Base class for parsing agent output into agent action/finish.
Parses tool invocations and final answers in JSON format.
Expects output to be in one of two formats.
If the output signals that an action should be taken, should be in the below format. This will result in an AgentAction being returned.
{"action": "search", "action_input": "2+2"}
If the output signals that a final answer should be given, should be in the below format. This will result in an AgentFinish being returned.
{"action": "Final Answer", "action_input": "4"}
Output parser with retries for the structured chat agent.
Agent that calls the language model and deciding the action.
This is driven by a LLMChain. The prompt in the LLMChain MUST include a variable called "agent_scratchpad" where the agent can put its intermediary work.
Chain to run queries against LLMs.
This class is deprecated. See below for an example implementation using LangChain runnables:
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI
prompt_template = "Tell me a {adjective} joke"
prompt = PromptTemplate(input_variables=["adjective"], template=prompt_template)
model = OpenAI()
chain = prompt | model | StrOutputParser()
chain.invoke("your adjective here")Structured Chat Agent.