BatchEmbedTextRequest.fromJson constructor

BatchEmbedTextRequest.fromJson(
  1. Object? j
)

Implementation

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