Base class for chat prompt templates.
It exposes two methods:
- format: returns a String prompt given a set of input values.
- formatPrompt: returns a PromptValue given a set of input values.
- formatMessages: returns a list of ChatMessage given a set of input values.
- Inheritance
-
- Object
- Runnable<
InputValues, BaseLangChainOptions, PromptValue> - BasePromptTemplate
- BaseChatPromptTemplate
- Implementers
- Annotations
-
- @immutable
Constructors
-
BaseChatPromptTemplate({required Set<
String> inputVariables, PartialValues? partialVariables}) -
Base class for chat prompt templates.
const
Properties
- defaultOptions → BaseLangChainOptions
-
The default options to use when invoking the Runnable.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputVariables
→ Set<
String> -
A set of the names of the variables the prompt template expects.
finalinherited
- partialVariables → PartialValues?
-
Partial variables.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
The type of the prompt template.
no setterinherited
Methods
-
batch(
List< InputValues> inputs, {List<BaseLangChainOptions> ? options}) → Future<List< PromptValue> > -
Batches the invocation of the Runnable on the given
inputs
.inherited -
bind(
BaseLangChainOptions options) → RunnableBinding< InputValues, BaseLangChainOptions, PromptValue> -
Binds the Runnable to the given
options
.inherited -
close(
) → void -
Cleans up any resources associated with it the Runnable.
inherited
-
copyWith(
{Set< String> ? inputVariables, Map<String, dynamic> ? partialVariables}) → BasePromptTemplate -
Copy the prompt template with the given parameters.
inherited
-
format(
InputValues values) → String -
Format the prompt given the input values and return a formatted string.
override
-
formatMessages(
InputValues values) → List< ChatMessage> - Format input values into a list of messages.
-
formatPrompt(
InputValues values) → PromptValue -
Format the prompt given the input values and return a formatted prompt
value.
override
-
getCompatibleOptions(
RunnableOptions? options) → BaseLangChainOptions? -
Returns the given
options
if they are compatible with the Runnable, otherwise returnsnull
.inherited -
invoke(
InputValues input, {BaseLangChainOptions? options}) → Future< PromptValue> -
Format the prompt given the input values and return a formatted prompt
value.
inherited
-
mergePartialAndUserVariables(
Map< String, dynamic> userVariables) → Map<String, Object> -
Merge the partial variables with the user variables.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
partial(
PartialValues values) → BasePromptTemplate -
Return a partial of the prompt template.
inherited
-
pipe<
NewRunOutput extends Object?, NewCallOptions extends RunnableOptions> (Runnable< PromptValue, NewCallOptions, NewRunOutput> next) → RunnableSequence<InputValues, NewRunOutput> -
Pipes the output of this Runnable into another Runnable using a
RunnableSequence.
inherited
-
stream(
InputValues input, {BaseLangChainOptions? options}) → Stream< PromptValue> -
Streams the output of invoking the Runnable on the given
input
.inherited -
streamFromInputStream(
Stream< InputValues> inputStream, {BaseLangChainOptions? options}) → Stream<PromptValue> -
Streams the output of invoking the Runnable on the given
inputStream
.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
validateTemplate(
) → void -
Validate the integrity of the prompt template, checking that all the
variables are present and that the right format is used.
inherited
-
withFallbacks(
List< Runnable< fallbacks) → RunnableWithFallback<InputValues, RunnableOptions, PromptValue> >InputValues, PromptValue> -
Adds fallback runnables to be invoked if the primary runnable fails.
inherited
-
withRetry(
{int maxRetries = 3, FutureOr< bool> retryIf(Object e)?, List<Duration?> ? delayDurations, bool addJitter = false}) → RunnableRetry<InputValues, PromptValue> -
Adds retry logic to an existing runnable.
inherited
Operators
-
operator ==(
covariant BasePromptTemplate other) → bool -
The equality operator.
inherited