Base class for prompt templates.
Create a message with a link to the LangChain troubleshooting guide.
Return a dict representation of an object.
Ensure that a config is a dict with all keys present.
Create a Pydantic model with the given field definitions.
Do not use outside of langchain packages. This API is subject to change at any time.
Format a document into a string based on a prompt template.
First, this pulls information from the document from two sources:
page_content: This takes the information from the document.page_content and
assigns it to a variable named page_content.metadata: This takes information from document.metadata and assigns it to
variables of the same name.Those variables are then passed into the prompt to produce a formatted string.
Async format a document into a string based on a prompt template.
First, this pulls information from the document from two sources:
page_content: This takes the information from the document.page_content and
assigns it to a variable named page_content.metadata: This takes information from document.metadata and assigns it to
variables of the same name.Those variables are then passed into the prompt to produce a formatted string.
Error codes.
Base class to parse the output of an LLM call.
Output parsers help structure language model responses.
Chat prompt value which explicitly lists out the message types it accepts.
For use in external schemas.
Base abstract class for inputs to any language model.
PromptValues can be converted to both LLM (pure text-generation) inputs and
chat model inputs.
String prompt value.
Configuration for a Runnable.
Custom values
The TypedDict has total=False set intentionally to:
merge_configsvar_child_runnable_config (a ContextVar that automatically passes
config down the call stack without explicit parameter passing), where
configs are merged rather than replaced# Parent sets tags
chain.invoke(input, config={"tags": ["parent"]})
# Child automatically inherits and can add:
# ensure_config({"tags": ["child"]}) -> {"tags": ["parent", "child"]}Runnable that can be serialized to JSON.
Class for storing a piece of text and associated metadata.
Document is for retrieval workflows, not chat I/O. For sending text
to an LLM in a conversation, use message types from langchain.messages.
Base class for all prompt templates, returning a prompt.