OpenAIMultiFunctionsAgent#
- class langchain.agents.openai_functions_multi_agent.base.OpenAIMultiFunctionsAgent[source]#
Bases:
BaseMultiActionAgent
Deprecated since version 0.1.0: Use
create_openai_tools_agent
instead.Agent driven by OpenAIs function powered API.
- Parameters:
llm β This should be an instance of ChatOpenAI, specifically a model that supports using functions.
tools β The tools this agent has access to.
prompt β The prompt for this agent, should support agent_scratchpad as one of the variables. For an easy way to construct this prompt, use OpenAIMultiFunctionsAgent.create_prompt(β¦)
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.
- param llm: BaseLanguageModel [Required]#
- param prompt: BasePromptTemplate [Required]#
- async aplan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: List[BaseCallbackHandler] | BaseCallbackManager | None = None, **kwargs: Any) List[AgentAction] | AgentFinish [source]#
Async given input, decided what to do.
- Parameters:
intermediate_steps (List[Tuple[AgentAction, str]]) β Steps the LLM has taken to date, along with observations.
callbacks (List[BaseCallbackHandler] | BaseCallbackManager | None) β Callbacks to use. Default is None.
**kwargs (Any) β User inputs.
- Returns:
Action specifying what tool to use.
- Return type:
List[AgentAction] | AgentFinish
- classmethod create_prompt(system_message: SystemMessage | None = SystemMessage(content='You are a helpful AI assistant.'), extra_prompt_messages: List[BaseMessagePromptTemplate] | None = None) BasePromptTemplate [source]#
Create prompt for this agent.
- Parameters:
system_message (SystemMessage | None) β Message to use as the system message that will be the first in the prompt.
extra_prompt_messages (List[BaseMessagePromptTemplate] | None) β Prompt messages that will be placed between the system message and the new human input. Default is None.
- Returns:
A prompt template to pass into this agent.
- Return type:
- classmethod from_llm_and_tools(llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: BaseCallbackManager | None = None, extra_prompt_messages: List[BaseMessagePromptTemplate] | None = None, system_message: SystemMessage | None = SystemMessage(content='You are a helpful AI assistant.'), **kwargs: Any) BaseMultiActionAgent [source]#
Construct an agent from an LLM and tools.
- Parameters:
llm (BaseLanguageModel) β The language model to use.
tools (Sequence[BaseTool]) β A list of tools to use.
callback_manager (BaseCallbackManager | None) β The callback manager to use. Default is None.
extra_prompt_messages (List[BaseMessagePromptTemplate] | None) β Extra prompt messages to use. Default is None.
system_message (SystemMessage | None) β The system message to use. Default is a default system message.
kwargs (Any) β Additional arguments.
- Return type:
- plan(intermediate_steps: List[Tuple[AgentAction, str]], callbacks: List[BaseCallbackHandler] | BaseCallbackManager | None = None, **kwargs: Any) List[AgentAction] | AgentFinish [source]#
Given input, decided what to do.
- Parameters:
intermediate_steps (List[Tuple[AgentAction, str]]) β Steps the LLM has taken to date, along with observations.
callbacks (List[BaseCallbackHandler] | BaseCallbackManager | None) β Callbacks to use. Default is None.
**kwargs (Any) β User inputs.
- Returns:
Action specifying what tool to use.
- Return type:
List[AgentAction] | AgentFinish
- return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[AgentAction, str]], **kwargs: Any) AgentFinish #
Return response when agent has been stopped due to max iterations.
- Parameters:
early_stopping_method (str) β Method to use for early stopping.
intermediate_steps (List[Tuple[AgentAction, str]]) β Steps the LLM has taken to date, along with observations.
**kwargs (Any) β User inputs.
- Returns:
Agent finish object.
- Return type:
- Raises:
ValueError β If early_stopping_method is not supported.
- save(file_path: Path | str) None #
Save the agent.
- Parameters:
file_path (Path | str) β Path to file to save the agent to.
- Raises:
NotImplementedError β If agent does not support saving.
ValueError β If file_path is not json or yaml.
- Return type:
None
Example: .. code-block:: python
# If working with agent executor agent.agent.save(file_path=βpath/agent.yamlβ)
- tool_run_logging_kwargs() Dict #
Return logging kwargs for tool run.
- Return type:
Dict
- property functions: List[dict]#
Get the functions for the agent.
- property input_keys: List[str]#
Get input keys. Input refers to user input here.
- property return_values: List[str]#
Return values of the agent.