LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicagentsopenai_functions_agentbaseOpenAIFunctionsAgent
    Class●Since v1.0Deprecated

    OpenAIFunctionsAgent

    An Agent driven by OpenAIs function powered API.

    Copy
    OpenAIFunctionsAgent()

    Bases

    BaseSingleActionAgent

    Used in Docs

    • Llmonitor integration
    • Robocorp toolkit integration

    Parameters

    NameTypeDescription
    llm*unknown

    This should be an instance of ChatOpenAI, specifically a model that supports using functions.

    tools*unknown

    The tools this agent has access to.

    prompt*unknown

    The prompt for this agent, should support agent_scratchpad as one of the variables. For an easy way to construct this prompt, use OpenAIFunctionsAgent.create_prompt(...)

    output_parser*unknown

    The output parser for this agent. Should be an instance of OpenAIFunctionsAgentOutputParser.

    Attributes

    attribute
    llm: BaseLanguageModel
    attribute
    tools: Sequence[BaseTool]
    attribute
    prompt: BasePromptTemplate
    attribute
    output_parser: type[OpenAIFunctionsAgentOutputParser]
    attribute
    input_keys: list[str]

    Get input keys. Input refers to user input here.

    attribute
    functions: list[dict]

    Get functions.

    Methods

    method
    get_allowed_tools

    Get allowed tools.

    method
    validate_prompt

    Validate prompt.

    method
    plan

    Given input, decided what to do.

    method
    aplan

    Async given input, decided what to do.

    method
    return_stopped_response

    Return response when agent has been stopped due to max iterations.

    method
    create_prompt

    Create prompt for this agent.

    method
    from_llm_and_tools

    Construct an agent from an LLM and tools.

    Inherited fromBaseSingleActionAgent

    Attributes

    Areturn_values: list[str]
    —

    Return values of the agent.

    Methods

    Mdict
    —

    Return dictionary representation of agent.

    Msave
    —

    Save the agent.

    Mtool_run_logging_kwargs
    —

    Return logging kwargs for tool run.

    View source on GitHub