langchain.agents.agent.BaseSingleActionAgent¶
- class langchain.agents.agent.BaseSingleActionAgent[source]¶
Bases:
BaseModelBase Single Action Agent class.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- abstract async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) Union[AgentAction, AgentFinish][source]¶
Given input, decided what to do.
- Parameters
intermediate_steps – Steps the LLM has taken to date, along with observations
callbacks – Callbacks to run.
**kwargs – User inputs.
- Returns
Action specifying what tool to use.
- classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, **kwargs: Any) BaseSingleActionAgent[source]¶
- abstract plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) Union[AgentAction, AgentFinish][source]¶
Given input, decided what to do.
- Parameters
intermediate_steps – Steps the LLM has taken to date, along with observations
callbacks – Callbacks to run.
**kwargs – User inputs.
- Returns
Action specifying what tool to use.
- return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) AgentFinish[source]¶
Return response when agent has been stopped due to max iterations.
- save(file_path: Union[Path, str]) None[source]¶
Save the agent.
- Parameters
file_path – Path to file to save the agent to.
Example: .. code-block:: python
# If working with agent executor agent.agent.save(file_path=”path/agent.yaml”)
- property return_values: List[str]¶
Return values of the agent.