Toggle Menu
Prev Up Next

# `langchain_experimental.agents.agent_toolkits.python.base`.create_python_agent

langchain_experimental.agents.agent_toolkits.python.base.create_python_agent(llm: BaseLanguageModel, tool: PythonREPLTool, agent_type: AgentType = AgentType.ZERO_SHOT_REACT_DESCRIPTION, callback_manager: Optional[BaseCallbackManager] = None, verbose: bool = False, prefix: str = 'You are an agent designed to write and execute python code to answer questions.\nYou have access to a python REPL, which you can use to execute python code.\nIf you get an error, debug your code and try again.\nOnly use the output of your code to answer the question. \nYou might know the answer without running any code, but you should still run the code to get the answer.\nIf it does not seem like you can write code to answer the question, just return "I don\'t know" as the answer.\n', agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → AgentExecutor

  Construct a python agent from an LLM and tool.

  Parameters

    - llm (BaseLanguageModel) –

    - tool (PythonREPLTool) –

    - agent_type (AgentType) –

    - callback_manager (Optional[BaseCallbackManager]) –

    - verbose (bool) –

    - prefix (str) –

    - agent_executor_kwargs (Optional[Dict[str, Any]]) –

    - kwargs (Dict[str, Any]) –

  Return type

    AgentExecutor