initialize_agent#

langchain.agents.initialize.initialize_agent(tools: Sequence[BaseTool], llm: BaseLanguageModel, agent: AgentType | None = None, callback_manager: BaseCallbackManager | None = None, agent_path: str | None = None, agent_kwargs: dict | None = None, *, tags: Sequence[str] | None = None, **kwargs: Any) AgentExecutor[source]#

Deprecated since version 0.1.0: Use () instead.

Load an agent executor given tools and LLM.

Parameters:
  • tools (Sequence[BaseTool]) – List of tools this agent has access to.

  • llm (BaseLanguageModel) – Language model to use as the agent.

  • agent (AgentType | None) – Agent type to use. If None and agent_path is also None, will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION. Defaults to None.

  • callback_manager (BaseCallbackManager | None) – CallbackManager to use. Global callback manager is used if not provided. Defaults to None.

  • agent_path (str | None) – Path to serialized agent to use. If None and agent is also None, will default to AgentType.ZERO_SHOT_REACT_DESCRIPTION. Defaults to None.

  • agent_kwargs (dict | None) – Additional keyword arguments to pass to the underlying agent. Defaults to None.

  • tags (Sequence[str] | None) – Tags to apply to the traced runs. Defaults to None.

  • kwargs (Any) – Additional keyword arguments passed to the agent executor.

Returns:

An agent executor.

Raises:
  • ValueError – If both agent and agent_path are specified.

  • ValueError – If agent is not a valid agent type.

  • ValueError – If both agent and agent_path are None.

Return type:

AgentExecutor

Examples using initialize_agent