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-corerunnablesconfigurableRunnableConfigurableFields
    Class●Since v0.1

    RunnableConfigurableFields

    Runnable that can be dynamically configured.

    A RunnableConfigurableFields should be initiated using the configurable_fields method of a Runnable.

    Here is an example of using a RunnableConfigurableFields with LLMs:

    from langchain_core.prompts import PromptTemplate
    from langchain_core.runnables import ConfigurableField
    from langchain_openai import ChatOpenAI
    
    model = ChatOpenAI(temperature=0).configurable_fields(
        temperature=ConfigurableField(
            id="temperature",
            name="LLM Temperature",
            description="The temperature of the LLM",
        )
    )
    # This creates a RunnableConfigurableFields for a chat model.
    
    # When invoking the created RunnableSequence, you can pass in the
    # value for your ConfigurableField's id which in this case
    # will be change in temperature
    
    prompt = PromptTemplate.from_template("Pick a random number above {x}")
    chain = prompt | model
    
    chain.invoke({"x": 0})
    chain.invoke({"x": 0}, config={"configurable": {"temperature": 0.9}})

    Here is an example of using a RunnableConfigurableFields with HubRunnables:

    from langchain_core.prompts import PromptTemplate
    from langchain_core.runnables import ConfigurableField
    from langchain_openai import ChatOpenAI
    from langchain.runnables.hub import HubRunnable
    
    prompt = HubRunnable("rlm/rag-prompt").configurable_fields(
        owner_repo_commit=ConfigurableField(
            id="hub_commit",
            name="Hub Commit",
            description="The Hub commit to pull from",
        )
    )
    
    prompt.invoke({"question": "foo", "context": "bar"})
    
    # Invoking prompt with `with_config` method
    
    prompt.invoke(
        {"question": "foo", "context": "bar"},
        config={"configurable": {"hub_commit": "rlm/rag-prompt-llama"}},
    )
    Copy
    RunnableConfigurableFields(
      self,
      *args: Any = (),
      **kwargs: Any = {}
    )

    Bases

    DynamicRunnable[Input, Output]

    Attributes

    attribute
    fields: dict[str, AnyConfigurableField]

    The configurable fields to use.

    attribute
    config_specs: list[ConfigurableFieldSpec]

    Get the configuration specs for the RunnableConfigurableFields.

    Methods

    method
    configurable_fields

    Inherited fromDynamicRunnable

    Attributes

    Adefault: strAconfig: RunnableConfig | None
    —

    The configuration to use.

    Amodel_configAInputType: AnyAOutputType: Any

    Methods

    Mis_lc_serializable
    —

    Return True as this class is serializable.

    Mget_lc_namespace
    —

    Get the namespace of the LangChain object.

    Mget_input_schemaMget_output_schemaMget_graphMwith_configMprepare
    —

    Prepare the Runnable for invocation.

    Minvoke
    —

    Invoke the retriever to get relevant documents.

    Mainvoke
    —

    Asynchronously invoke the retriever to get relevant documents.

    MbatchMabatchMstreamMastreamMtransformMatransform

    Inherited fromRunnableSerializable

    Attributes

    Aname: str
    —

    The name of the function.

    Amodel_config

    Methods

    Mto_json
    —

    Convert the graph to a JSON-serializable format.

    Mconfigurable_alternatives
    —

    Configure alternatives for Runnable objects that can be set at runtime.

    Inherited fromSerializable

    Attributes

    Alc_secrets: dict[str, str]
    —

    A map of constructor argument names to secret ids.

    Alc_attributes: dict
    —

    List of attribute names that should be included in the serialized kwargs.

    Amodel_config

    Methods

    Mis_lc_serializable
    —

    Return True as this class is serializable.

    Mget_lc_namespace
    —

    Get the namespace of the LangChain object.

    Mlc_id
    —

    Return a unique identifier for this class for serialization purposes.

    Mto_json
    —

    Convert the graph to a JSON-serializable format.

    Mto_json_not_implemented
    —

    Serialize a "not implemented" object.

    Inherited fromRunnable

    Attributes

    Aname: str
    —

    The name of the function.

    AInputType: AnyAOutputType: AnyAinput_schema: type[BaseModel]
    —

    The type of input this Runnable accepts specified as a Pydantic model.

    Aoutput_schema: type[BaseModel]
    —

    Output schema.

    Methods

    Mget_nameMget_input_schemaMget_input_jsonschema
    —

    Get a JSON schema that represents the input to the Runnable.

    Mget_output_schemaMget_output_jsonschema
    —

    Get a JSON schema that represents the output of the Runnable.

    Mconfig_schema
    —

    The type of config this Runnable accepts specified as a Pydantic model.

    Mget_config_jsonschema
    —

    Get a JSON schema that represents the config of the Runnable.

    Mget_graphMget_prompts
    —

    Return a list of prompts used by this Runnable.

    Mpipe
    —

    Pipe Runnable objects.

    Mpick
    —

    Pick keys from the output dict of this Runnable.

    Massign
    —

    Merge the Dict input with the output produced by the mapping argument.

    Minvoke
    —

    Invoke the retriever to get relevant documents.

    Mainvoke
    —

    Asynchronously invoke the retriever to get relevant documents.

    MbatchMbatch_as_completed
    —

    Run invoke in parallel on a list of inputs.

    MabatchMabatch_as_completed
    —

    Run ainvoke in parallel on a list of inputs.

    MstreamMastreamMastream_log
    —

    Stream all output from a Runnable, as reported to the callback system.

    Mastream_events
    —

    Generate a stream of events.

    MtransformMatransformMbind
    —

    Bind arguments to a Runnable, returning a new Runnable.

    Mwith_configMwith_listeners
    —

    Bind lifecycle listeners to a Runnable, returning a new Runnable.

    Mwith_alisteners
    —

    Bind async lifecycle listeners to a Runnable.

    Mwith_types
    —

    Bind input and output types to a Runnable, returning a new Runnable.

    Mwith_retry
    —

    Create a new Runnable that retries the original Runnable on exceptions.

    Mmap
    —

    Map a function to multiple iterables.

    Mwith_fallbacks
    —

    Add fallbacks to a Runnable, returning a new Runnable.

    Mas_tool
    —

    Create a BaseTool from a Runnable.

    View source on GitHub