Friday, September 20, 2024

What's New in LangChain v0.3

1. LangChain v0.3 release for Python and JavaScript ecosystems.
2. Python changes include upgrade to Pydantic 2, end-of-life for Pydantic 1, and end-of-life for Python 3.8.
3. JavaScript changes entail the addition of @langchain/core as a peer dependency, explicit installation requirement, and non-blocking callbacks by default.
4. Removal of deprecated document loader and self-query entrypoints from “langchain” in favor of entrypoints in @langchain/community and integration packages.
5. Deprecated usage of objects with a “type” as a BaseMessageLike in favor of MessageWithRole.
6. Improvements include moving integrations to individual packages, revamped integration docs and API references, simplified tool definition and usage, added utilities for interacting with chat models, and dispatching custom events.
7. How-to guides available for migrating to the new version for Python and JavaScript.
8. Versioned documentation available with previous versions still accessible online.
9. LangGraph integration recommended for building stateful, multi-actor applications with LLMs in LangChain v0.3.
10. Upcoming improvements in LangChain’s multi-modal capabilities and ongoing work on enhancing documentation and integration reliability.

Wednesday, September 04, 2024

Differences: OpenAI vs. Azure OpenAI

OpenAI: Pioneering AI Advancements

OpenAI, a renowned research laboratory, stands at the forefront of AI development with a mission to create safe and beneficial AI solutions. Their arsenal includes ground breaking models such as ChatGPT, GPT-4, GPT-4o, DALL-E, Whisper, CLIP, MuseNet, and Jukebox, each pushing the boundaries of AI applications. From natural language processing to image generation and music composition, OpenAI's research spans diverse AI domains, promising exciting innovations for researchers, developers, and enthusiasts alike.

Azure OpenAI: Uniting Microsoft's Cloud Power with AI Expertise

Azure OpenAI is a powerful collaboration between Microsoft and OpenAI, combining Microsoft's robust cloud infrastructure with OpenAI's AI expertise. This partnership has build a secure and reliable platform within the Azure ecosystem, offering access to state-of-the-art AI models like GPT, Codex, and DALL-E while safeguarding customer data. Azure OpenAI's integration with other Microsoft Azure services amplifies its capabilities, enabling seamless data processing and analysis for intelligent applications.

Key Distinctions: OpenAI vs. Azure OpenAI

A comparative analysis reveals essential distinctions between OpenAI and Azure OpenAI, showcasing their strengths and focus areas.

While OpenAI concentrates on pioneering AI research and development with a strong emphasis on comprehensive data privacy policies, where as Azure OpenAI offers enterprise-grade security and integration within the Azure ecosystem.

Azure OpenAI serves as an optimal solution for businesses seeking to leverage advanced AI capabilities while maintaining data control and security, making it a preferred choice for enterprise implementations with its customer driven approach.

Sunday, July 07, 2024

How to set specific version of dependency in poetry

I am here will set langchain-core==0.2.2 instead of 0.2.3 sent in toml file.

To set Poetry to use langchain-core==0.2.2, you can add it as a dependency in your pyproject.toml file. Here's how you can do it:

  1. Open your pyproject.toml file in your project directory.
  2. Locate the [tool.poetry.dependencies] section.
  3. Add the following line to specify the version of langchain-core you want to use: langchain-core = "==0.2.2"
  4. Save the pyproject.toml file.

After making this change, Poetry will use langchain-core==0.2.2 when you run poetry install or poetry update.

Note: Make sure you have Poetry installed on your system before running these commands. You can install Poetry by following the instructions on the official Poetry website.

Saturday, June 01, 2024

Common prevention techniques against injection attacks

With reference to my previous blog post. Here are few prevention techniques against injection attacks:

  1. Input Validation: Validate and sanitize all user input to ensure it meets expected formats and ranges. Avoid dynamic queries built using untrusted input.

  2. Use Parameterized Queries: Utilize parameterized queries with prepared statements or stored procedures to prevent the injection of malicious code.

  3. Escaping Input: Special characters in user input should be escaped to neutralize their harmful effects, making them harmless before use.

  4. Least Privilege Principle: Applications should operate with the least privilege necessary to limit the potential impact of a successful injection attack.

  5. Regular Software Patching: Keep all software components and frameworks up to date to patch known injection vulnerabilities.

  6. Web Application Firewalls (WAF): Implement WAF solutions to filter and block malicious input before it reaches the application.

  7. Code Reviews and Security Testing: Conduct regular code reviews, security audits, and penetration testing to identify and mitigate potential injection vulnerabilities.

  8. Secure Development Practices: Train developers in secure coding practices to minimize the introduction of injection vulnerabilities during application development.

  9. Secure Configuration: Follow best practices for server configuration and secure coding guidelines to reduce the attack surface for injection attacks.

By implementing a combination of these techniques and maintaining a proactive approach to web application security, organizations can significantly reduce the risk of falling victim to injection attacks. 

Friday, May 24, 2024

How to set verbose in Langchain

Here is how you can set globally. 

from langchain.globals import set_verbose, set_debug

set_debug(True)
set_verbose(True)
  

You can also scope verbosity down to a single object, in which case only the inputs and outputs to that object are printed (along with any additional callbacks calls made specifically by that object).

# Passing verbose=True to initialize_agent will pass that along to the AgentExecutor (which is a Chain).
agent = initialize_agent(
    tools, 
    llm, 
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True,
)

agent.run("who invented electricity")
  

Hope this helps!!