langchain_cohere.react_multi_hop.agent
.create_cohere_react_agent¶
- langchain_cohere.react_multi_hop.agent.create_cohere_react_agent(llm: BaseLanguageModel, tools: Sequence[BaseTool], prompt: ChatPromptTemplate) Runnable [source]¶
Create an agent that enables multiple tools to be used in sequence to complete a task.
- Parameters
llm (BaseLanguageModel) – The ChatCohere LLM instance to use.
tools (Sequence[BaseTool]) – Tools this agent has access to.
prompt (ChatPromptTemplate) – The prompt to use.
- Returns
A Runnable sequence representing an agent. It takes as input all the same input variables as the prompt passed in does and returns a List[AgentAction] or a single AgentFinish.
The AgentFinish will have two fields: * output: str - The output string generated by the model * citations: List[CohereCitation] - A list of citations that refer to the
output and observations made by the agent. If there are no citations this list will be empty.
- Return type
Example
- . code-block:: python
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?”,
})