Langchain agents documentation python. LangChain simplifies every stage of the LLM application lifecycle: Development: Build your applications using LangChain's open-source components and third-party integrations. We will equip it with a set of tools using LangChain's SQLDatabaseToolkit. Jul 23, 2025 · LangChain is an open-source framework designed to simplify the creation of applications using large language models (LLMs). Getting Started Documentation Aug 28, 2024 · A comprehensive tutorial on building multi-tool LangChain agents to automate tasks in Python using LLMs and chat models using OpenAI. Deprecated since version 0. 📄️ Apify This notebook shows how to use the Apify integration for LangChain. create_python_agent # langchain_experimental. This is useful when working with ChatModels, and is used to reconstruct conversation history from the agent’s perspective. The agent executes the action (e. In chains, a sequence of actions is hardcoded (in code). 0: Use create_react_agent instead. Classes In Agents, a language model is used as a reasoning engine to determine which actions to take and in which order. chat. For details, refer to the LangGraph documentation as well as guides for LangChain Python API Reference langchain-experimental: 0. create_structured_chat_agent(llm: ~langchain_core. LangGraph exposes high level interfaces for creating common types of agents, as well as a low-level API for composing custom flows. g. 0 or 0. These applications use a technique known as Retrieval Augmented Generation, or RAG. 3 versions of all the base packages. Sep 16, 2024 · See the deprecated chains and associated migration guides here. BaseLanguageModel, tools: ~collections. create_csv_agent(llm: LanguageModelLike, path: str | IOBase | List[str | IOBase], pandas_kwargs: dict | None = None, **kwargs: Any) → AgentExecutor [source] # Create pandas dataframe agent by loading csv to a dataframe. This state management can take several forms, including: Simply stuffing previous messages into a chat model prompt. If you're looking to get started with chat models, vector stores, or other LangChain components from a specific provider, check out our supported This guide provides explanations of the key concepts behind the LangChain framework and AI applications more broadly. You can peruse LangSmith how-to guides here, but we'll highlight a few sections that are particularly relevant to LangChain below: Evaluation Agent # class langchain. Sep 18, 2024 · Let’s walk through a simple example of building a Langchain Agent that performs two tasks: retrieves information from Wikipedia and executes a Python function. Overview The tool abstraction in LangChain associates a Python function with a schema that defines the function's name, description and expected arguments. 27 # Main entrypoint into package. param log: str [Required] # Additional information to log about the action. agent_toolkits. param callback_manager: BaseCallbackManager | None = None # [DEPRECATED] Use callbacks instead. This template uses a csv agent with tools (Python REPL) and memory (vectorstore) for interaction (question-answering) with text data. The agent can store, retrieve, and use memories to enhance its interactions with users. ATTENTION The schema definitions are provided for backwards compatibility. For the JavaScript documentation, see here. As a language model integration framework, LangChain's use-cases largely overlap with those of language models in general, including document analysis and summarization, chatbots, and code analysis. This agent uses a search tool to look up answers to the simpler questions in order to answer the original complex question. Agents: Agents involve an LLM making decisions about which Actions to take, taking that Action, seeing an Observation, and repeating that until done. Or, if you prefer to look at the fundamentals first, you can check out the sections on Expression Language and the various components LangChain provides for more background knowledge. The main advantages of using the SQL Agent are: It can answer questions based on the databases' schema as well as on the databases' content (like describing a specific table). Agents are systems that take a high-level task and use an LLM as a reasoning engine to decide what actions to take and execute those actions. How to create tools When constructing an agent, you will need to provide it with a list of Tools that it can use. LangChain's products work seamlessly together to provide an integrated solution for every step of the application development journey. create_structured_chat_agent # langchain. create_python_agent( llm: BaseLanguageModel, tool: PythonREPLTool, agent_type: AgentType = AgentType. nltk langchain_text_splitters. Read about all the agent types here. 1, we recommend that you first upgrade to 0. Create an AgentAction AgentAction # class langchain_core. Class hierarchy: Build controllable agents with LangGraph, our low-level agent orchestration framework. Productionization The agent executes the action (e. agent. path (Union[str, IOBase Deprecated since version 0. messages import ( AIMessage, BaseMessage, FunctionMessage, HumanMessage, ) The agent executes the action (e. Get started with Python Get started with JavaScript You are currently on a page documenting the use of Ollama models as text completion models. Deploy and scale with LangGraph Platform, with APIs for state management, a visual studio for debugging, and multiple deployment options. 💁 Contributing As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation. Get started Familiarize yourself with LangChain's open-source components by building simple applications. 30 sql_agent. This is the Python specific portion of the documentation. For more information on these concepts, please see our full documentation. LangChain is a software framework that helps facilitate the integration of large language models (LLMs) into applications. This is similar to AgentAction, but includes a message log consisting of chat messages. markdown langchain_text_splitters. How to add memory to chatbots A key feature of chatbots is their ability to use the content of previous conversational turns as context. More complex modifications param agent: BaseSingleActionAgent | BaseMultiActionAgent | Runnable [Required] # The agent to run for creating a plan and determining actions to take at each step of the execution loop. base. Use LangGraph to build stateful agents with first-class streaming and human-in-the-loop support. Continuously improve your application with LangSmith's tools for LLM observability, evaluation, and prompt engineering. 20,<0. An agent that holds a conversation in addition to using tools. abc. LangChain provides the smoothest path to high quality agents. load_tools. extra_tools (Sequence[BaseTool]) – Additional tools to give to agent on top of the ones that come with SQLDatabaseToolkit. Parameters: llm (LanguageModelLike) – Language model to use for the agent. You can use an agent with a different type of model than it is intended for, but it likely won't produce Apr 11, 2024 · Quickstart To best understand the agent framework, let's build an agent that has two tools: one to look things up online, and one to look up specific data that we've loaded into a index. 0: LangChain agents will continue to be supported, but it is recommended for new use cases to be built with LangGraph. LangGraph offers a more flexible and full-featured framework for building agents, including support for tool-calling, persistence of state, and human-in-the-loop workflows. Using LangGraph's pre-built ReAct agent constructor, we can do this in one line. 3 langchain_text_splitters. In Agents, a language model is used as a reasoning engine to determine which actions to take and in which order. 43 ¶ langchain_core. python langchain_text_splitters. Getting Started # Checkout the below guide for a walkthrough of how to get started using LangChain to create an Language Model application. Classes AgentActionMessageLog # class langchain_core. jsx langchain_text_splitters. Many popular Ollama models are chat completion models. A basic agent works in the following manner: Given a prompt an agent uses an LLM to request an action to take (e. 2 docs. agents module. Tools can be passed to chat models that support tool calling allowing the model to request the execution of a specific function with specific inputs. For details, refer to the LangGraph documentation as well as guides for In this quickstart we'll show you how to build a simple LLM application with LangChain. load_tools # langchain_community. Contribute to langchain-ai/langchain development by creating an account on GitHub. LLMs are large deep-learning models pre-trained on large amounts of data that can generate responses to user queries—for example, answering questions or creating images from text-based prompts. Classes create_csv_agent # langchain_experimental. This log can be used in They can answer questions based on the databases' schema as well as on the databases' content (like describing a specific table). conversational. 📄️ AWS Lambda Amazon AWS Lambda is a create_python_agent # langchain_experimental. csv. LangChain is an open source framework for building applications based on large language models (LLMs). Tools are utilities designed to be called by a model: their inputs are designed to be generated by models, and their outputs are designed to be passed back to models. This will work with either 0. LangChain provides a standard interface for agents, a selection of agents to choose from, and examples of end to end agents. 5rc1 autonomous_agents langchain-core: 0. Concepts The core idea of agents is to use a language model to choose a sequence of actions to take. The interfaces for core components like chat models, LLMs, vector stores, retrievers, and more are defined here. konlpy langchain_text_splitters. We'll use the tool calling agent, which is generally the most reliable kind and the recommended one for most use cases. LangChain Python API Reference langchain-cohere: 0. This is driven by a LLMChain. structured_chat. LangChain Labs is a collection of agents and experimental AI products. This framework comes with a package for both Python and JavaScript. You can access that version of the documentation in the v0. 📄️ ArXiv This notebook goes over how to use the arxiv tool with an agent. There are several key components here: Schema LangChain has several abstractions to make working with agents easy © Copyright 2023, LangChain Inc. load. Oct 10, 2023 · Learn about the essential components of LangChain — agents, models, chunks and chains — and how to harness the power of LangChain in Python. latest We will go over this pretty quickly - for a deeper dive into what exactly is going on, check out the Agent's Getting Started documentation Install langchain hub first Agents LangChain has a SQL Agent which provides a more flexible way of interacting with SQL Databases than a chain. create_sql_agent (llm [, ]) Construct a SQL agent from an LLM and toolkit or database. If you're using langgraph, upgrade to langgraph>=0. Below we assemble a minimal SQL agent. For details, refer to the LangGraph documentation as well as guides for Example code for building applications with LangChain, with an emphasis on more applied and end-to-end examples than contained in the main documentation. These are applications that can answer questions about specific source information. Agents use language models to choose a sequence of actions to take. API reference Head to the reference section for full documentation of all classes and methods in the LangChain and LangChain Experimental Python packages. Dec 9, 2024 · The schemas for the agents themselves are defined in langchain. How to update your code If you're using langchain / langchain-community / langchain-core 0. LangChain implements a standard interface for large language models and related technologies, such as embedding models and vector stores, and integrates with hundreds of providers. Our goal with LangChainHub is to be a single stop shop for sharing prompts, chains, agents and more. As a starting point, we’re launching the hub with a repository of prompts used in LangChain. AgentExecutor [source] # Bases: Chain Agent that is using tools. For a purely conceptual guide to LangChain, see here. Jul 23, 2025 · LangChain allows AI developers to develop applications based on the combined Large Language Models (such as GPT-4) with external sources of computation and data. Agents select and use Tools and Toolkits for actions. Learn the essentials of LangSmith — our platform for LLM application development, whether you're building with LangChain or not. One of the most powerful applications enabled by LLMs is sophisticated question-answering (Q&A) chatbots. agents. , runs the tool), and receives an observation. 72 # langchain-core defines the base abstractions for the LangChain ecosystem. Introduction LangChain is a framework for developing applications powered by large language models (LLMs). We recommend that you use LangGraph for building agents. ConversationalAgent [source] # Bases: Agent Deprecated since version 0. When the agent reaches a stopping condition, it returns a final return value. Defaults to None Deprecated since version 0. langchain: 0. Tools allow agents to interact with various resources and services like APIs Tools 📄️ Alpha Vantage Alpha Vantage Alpha Vantage provides realtime and historical financial market data through a set of powerful and developer-friendly data APIs and spreadsheets. . create_python_agent(llm: BaseLanguageModel, tool: PythonREPLTool, agent_type: AgentType = AgentType. LangSmith documentation is hosted on a separate site. Agents let us do just this. latex langchain_text_splitters. The action consists of the name of the tool to execute and the input to pass to the tool. AgentAction [source] # Bases: Serializable Represents a request to execute an action by an agent. The above, but trimming old messages to reduce the amount of distracting information the model has to deal with. agent_executor_kwargs (Optional[Dict[str, Any]]) – Arbitrary additional AgentExecutor args. For details, refer to the LangGraph documentation as well as guides for AgentExecutor # class langchain. For the current stable version, see this version (Latest). """ # noqa: E501 from __future__ import annotations import json from typing import Any, List, Literal, Sequence, Union from langchain_core. 15 # Main entrypoint into package. Tools allow agents to interact with various resources and services like Design agents with control Add human oversight and create stateful, scalable workflows with AI agents. Pass the tool you want an agent to access in a list to the load_tools () method. Create a new model by parsing and validating input data from keyword arguments. The agent returns the observation to the LLM, which can then be used to generate the next action. The log is used to pass along extra information about the action. Guides Best practices for developing with LangChain. The core idea of agents is to use a language model to choose a sequence of actions to take. latest LangChain Python API Reference langchain-aws: 0. The schemas for the agents themselves are defined in langchain. It provides a standard interface for chains, many integrations with other tools, and end-to-end chains for common applications. It seamlessly integrates with LangChain and LangGraph, and you can use it to inspect and debug individual steps of your chains and agents as you build. For details, refer to the LangGraph documentation as well as guides for Deprecated since version 0. load_tools( tool_names: List[str], llm: BaseLanguageModel | None = None, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None, allow_dangerous_tools: bool = False, **kwargs: Any, ) → List[BaseTool] [source] # Load tools based on their name. Sequence [~langchain_core. Callable [ [list [~langchain_core. It can recover from errors by running a generated query, catching the traceback and regenerating it langgraph langgraph is an extension of langchain aimed at building robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. Oct 13, 2023 · To create an agent that accesses tools, import the load_tools, initialize_agent methods, and AgentType object from the langchain. 2. Classes This is documentation for LangChain v0. tools. , a tool to run). Still, this is a great way to get started with LangChain - a lot of features can be built with just some prompting and an LLM call! Agent # class langchain. Agent Types This categorizes all the available agents along a few dimensions. In agents, a language model is used as a reasoning engine to determine which actions to take and in which order. 17 ¶ langchain. See the full list of integrations in the Section Navigation. Jul 24, 2025 · LangChain provides some prompts/chains for assisting in this. python. json langchain_text_splitters. LangChain comes with a number of built-in agents that are optimized for different use cases. 0: Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc. For details, refer to the LangGraph documentation as well as guides for Dec 9, 2024 · langchain 0. When you use all LangChain products, you'll build better, get to production quicker, and grow visibility -- all with less set up and friction. param callbacks: Callbacks = None # Optional list of callback handlers (or callback manager). Contributing Check out the developer's guide for guidelines on contributing and help getting your dev environment set up. load_tools(tool_names: List[str], llm: BaseLanguageModel | None = None, callbacks: List[BaseCallbackHandler] | BaseCallbackManager | None = None, allow_dangerous_tools: bool = False, **kwargs: Any) → List[BaseTool] [source] # Load tools based on their name. Setup: LangSmith By definition, agents take a self-determined, input-dependent In Agents, a language model is used as a reasoning engine to determine which actions to take and in which order. 2 or 0. character langchain_text_splitters. Jun 17, 2025 · LangChain supports the creation of agents, or systems that use LLMs as reasoning engines to determine which actions to take and the inputs necessary to perform the action. This tutorial shows how to implement an agent with long-term memory capabilities using LangGraph. BaseTool], prompt: ~langchain_core. 🗃️ Q&A with RAG 6 items 🗃️ Extracting structured output 4 items 🗃️ Chatbots 5 items 🗃️ Tool use and agents 8 items 🗃️ Query analysis 4 items See the full list of integrations in the Section Navigation. prompts. language_models. This tutorial previously used the RunnableWithMessageHistory abstraction. In Chains, a sequence of actions is hardcoded. This application will translate text from English into another language. Dec 9, 2024 · langchain_core 0. Key concepts Tools are a way to encapsulate a function and its schema in a way that can be LangChain's products work seamlessly together to provide an integrated solution for every step of the application development journey. agents ¶ Schema definitions for representing agent actions, observations, and return values. 1, which is no longer actively maintained. This will assume knowledge of LLMs and retrieval so if you haven't already explored those sections, it is recommended you do so. BaseTool]], str] = <function render agent_toolkits # Toolkits are sets of tools that can be used to interact with various services and APIs. AgentActionMessageLog [source] # Bases: AgentAction Representation of an action to be executed by an agent. sentence_transformers langchain_text This notebook showcases an agent designed to write and execute Python code to answer a question. \nYou have access An agent that breaks down a complex question into a series of simpler questions. Why is LangChain Important? LangChain Python API Reference langchain-aws: 0. html langchain_text_splitters. LangChain 是一个用于开发由语言模型驱动的应用程序的框架。 我们相信,最强大和不同的应用程序不仅将通过 API 调用语言模型,还将: 数据感知:将语言模型与其他数据源连接在一起。 主动性:允许语言模型与其环境进行交互。 因此,LangChain 框架的设计目标是为了实现这些类型的应用程序。 组件:LangChain 为处理语言模型所需的组件提供模块化的抽象。 LangChain 还为所有这些抽象提供了实现的集合。 这些组件旨在易于使用,无论您是否使用 LangChain 框架的其余部分。 用例特定链:链可以被看作是以特定方式组装这些组件,以便最好地完成特定用例。 这旨在成为一个更高级别的接口,使人们可以轻松地开始特定的用例。 这些链也旨在可定制化。 🦜🔗 Build context-aware reasoning applications. In this comprehensive guide, we’ll New to LangChain or LLM app development in general? Read this material to quickly get up and running building your first applications. ConversationalAgent # class langchain. ChatPromptTemplate, tools_renderer: ~typing. ZERO_SHOT_REACT_DESCRIPTION, callback_manager: BaseCallbackManager | None = None, verbose: bool = False, prefix: str = 'You are an agent designed to write and execute python code to answer questions. 29 agents In Agents, a language model is used as a reasoning engine to determine which actions to take and in which order. This is a relatively simple LLM application - it's just a single LLM call plus some prompting. 3. Agent that calls the language model and deciding the action. Tutorials New to LangChain or LLM app development in general? Read this material to quickly get up and running building your first applications. Agent [source] # Bases: BaseSingleActionAgent Deprecated since version 0. agents ¶ Agent is a class that uses an LLM to choose a sequence of actions to take. LangGraph is an extension of LangChain specifically aimed at creating highly controllable and customizable agents. serializable import Serializable from langchain_core. langgraph langgraph is an extension of langchain aimed at building robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. © Copyright 2023, LangChain Inc. \nYou have access Nov 6, 2024 · LangChain is revolutionizing how we build AI applications by providing a powerful framework for creating agents that can think, reason, and take actions. Besides the actual function that is called, the Tool consists of several components: Construct a SQL agent from an LLM and toolkit or database. 1. The main thing this affects is the prompting strategy used. Intended Model Type Whether this agent is intended for Chat Models (takes in messages, outputs message) or LLMs (takes in string, outputs string). hlsr deefh rvxwqnk kvrp hlwlu vjsjsyr oidf dsxi gcqt igzp