Whether to cache the response.
Whether to print out response text.
Callbacks to add to the run trace.
Tags to add to the run trace.
Metadata to add to the run trace.
Optional encoder to use for counting tokens.
Get the input type for this Runnable.
The name of the Runnable. Used for debugging and tracing.
Input type.
Output Type.
The type of input this Runnable accepts specified as a Pydantic model.
Output schema.
List configurable fields for this Runnable.
Get the name of the Runnable.
Get a Pydantic model that can be used to validate input to the Runnable.
Get a JSON schema that represents the input to the Runnable.
Get a Pydantic model that can be used to validate output to the Runnable.
Simple interface for implementing a custom LLM.
You should subclass this class and implement the following:
_call method: Run the LLM on the given prompt and input (used by invoke)._identifying_params property: Return a dictionary of the identifying parameters
This is critical for caching and tracing purposes. Identifying parameters
is a dict that identifies the LLM.
It should mostly include a model_name.Optional: Override the following methods to provide more optimizations:
_acall: Provide a native async version of the _call method.
If not provided, will delegate to the synchronous version using
run_in_executor. (Used by ainvoke)._stream: Stream the LLM on the given prompt and input.
stream will use _stream if provided, otherwise it
use _call and output will arrive in one chunk._astream: Override to provide a native async version of the _stream method.
astream will use _astream if provided, otherwise it will implement
a fallback behavior that will use _stream if _stream is implemented,
and use _acall if _stream is not implemented.Return the ordered IDs of the tokens in a text.
Get a JSON schema that represents the output of the Runnable.