embedAll method

Future<List<List<double>>> embedAll(
  1. List<EmbeddingInput> inputs, {
  2. required TaskType taskType,
  3. CancelToken? cancelToken,
})

The vectors for inputs, in input order.

The first failure fails the call. cancelToken stops sending and fails the call with EmbeddingCancelledException; partial results are discarded. Text and media alike.

The models core returns also validate every input before the first is sent, and keep at most two requests of the call outstanding; requests already outstanding when the call fails or is cancelled finish and are dropped. This default body — for fakes — embeds one input at a time.

Implementation

Future<List<List<double>>> embedAll(
  List<EmbeddingInput> inputs, {
  required TaskType taskType,
  CancelToken? cancelToken,
}) async {
  final out = <List<double>>[];
  for (final input in inputs) {
    if (cancelToken?.isCancelled ?? false) {
      throw const EmbeddingCancelledException();
    }
    out.add(await embed(input, taskType: taskType));
  }
  return out;
}