TypedModel class
A typed facade over Model.
Wraps the raw Map<String, dynamic>-based API with typed classes:
GenerateTextOptions in, GenerateTextResult out, StreamParts out of
streamText. Construct with a Model (e.g. Model.openai(...)); call
close to release the native handle.
Example:
final model = Model.openai(apiKey, 'gpt-4o', baseUrl: baseUrl);
final typed = TypedModel(model);
try {
final result = typed.generateText('Hello', GenerateTextOptions(temperature: 0.7));
print(result.text);
} finally {
typed.close();
}
Constructors
- TypedModel(Model _raw)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Release the native handle. Delegates to the wrapped Model; safe to call multiple times.
-
generateText(
String prompt, [GenerateTextOptions? options]) → GenerateTextResult -
Generate text from a string
prompt. -
generateTextMessages(
List< ModelMessage> messages, [GenerateTextOptions? options]) → GenerateTextResult - Generate text from a list of typed ModelMessages (multi-turn).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
streamText(
Object prompt, [GenerateTextOptions? options]) → Stream< StreamPart> - Stream text, yielding typed StreamParts.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited