LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreoutput_parsersopenai_tools
    Module●Since v0.1

    openai_tools

    Parse tools for OpenAI tools output.

    Attributes

    attribute
    TypeBaseModel: type[BaseModel]
    attribute
    logger

    Functions

    function
    invalid_tool_call

    Create an invalid tool call.

    function
    create_tool_call

    Create a tool call.

    function
    parse_partial_json

    Parse a JSON string that may be missing closing braces.

    function
    is_pydantic_v1_subclass

    Check if the given class is Pydantic v1-like.

    function
    is_pydantic_v2_subclass

    Check if the given class is Pydantic v2-like.

    function
    parse_tool_call

    Parse a single tool call.

    function
    make_invalid_tool_call

    Create an InvalidToolCall from a raw tool call.

    function
    parse_tool_calls

    Parse a list of tool calls.

    Classes

    class
    OutputParserException

    Exception that output parsers should raise to signify a parsing error.

    This exists to differentiate parsing errors from other code or execution errors that also may arise inside the output parser.

    OutputParserException will be available to catch and handle in ways to fix the parsing error, while other errors will be raised.

    class
    AIMessage

    Message from an AI.

    An AIMessage is returned from a chat model as a response to a prompt.

    This message represents the output of the model and consists of both the raw output as returned by the model and standardized fields (e.g., tool calls, usage metadata) added by the LangChain framework.

    class
    InvalidToolCall

    Allowance for errors made by LLM.

    Here we add an error key to surface errors made during generation (e.g., invalid JSON arguments.)

    class
    BaseCumulativeTransformOutputParser

    Base class for an output parser that can handle streaming input.

    class
    ChatGeneration

    A single chat generation output.

    A subclass of Generation that represents the response from a chat model that generates chat messages.

    The message attribute is a structured representation of the chat message. Most of the time, the message will be of type AIMessage.

    Users working with chat models will usually access information via either AIMessage (returned from runnable interfaces) or LLMResult (available via callbacks).

    class
    Generation

    A single text generation output.

    Generation represents the response from an "old-fashioned" LLM (string-in, string-out) that generates regular text (not chat messages).

    This model is used internally by chat model and will eventually be mapped to a more general LLMResult object, and then projected into an AIMessage object.

    LangChain users working with chat models will usually access information via AIMessage (returned from runnable interfaces) or LLMResult (available via callbacks). Please refer to AIMessage and LLMResult for more information.

    class
    JsonOutputToolsParser

    Parse tools from OpenAI response.

    class
    JsonOutputKeyToolsParser

    Parse tools from OpenAI response.

    class
    PydanticToolsParser

    Parse tools from OpenAI response.

    View source on GitHub