MockEmbeddingModelV2<VALUE> class

A controllable mock embedding model for testing.

Mirrors MockEmbeddingModelV1 from the JS AI SDK v6 ai/test sub-path.

final model = MockEmbeddingModelV2(
  embedding: [0.1, 0.2, 0.3],
);
final result = await embed(model: model, value: 'hello');
expect(result.embedding, [0.1, 0.2, 0.3]);

Constructors

MockEmbeddingModelV2({required List<double> embedding, EmbeddingModelV2Usage? usage, Object? doEmbedError, String provider = 'mock', String modelId = 'mock-embedding-model'})

Properties

doEmbedError → Object?
If set, doEmbed throws this error instead of returning embeddings.
final
embedCalls → List<EmbeddingModelV2CallOptions<VALUE>>
All call options passed to doEmbed in the order they were called.
final
embedding → List<double>
The embedding vector to return for every input value.
final
hashCode → int
The hash code for this object.
no setterinherited
maxEmbeddingsPerCall → int?
Maximum values per request, or null when no limit is declared.
no setter
modelId → String
final
provider → String
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
specificationVersion → String
no setter
supportsParallelCalls → bool
Whether independent requests may run concurrently.
no setter
usage → EmbeddingModelV2Usage?
Token usage to report.
final

Methods

doEmbed(EmbeddingModelV2CallOptions<VALUE> options) → Future<EmbeddingModelV2GenerateResult<VALUE>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited