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-coreoutputsgeneration
    Module●Since v0.1

    generation

    Generation output schema.

    Functions

    Classes

    View source on GitHub
    function
    merge_dicts
    class
    Serializable
    class
    Generation
    class
    GenerationChunk

    Merge dictionaries.

    Merge many dicts, handling specific scenarios where a key exists in both dictionaries but has a value of None in 'left'. In such cases, the method uses the value from 'right' for that key in the merged dictionary.

    Serializable base class.

    This class is used to serialize objects to JSON.

    It relies on the following methods and properties:

    • is_lc_serializable: Is this class serializable?

      By design, even if a class inherits from Serializable, it is not serializable by default. This is to prevent accidental serialization of objects that should not be serialized.

    • get_lc_namespace: Get the namespace of the LangChain object.

      During deserialization, this namespace is used to identify the correct class to instantiate.

      Please see the Reviver class in langchain_core.load.load for more details.

      During deserialization an additional mapping is handle classes that have moved or been renamed across package versions.

    • lc_secrets: A map of constructor argument names to secret ids.

    • lc_attributes: List of additional attribute names that should be included as part of the serialized representation.

    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.

    GenerationChunk, which can be concatenated with other Generation chunks.