BaseLanguageModel<Input extends Object, Options extends LanguageModelOptions, Output extends LanguageModelResult<Object> > class
abstract
Base class for all language models.
There are two different sub-types of Language Models:
- LLMs: these wrap APIs which take text in and return text.
- ChatModels: these wrap models which take chat messages in and return a chat message.
- Inheritance
-
- Object
- Runnable<
PromptValue, Options, Output> - BaseLangChain<
PromptValue, Options, Output> - BaseLanguageModel
- Implementers
Constructors
- BaseLanguageModel({required Options defaultOptions})
-
Base class for all language models.
const
Properties
- defaultOptions → Options
-
The default options to use when invoking the Runnable.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- modelType → String
-
Return type of language model.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
batch(
List< PromptValue> inputs, {List<Options> ? options}) → Future<List< Output> > -
Batches the invocation of the Runnable on the given
inputs
.inherited -
bind(
Options options) → RunnableBinding< PromptValue, Options, Output> -
Binds the Runnable to the given
options
.inherited -
close(
) → void -
Cleans up any resources associated with it the Runnable.
inherited
-
countTokens(
PromptValue promptValue, {Options? options}) → Future< int> - Returns the number of tokens resulting from tokenize the given prompt.
-
getCompatibleOptions(
RunnableOptions? options) → Options? -
Returns the given
options
if they are compatible with the Runnable, otherwise returnsnull
.inherited -
invoke(
PromptValue input, {Options? options}) → Future< Output> -
Invokes the Runnable on the given
input
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pipe<
NewRunOutput extends Object?, NewCallOptions extends RunnableOptions> (Runnable< Output, NewCallOptions, NewRunOutput> next) → RunnableSequence<PromptValue, NewRunOutput> -
Pipes the output of this Runnable into another Runnable using a
RunnableSequence.
inherited
-
stream(
PromptValue input, {Options? options}) → Stream< Output> -
Streams the output of invoking the Runnable on the given
input
.inherited -
streamFromInputStream(
Stream< PromptValue> inputStream, {Options? options}) → Stream<Output> -
Streams the output of invoking the Runnable on the given
inputStream
.inherited -
tokenize(
PromptValue promptValue, {Options? options}) → Future< List< int> > - Tokenizes the given prompt using the encoding used by the language model.
-
toString(
) → String -
A string representation of this object.
override
-
withFallbacks(
List< Runnable< fallbacks) → RunnableWithFallback<PromptValue, RunnableOptions, Output> >PromptValue, Output> -
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<PromptValue, Output> -
Adds retry logic to an existing runnable.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited