BatchEmbedTextResponse.fromJson constructor

BatchEmbedTextResponse.fromJson(
  1. Object? j
)

Implementation

factory BatchEmbedTextResponse.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return BatchEmbedTextResponse(
    embeddings: switch (json['embeddings']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Embedding.fromJson(i)],
      _ => throw const FormatException('"embeddings" is not a list'),
    },
  );
}