GenerateContentRequest.fromJson constructor
GenerateContentRequest.fromJson(
- Object? j
Implementation
factory GenerateContentRequest.fromJson(Object? j) {
final json = j as Map<String, Object?>;
return GenerateContentRequest(
model: switch (json['model']) {
null => '',
Object $1 => decodeString($1),
},
systemInstruction: switch (json['systemInstruction']) {
null => null,
Object $1 => Content.fromJson($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'),
},
tools: switch (json['tools']) {
null => [],
List<Object?> $1 => [for (final i in $1) Tool.fromJson(i)],
_ => throw const FormatException('"tools" is not a list'),
},
toolConfig: switch (json['toolConfig']) {
null => null,
Object $1 => ToolConfig.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'),
},
generationConfig: switch (json['generationConfig']) {
null => null,
Object $1 => GenerationConfig.fromJson($1),
},
cachedContent: switch (json['cachedContent']) {
null => null,
Object $1 => decodeString($1),
},
);
}