Schema to represent a basic prompt for an LLM.
class PromptTemplateBaseStringPromptTemplate<RunInput, PartialVariableName>Internal method that handles batching and configuration for a runnable
Return the string type key uniquely identifying this class of prompt template.
Default streaming implementation.
Helper method to transform an Iterator of Input values into an Iterator of
Assigns new fields to the dict output of this runnable. Returns a new runnable.
Convert a runnable to a tool. Return a new instance of RunnableToolLike
Default implementation of batch, which calls invoke N times.
Format the prompt given the input values.
Formats the prompt given the input values and returns a formatted
Invokes the prompt template with the given input and options.
Merges partial variables and user variables.
Pick keys from the dict output of this runnable. Returns a new runnable.
Create a new runnable sequence that runs each individual runnable in series,
Stream output in chunks.
Generate a stream of events emitted by the internal steps of the runnable.
Stream all output from a runnable, as reported to the callback system.
Default implementation of transform, which buffers input and then calls stream.
Bind config to a Runnable, returning a new Runnable.
Create a new runnable from the current one that will try invoking
Bind lifecycle listeners to a Runnable, returning a new Runnable.
Add retry logic to an existing runnable.
The name of the serializable. Override to provide an alias or
A list of variable names the prompt template expects
A path to the module that contains the class, eg. ["langchain", "llms"]
Metadata to be used for tracing.
How to parse the output of calling an LLM on this formatted prompt
Partial variables
Tags to be used for tracing.
A path to the module that contains the class, eg. ["langchain", "llms"]
Internal method that handles batching and configuration for a runnable
A path to the module that contains the class, eg. ["langchain", "llms"]
import { PromptTemplate } from "langchain/prompts";
const prompt = new PromptTemplate({
inputVariables: ["foo"],
template: "Say {foo}",
});Additional fields which should be included inside the message content array if using a complex message content.
A list of variable names the prompt template expects
A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.
How to parse the output of calling an LLM on this formatted prompt
Partial variables
The prompt template
The format of the prompt template. Options are "f-string" and "mustache"
Whether or not to try validating the template on initialization
Default streaming implementation.