embedMany<CustomOptions> method
Future<List<Embedding> >
embedMany<CustomOptions>({
- required EmbedderRef<
CustomOptions> embedder, - required List<
DocumentData> documents, - CustomOptions? options,
Embeds multiple documents using the specified embedder.
Implementation
Future<List<Embedding>> embedMany<CustomOptions>({
required EmbedderRef<CustomOptions> embedder,
required List<DocumentData> documents,
CustomOptions? options,
}) async {
final action = await registry.lookupAction(.embedder, embedder.name);
if (action == null) {
throw GenkitException(
'Embedder ${embedder.name} not found',
status: StatusCodes.NOT_FOUND,
);
}
final resolvedOptions = options is Map
? options as Map<String, dynamic>
: (options as dynamic)?.toJson() as Map<String, dynamic>?;
final req = EmbedRequest(input: documents, options: resolvedOptions);
final response = await action(req) as EmbedResponse;
return response.embeddings;
}