Create an agent that enables multiple tools to be used in sequence to complete a task.
create_cohere_react_agent(
llm: BaseLanguageModel,
tools: Sequence[BaseTool],
prompt: ChatPromptTemplate
) -> RunnableExample:
from langchain.agents import AgentExecutor
from langchain.prompts import ChatPromptTemplate
from langchain_cohere import ChatCohere, create_cohere_react_agent
prompt = ChatPromptTemplate.from_template("{input}")
tools = [] # Populate this with a list of tools you would like to use.
llm = ChatCohere()
agent = create_cohere_react_agent(
llm,
tools,
prompt
)
agent_executor = AgentExecutor(agent=agent, tools=tools)
agent_executor.invoke({
"input": "In what year was the company that was founded as Sound of Music added to the S&P 500?",
})| Name | Type | Description |
|---|---|---|
llm* | BaseLanguageModel | The |
tools* | Sequence[BaseTool] | Tools this agent has access to. |
prompt* | ChatPromptTemplate | The prompt to use. |