GenerateAnswerRequest.fromJson constructor

GenerateAnswerRequest.fromJson(
  1. Object? j
)

Implementation

factory GenerateAnswerRequest.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return GenerateAnswerRequest(
    inlinePassages: switch (json['inlinePassages']) {
      null => null,
      Object $1 => GroundingPassages.fromJson($1),
    },
    semanticRetriever: switch (json['semanticRetriever']) {
      null => null,
      Object $1 => SemanticRetrieverConfig.fromJson($1),
    },
    model: switch (json['model']) {
      null => '',
      Object $1 => decodeString($1),
    },
    contents: switch (json['contents']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Content.fromJson(i)],
      _ => throw const FormatException('"contents" is not a list'),
    },
    answerStyle: switch (json['answerStyle']) {
      null => GenerateAnswerRequest_AnswerStyle.$default,
      Object $1 => GenerateAnswerRequest_AnswerStyle.fromJson($1),
    },
    safetySettings: switch (json['safetySettings']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) SafetySetting.fromJson(i)],
      _ => throw const FormatException('"safetySettings" is not a list'),
    },
    temperature: switch (json['temperature']) {
      null => null,
      Object $1 => decodeDouble($1),
    },
  );
}