ReAct Agent Documentation
Functions
create_agent(llm, tools, callbacks=[])
Creates and initializes a LangChain agent configured with the ZERO_SHOT_REACT_DESCRIPTION strategy.
This agent uses provided tools and a large language model (LLM) to perform tasks using a zero-shot reasoning and action (ReAct) methodology.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm
|
The large language model instance used by the agent for generating responses. |
required | |
tools
|
list
|
A list of Tool objects that the agent can use to accomplish tasks. |
required |
callbacks
|
list
|
A list of callback functions to monitor agent interactions. Defaults to an empty list. |
[]
|
Returns:
| Type | Description |
|---|---|
|
An initialized LangChain agent ready to perform ReAct-style tasks. |
Example
from langchain.llms import OpenAI
from langchain.agents import Tool
from my_tools import custom_tool
llm = OpenAI(model="gpt-3.5-turbo")
tools = [custom_tool]
agent = create_agent(llm, tools)
response = agent.run("Extract invoice data from the provided document.")
print(response)