// GENERATED by tools/gen — DO NOT EDIT.
///|
fn[T : @json.FromJson] required_field(
obj : Map[String, Json],
key : String,
path : @json.JsonPath,
) -> T raise @json.JsonDecodeError {
let field_path = path.add_key(key)
match obj.get(key) {
Option::None =>
raise @json.JsonDecodeError::JsonDecodeError(
(field_path, "required だが欠落: " + field_path.to_string()),
)
Option::Some(value) => @json.from_json(value, path=field_path)
}
}
///|
fn json_string_int64_to_json(value : Int64) -> Json {
Json::string(value.to_string())
}
///|
fn parse_plain_string_int64(text : String) -> Int64? {
if text.length() == 0 {
return Option::None
}
let negative = text[0] == '-'
let digits_start = if negative { 1 } else { 0 }
if digits_start == text.length() {
return Option::None
}
for index in digits_start.. '9' {
return Option::None
}
}
let mut significant_start = digits_start
while significant_start < text.length() && text[significant_start] == '0' {
significant_start += 1
}
if significant_start == text.length() {
return Option::Some(0L)
}
let significant_length = text.length() - significant_start
let limit = if negative {
"9223372036854775808"
} else {
"9223372036854775807"
}
if significant_length > limit.length() {
return Option::None
}
if significant_length == limit.length() {
for offset in 0.. boundary {
return Option::None
}
if digit < boundary {
break
}
}
}
let mut result = 0L
for index in significant_start.. Int64 raise @json.JsonDecodeError {
guard value is @json.Json::String(text) else {
raise @json.JsonDecodeError::JsonDecodeError(
(path, "expected JSON string for string-encoded Int64"),
)
}
match parse_plain_string_int64(text) {
Option::Some(value) => value
Option::None =>
raise @json.JsonDecodeError::JsonDecodeError(
(path, "invalid or out-of-range string-encoded Int64"),
)
}
}
///|
fn[T] decode_optional_custom(
obj : Map[String, Json],
key : String,
path : @json.JsonPath,
decode : (Json, @json.JsonPath) -> T raise @json.JsonDecodeError,
) -> T? raise @json.JsonDecodeError {
match obj.get(key) {
Option::None | Option::Some(@json.Json::Null) => Option::None
Option::Some(value) => Option::Some(decode(value, path.add_key(key)))
}
}
///|
fn[T : ToJson] json_map_to_json(value : Map[String, T]) -> Json {
let result : Map[String, Json] = Map([])
for key, item in value {
result[key] = @json.Json::Json(item)
}
Json::object(result)
}
///|
fn[T : @json.FromJson] decode_json_map(
value : Json,
path : @json.JsonPath,
) -> Map[String, T] raise @json.JsonDecodeError {
let obj = @sdkjson.expect_object(value, path)
let result : Map[String, T] = Map([])
for key, item in obj {
result[key] = @json.from_json(item, path=path.add_key(key))
}
result
}
///|
fn[T : @json.FromJson] decode_optional_json_map(
obj : Map[String, Json],
key : String,
path : @json.JsonPath,
) -> Map[String, T]? raise @json.JsonDecodeError {
match obj.get(key) {
Option::None | Option::Some(@json.Json::Null) => Option::None
Option::Some(value) =>
Option::Some(decode_json_map(value, path.add_key(key)))
}
}
///|
///
/// Optional. The MIME type of the text output. Enum values: MIME_TYPE_UNSPECIFIED: Default value. This value is unused.; APPLICATION_JSON: JSON output format.; TEXT_PLAIN: Plain text output format.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum TextResponseFormatMimeType {
MIMETYPEUNSPECIFIED
APPLICATIONJSON
TEXTPLAIN
Custom(String)
}
///|
pub extend TextResponseFormatMimeType with Eq::{equal, not_equal}
///|
pub extend TextResponseFormatMimeType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend TextResponseFormatMimeType with ToJson::{to_json}
///|
pub impl ToJson for TextResponseFormatMimeType with fn to_json(self) {
let raw = match self {
TextResponseFormatMimeType::MIMETYPEUNSPECIFIED => "MIME_TYPE_UNSPECIFIED"
TextResponseFormatMimeType::APPLICATIONJSON => "APPLICATION_JSON"
TextResponseFormatMimeType::TEXTPLAIN => "TEXT_PLAIN"
TextResponseFormatMimeType::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend TextResponseFormatMimeType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for TextResponseFormatMimeType with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MIME_TYPE_UNSPECIFIED" =>
Option::Some(TextResponseFormatMimeType::MIMETYPEUNSPECIFIED)
"APPLICATION_JSON" =>
Option::Some(TextResponseFormatMimeType::APPLICATIONJSON)
"TEXT_PLAIN" => Option::Some(TextResponseFormatMimeType::TEXTPLAIN)
_ => Option::None
}
},
raw => TextResponseFormatMimeType::Custom(raw),
)
}
///|
///
/// Configuration for text output format.
#derive(Eq, @debug.Debug)
pub(all) struct TextResponseFormat {
schema : Json?
mime_type : TextResponseFormatMimeType?
}
///|
pub extend TextResponseFormat with Eq::{equal, not_equal}
///|
pub extend TextResponseFormat with @debug.Debug::{to_repr}
///|
///
/// Creates a TextResponseFormat with omitted optional fields absent.
pub fn TextResponseFormat::new(
schema? : Json,
mime_type? : TextResponseFormatMimeType,
) -> TextResponseFormat {
{ schema, mime_type, }
}
///|
///
/// Encodes this value as JSON.
pub extend TextResponseFormat with ToJson::{to_json}
///|
pub impl ToJson for TextResponseFormat with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("schema", self.schema)
.opt("mimeType", self.mime_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend TextResponseFormat with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for TextResponseFormat with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
schema: @sdkjson.opt_field(obj, "schema", path),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
}
}
///|
///
/// Optional. The delivery mode for the image output. Enum values: DELIVERY_UNSPECIFIED: Default value. This value is unused.; INLINE: Image data is returned inline in the response.; URI: Image data is returned as a URI.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ImageResponseFormatDelivery {
DELIVERYUNSPECIFIED
INLINE
URI
Custom(String)
}
///|
pub extend ImageResponseFormatDelivery with Eq::{equal, not_equal}
///|
pub extend ImageResponseFormatDelivery with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ImageResponseFormatDelivery with ToJson::{to_json}
///|
pub impl ToJson for ImageResponseFormatDelivery with fn to_json(self) {
let raw = match self {
ImageResponseFormatDelivery::DELIVERYUNSPECIFIED => "DELIVERY_UNSPECIFIED"
ImageResponseFormatDelivery::INLINE => "INLINE"
ImageResponseFormatDelivery::URI => "URI"
ImageResponseFormatDelivery::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ImageResponseFormatDelivery with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageResponseFormatDelivery with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"DELIVERY_UNSPECIFIED" =>
Option::Some(ImageResponseFormatDelivery::DELIVERYUNSPECIFIED)
"INLINE" => Option::Some(ImageResponseFormatDelivery::INLINE)
"URI" => Option::Some(ImageResponseFormatDelivery::URI)
_ => Option::None
}
},
raw => ImageResponseFormatDelivery::Custom(raw),
)
}
///|
///
/// Optional. The aspect ratio for the image output. Enum values: ASPECT_RATIO_UNSPECIFIED: Default value. This value is unused.; ASPECT_RATIO_ONE_BY_ONE: 1:1 aspect ratio.; ASPECT_RATIO_TWO_BY_THREE: 2:3 aspect ratio.; ASPECT_RATIO_THREE_BY_TWO: 3:2 aspect ratio.; ASPECT_RATIO_THREE_BY_FOUR: 3:4 aspect ratio.; ASPECT_RATIO_FOUR_BY_THREE: 4:3 aspect ratio.; ASPECT_RATIO_FOUR_BY_FIVE: 4:5 aspect ratio.; ASPECT_RATIO_FIVE_BY_FOUR: 5:4 aspect ratio.; ASPECT_RATIO_NINE_BY_SIXTEEN: 9:16 aspect ratio.; ASPECT_RATIO_SIXTEEN_BY_NINE: 16:9 aspect ratio.; ASPECT_RATIO_TWENTY_ONE_BY_NINE: 21:9 aspect ratio.; ASPECT_RATIO_ONE_BY_EIGHT: 1:8 aspect ratio.; ASPECT_RATIO_EIGHT_BY_ONE: 8:1 aspect ratio.; ASPECT_RATIO_ONE_BY_FOUR: 1:4 aspect ratio.; ASPECT_RATIO_FOUR_BY_ONE: 4:1 aspect ratio.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ImageResponseFormatAspectRatio {
ASPECTRATIOUNSPECIFIED
ASPECTRATIOONEBYONE
ASPECTRATIOTWOBYTHREE
ASPECTRATIOTHREEBYTWO
ASPECTRATIOTHREEBYFOUR
ASPECTRATIOFOURBYTHREE
ASPECTRATIOFOURBYFIVE
ASPECTRATIOFIVEBYFOUR
ASPECTRATIONINEBYSIXTEEN
ASPECTRATIOSIXTEENBYNINE
ASPECTRATIOTWENTYONEBYNINE
ASPECTRATIOONEBYEIGHT
ASPECTRATIOEIGHTBYONE
ASPECTRATIOONEBYFOUR
ASPECTRATIOFOURBYONE
Custom(String)
}
///|
pub extend ImageResponseFormatAspectRatio with Eq::{equal, not_equal}
///|
pub extend ImageResponseFormatAspectRatio with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ImageResponseFormatAspectRatio with ToJson::{to_json}
///|
pub impl ToJson for ImageResponseFormatAspectRatio with fn to_json(self) {
let raw = match self {
ImageResponseFormatAspectRatio::ASPECTRATIOUNSPECIFIED =>
"ASPECT_RATIO_UNSPECIFIED"
ImageResponseFormatAspectRatio::ASPECTRATIOONEBYONE =>
"ASPECT_RATIO_ONE_BY_ONE"
ImageResponseFormatAspectRatio::ASPECTRATIOTWOBYTHREE =>
"ASPECT_RATIO_TWO_BY_THREE"
ImageResponseFormatAspectRatio::ASPECTRATIOTHREEBYTWO =>
"ASPECT_RATIO_THREE_BY_TWO"
ImageResponseFormatAspectRatio::ASPECTRATIOTHREEBYFOUR =>
"ASPECT_RATIO_THREE_BY_FOUR"
ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYTHREE =>
"ASPECT_RATIO_FOUR_BY_THREE"
ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYFIVE =>
"ASPECT_RATIO_FOUR_BY_FIVE"
ImageResponseFormatAspectRatio::ASPECTRATIOFIVEBYFOUR =>
"ASPECT_RATIO_FIVE_BY_FOUR"
ImageResponseFormatAspectRatio::ASPECTRATIONINEBYSIXTEEN =>
"ASPECT_RATIO_NINE_BY_SIXTEEN"
ImageResponseFormatAspectRatio::ASPECTRATIOSIXTEENBYNINE =>
"ASPECT_RATIO_SIXTEEN_BY_NINE"
ImageResponseFormatAspectRatio::ASPECTRATIOTWENTYONEBYNINE =>
"ASPECT_RATIO_TWENTY_ONE_BY_NINE"
ImageResponseFormatAspectRatio::ASPECTRATIOONEBYEIGHT =>
"ASPECT_RATIO_ONE_BY_EIGHT"
ImageResponseFormatAspectRatio::ASPECTRATIOEIGHTBYONE =>
"ASPECT_RATIO_EIGHT_BY_ONE"
ImageResponseFormatAspectRatio::ASPECTRATIOONEBYFOUR =>
"ASPECT_RATIO_ONE_BY_FOUR"
ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYONE =>
"ASPECT_RATIO_FOUR_BY_ONE"
ImageResponseFormatAspectRatio::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ImageResponseFormatAspectRatio with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageResponseFormatAspectRatio with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"ASPECT_RATIO_UNSPECIFIED" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOUNSPECIFIED)
"ASPECT_RATIO_ONE_BY_ONE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOONEBYONE)
"ASPECT_RATIO_TWO_BY_THREE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOTWOBYTHREE)
"ASPECT_RATIO_THREE_BY_TWO" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOTHREEBYTWO)
"ASPECT_RATIO_THREE_BY_FOUR" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOTHREEBYFOUR)
"ASPECT_RATIO_FOUR_BY_THREE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYTHREE)
"ASPECT_RATIO_FOUR_BY_FIVE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYFIVE)
"ASPECT_RATIO_FIVE_BY_FOUR" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOFIVEBYFOUR)
"ASPECT_RATIO_NINE_BY_SIXTEEN" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIONINEBYSIXTEEN)
"ASPECT_RATIO_SIXTEEN_BY_NINE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOSIXTEENBYNINE)
"ASPECT_RATIO_TWENTY_ONE_BY_NINE" =>
Option::Some(
ImageResponseFormatAspectRatio::ASPECTRATIOTWENTYONEBYNINE,
)
"ASPECT_RATIO_ONE_BY_EIGHT" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOONEBYEIGHT)
"ASPECT_RATIO_EIGHT_BY_ONE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOEIGHTBYONE)
"ASPECT_RATIO_ONE_BY_FOUR" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOONEBYFOUR)
"ASPECT_RATIO_FOUR_BY_ONE" =>
Option::Some(ImageResponseFormatAspectRatio::ASPECTRATIOFOURBYONE)
_ => Option::None
}
},
raw => ImageResponseFormatAspectRatio::Custom(raw),
)
}
///|
///
/// Optional. The size of the image output. Enum values: IMAGE_SIZE_UNSPECIFIED: Default value. This value is unused.; IMAGE_SIZE_FIVE_TWELVE: 512px image size.; IMAGE_SIZE_ONE_K: 1K image size.; IMAGE_SIZE_TWO_K: 2K image size.; IMAGE_SIZE_FOUR_K: 4K image size.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ImageResponseFormatImageSize {
IMAGESIZEUNSPECIFIED
IMAGESIZEFIVETWELVE
IMAGESIZEONEK
IMAGESIZETWOK
IMAGESIZEFOURK
Custom(String)
}
///|
pub extend ImageResponseFormatImageSize with Eq::{equal, not_equal}
///|
pub extend ImageResponseFormatImageSize with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ImageResponseFormatImageSize with ToJson::{to_json}
///|
pub impl ToJson for ImageResponseFormatImageSize with fn to_json(self) {
let raw = match self {
ImageResponseFormatImageSize::IMAGESIZEUNSPECIFIED =>
"IMAGE_SIZE_UNSPECIFIED"
ImageResponseFormatImageSize::IMAGESIZEFIVETWELVE =>
"IMAGE_SIZE_FIVE_TWELVE"
ImageResponseFormatImageSize::IMAGESIZEONEK => "IMAGE_SIZE_ONE_K"
ImageResponseFormatImageSize::IMAGESIZETWOK => "IMAGE_SIZE_TWO_K"
ImageResponseFormatImageSize::IMAGESIZEFOURK => "IMAGE_SIZE_FOUR_K"
ImageResponseFormatImageSize::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ImageResponseFormatImageSize with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageResponseFormatImageSize with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"IMAGE_SIZE_UNSPECIFIED" =>
Option::Some(ImageResponseFormatImageSize::IMAGESIZEUNSPECIFIED)
"IMAGE_SIZE_FIVE_TWELVE" =>
Option::Some(ImageResponseFormatImageSize::IMAGESIZEFIVETWELVE)
"IMAGE_SIZE_ONE_K" =>
Option::Some(ImageResponseFormatImageSize::IMAGESIZEONEK)
"IMAGE_SIZE_TWO_K" =>
Option::Some(ImageResponseFormatImageSize::IMAGESIZETWOK)
"IMAGE_SIZE_FOUR_K" =>
Option::Some(ImageResponseFormatImageSize::IMAGESIZEFOURK)
_ => Option::None
}
},
raw => ImageResponseFormatImageSize::Custom(raw),
)
}
///|
///
/// Optional. The MIME type of the image output. Enum values: MIME_TYPE_UNSPECIFIED: Default value. This value is unused.; IMAGE_JPEG: JPEG image format.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ImageResponseFormatMimeType {
MIMETYPEUNSPECIFIED
IMAGEJPEG
Custom(String)
}
///|
pub extend ImageResponseFormatMimeType with Eq::{equal, not_equal}
///|
pub extend ImageResponseFormatMimeType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ImageResponseFormatMimeType with ToJson::{to_json}
///|
pub impl ToJson for ImageResponseFormatMimeType with fn to_json(self) {
let raw = match self {
ImageResponseFormatMimeType::MIMETYPEUNSPECIFIED => "MIME_TYPE_UNSPECIFIED"
ImageResponseFormatMimeType::IMAGEJPEG => "IMAGE_JPEG"
ImageResponseFormatMimeType::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ImageResponseFormatMimeType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageResponseFormatMimeType with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MIME_TYPE_UNSPECIFIED" =>
Option::Some(ImageResponseFormatMimeType::MIMETYPEUNSPECIFIED)
"IMAGE_JPEG" => Option::Some(ImageResponseFormatMimeType::IMAGEJPEG)
_ => Option::None
}
},
raw => ImageResponseFormatMimeType::Custom(raw),
)
}
///|
///
/// Configuration for image output format.
#derive(Eq, @debug.Debug)
pub(all) struct ImageResponseFormat {
delivery : ImageResponseFormatDelivery?
aspect_ratio : ImageResponseFormatAspectRatio?
image_size : ImageResponseFormatImageSize?
mime_type : ImageResponseFormatMimeType?
}
///|
pub extend ImageResponseFormat with Eq::{equal, not_equal}
///|
pub extend ImageResponseFormat with @debug.Debug::{to_repr}
///|
///
/// Creates a ImageResponseFormat with omitted optional fields absent.
pub fn ImageResponseFormat::new(
delivery? : ImageResponseFormatDelivery,
aspect_ratio? : ImageResponseFormatAspectRatio,
image_size? : ImageResponseFormatImageSize,
mime_type? : ImageResponseFormatMimeType,
) -> ImageResponseFormat {
{ delivery, aspect_ratio, image_size, mime_type, }
}
///|
///
/// Encodes this value as JSON.
pub extend ImageResponseFormat with ToJson::{to_json}
///|
pub impl ToJson for ImageResponseFormat with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("delivery", self.delivery)
.opt("aspectRatio", self.aspect_ratio)
.opt("imageSize", self.image_size)
.opt("mimeType", self.mime_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ImageResponseFormat with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageResponseFormat with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
delivery: @sdkjson.opt_field(obj, "delivery", path),
aspect_ratio: @sdkjson.opt_field(obj, "aspectRatio", path),
image_size: @sdkjson.opt_field(obj, "imageSize", path),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
}
}
///|
///
/// Optional. The MIME type of the audio output. Enum values: MIME_TYPE_UNSPECIFIED: Default value. This value is unused.; AUDIO_MP3: MP3 audio format.; AUDIO_OGG_OPUS: OGG Opus audio format.; AUDIO_L16: Raw PCM (L16) audio format.; AUDIO_WAV: WAV audio format.; AUDIO_ALAW: A-law audio format.; AUDIO_MULAW: Mu-law audio format.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum AudioResponseFormatMimeType {
MIMETYPEUNSPECIFIED
AUDIOMP3
AUDIOOGGOPUS
AUDIOL16
AUDIOWAV
AUDIOALAW
AUDIOMULAW
Custom(String)
}
///|
pub extend AudioResponseFormatMimeType with Eq::{equal, not_equal}
///|
pub extend AudioResponseFormatMimeType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend AudioResponseFormatMimeType with ToJson::{to_json}
///|
pub impl ToJson for AudioResponseFormatMimeType with fn to_json(self) {
let raw = match self {
AudioResponseFormatMimeType::MIMETYPEUNSPECIFIED => "MIME_TYPE_UNSPECIFIED"
AudioResponseFormatMimeType::AUDIOMP3 => "AUDIO_MP3"
AudioResponseFormatMimeType::AUDIOOGGOPUS => "AUDIO_OGG_OPUS"
AudioResponseFormatMimeType::AUDIOL16 => "AUDIO_L16"
AudioResponseFormatMimeType::AUDIOWAV => "AUDIO_WAV"
AudioResponseFormatMimeType::AUDIOALAW => "AUDIO_ALAW"
AudioResponseFormatMimeType::AUDIOMULAW => "AUDIO_MULAW"
AudioResponseFormatMimeType::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend AudioResponseFormatMimeType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioResponseFormatMimeType with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MIME_TYPE_UNSPECIFIED" =>
Option::Some(AudioResponseFormatMimeType::MIMETYPEUNSPECIFIED)
"AUDIO_MP3" => Option::Some(AudioResponseFormatMimeType::AUDIOMP3)
"AUDIO_OGG_OPUS" =>
Option::Some(AudioResponseFormatMimeType::AUDIOOGGOPUS)
"AUDIO_L16" => Option::Some(AudioResponseFormatMimeType::AUDIOL16)
"AUDIO_WAV" => Option::Some(AudioResponseFormatMimeType::AUDIOWAV)
"AUDIO_ALAW" => Option::Some(AudioResponseFormatMimeType::AUDIOALAW)
"AUDIO_MULAW" => Option::Some(AudioResponseFormatMimeType::AUDIOMULAW)
_ => Option::None
}
},
raw => AudioResponseFormatMimeType::Custom(raw),
)
}
///|
///
/// Optional. The delivery mode for the audio output. Enum values: DELIVERY_UNSPECIFIED: Default value. This value is unused.; INLINE: Audio data is returned inline in the response.; URI: Audio data is returned as a URI.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum AudioResponseFormatDelivery {
DELIVERYUNSPECIFIED
INLINE
URI
Custom(String)
}
///|
pub extend AudioResponseFormatDelivery with Eq::{equal, not_equal}
///|
pub extend AudioResponseFormatDelivery with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend AudioResponseFormatDelivery with ToJson::{to_json}
///|
pub impl ToJson for AudioResponseFormatDelivery with fn to_json(self) {
let raw = match self {
AudioResponseFormatDelivery::DELIVERYUNSPECIFIED => "DELIVERY_UNSPECIFIED"
AudioResponseFormatDelivery::INLINE => "INLINE"
AudioResponseFormatDelivery::URI => "URI"
AudioResponseFormatDelivery::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend AudioResponseFormatDelivery with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioResponseFormatDelivery with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"DELIVERY_UNSPECIFIED" =>
Option::Some(AudioResponseFormatDelivery::DELIVERYUNSPECIFIED)
"INLINE" => Option::Some(AudioResponseFormatDelivery::INLINE)
"URI" => Option::Some(AudioResponseFormatDelivery::URI)
_ => Option::None
}
},
raw => AudioResponseFormatDelivery::Custom(raw),
)
}
///|
///
/// Configuration for audio output format.
#derive(Eq, @debug.Debug)
pub(all) struct AudioResponseFormat {
mime_type : AudioResponseFormatMimeType?
bit_rate : Int32?
sample_rate : Int32?
delivery : AudioResponseFormatDelivery?
}
///|
pub extend AudioResponseFormat with Eq::{equal, not_equal}
///|
pub extend AudioResponseFormat with @debug.Debug::{to_repr}
///|
///
/// Creates a AudioResponseFormat with omitted optional fields absent.
pub fn AudioResponseFormat::new(
mime_type? : AudioResponseFormatMimeType,
bit_rate? : Int32,
sample_rate? : Int32,
delivery? : AudioResponseFormatDelivery,
) -> AudioResponseFormat {
{ mime_type, bit_rate, sample_rate, delivery, }
}
///|
///
/// Encodes this value as JSON.
pub extend AudioResponseFormat with ToJson::{to_json}
///|
pub impl ToJson for AudioResponseFormat with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("mimeType", self.mime_type)
.opt("bitRate", self.bit_rate)
.opt("sampleRate", self.sample_rate)
.opt("delivery", self.delivery)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend AudioResponseFormat with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioResponseFormat with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
bit_rate: @sdkjson.opt_field(obj, "bitRate", path),
sample_rate: @sdkjson.opt_field(obj, "sampleRate", path),
delivery: @sdkjson.opt_field(obj, "delivery", path),
}
}
///|
///
/// Configuration for the response output format. This is a flat object where each optional sub-field configures a specific output modality.
#derive(Eq, @debug.Debug)
pub(all) struct ResponseFormatConfig {
text : TextResponseFormat?
image : ImageResponseFormat?
audio : AudioResponseFormat?
}
///|
pub extend ResponseFormatConfig with Eq::{equal, not_equal}
///|
pub extend ResponseFormatConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a ResponseFormatConfig with omitted optional fields absent.
pub fn ResponseFormatConfig::new(
text? : TextResponseFormat,
image? : ImageResponseFormat,
audio? : AudioResponseFormat,
) -> ResponseFormatConfig {
{ text, image, audio, }
}
///|
///
/// Encodes this value as JSON.
pub extend ResponseFormatConfig with ToJson::{to_json}
///|
pub impl ToJson for ResponseFormatConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("text", self.text)
.opt("image", self.image)
.opt("audio", self.audio)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ResponseFormatConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ResponseFormatConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
text: @sdkjson.opt_field(obj, "text", path),
image: @sdkjson.opt_field(obj, "image", path),
audio: @sdkjson.opt_field(obj, "audio", path),
}
}
///|
///
/// Provides hints to the model about possible languages present in the audio.
#derive(Eq, @debug.Debug)
pub(all) struct LanguageHints {
language_codes : Array[String]?
}
///|
pub extend LanguageHints with Eq::{equal, not_equal}
///|
pub extend LanguageHints with @debug.Debug::{to_repr}
///|
///
/// Creates a LanguageHints with omitted optional fields absent.
pub fn LanguageHints::new(language_codes? : Array[String]) -> LanguageHints {
{ language_codes, }
}
///|
///
/// Encodes this value as JSON.
pub extend LanguageHints with ToJson::{to_json}
///|
pub impl ToJson for LanguageHints with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("languageCodes", self.language_codes).build()
}
///|
///
/// Decodes this value from JSON.
pub extend LanguageHints with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for LanguageHints with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ language_codes: @sdkjson.opt_field(obj, "languageCodes", path), }
}
///|
///
/// Optional. Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` transcription. In `SMART` mode, the model performs disfluency removal (eliminating filler words, repetitions, and false starts), light grammatical cleanup, automatic formatting (paragraphs, bullet points, numbered lists), and minor user edits (inline self-corrections). Timestamps and diarization are incompatible with mode `SMART`. Enum values: MODE_UNSPECIFIED: Unspecified transcription mode.; VERBATIM: Verbatim transcription mode.; SMART: Smart transcription mode.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum AudioTranscriptionConfigMode {
MODEUNSPECIFIED
VERBATIM
SMART
Custom(String)
}
///|
pub extend AudioTranscriptionConfigMode with Eq::{equal, not_equal}
///|
pub extend AudioTranscriptionConfigMode with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend AudioTranscriptionConfigMode with ToJson::{to_json}
///|
pub impl ToJson for AudioTranscriptionConfigMode with fn to_json(self) {
let raw = match self {
AudioTranscriptionConfigMode::MODEUNSPECIFIED => "MODE_UNSPECIFIED"
AudioTranscriptionConfigMode::VERBATIM => "VERBATIM"
AudioTranscriptionConfigMode::SMART => "SMART"
AudioTranscriptionConfigMode::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend AudioTranscriptionConfigMode with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioTranscriptionConfigMode with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODE_UNSPECIFIED" =>
Option::Some(AudioTranscriptionConfigMode::MODEUNSPECIFIED)
"VERBATIM" => Option::Some(AudioTranscriptionConfigMode::VERBATIM)
"SMART" => Option::Some(AudioTranscriptionConfigMode::SMART)
_ => Option::None
}
},
raw => AudioTranscriptionConfigMode::Custom(raw),
)
}
///|
///
/// The audio transcription configuration.
#derive(Eq, @debug.Debug)
pub(all) struct AudioTranscriptionConfig {
word_timestamp : Bool?
language_hints : LanguageHints?
language_codes : Array[String]?
adaptation_phrases : Array[String]?
source_text : String?
diarization : Bool?
custom_vocabulary : Array[String]?
language_auto : Json?
mode : AudioTranscriptionConfigMode?
}
///|
pub extend AudioTranscriptionConfig with Eq::{equal, not_equal}
///|
pub extend AudioTranscriptionConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a AudioTranscriptionConfig with omitted optional fields absent.
pub fn AudioTranscriptionConfig::new(
word_timestamp? : Bool,
language_hints? : LanguageHints,
language_codes? : Array[String],
adaptation_phrases? : Array[String],
source_text? : String,
diarization? : Bool,
custom_vocabulary? : Array[String],
language_auto? : Json,
mode? : AudioTranscriptionConfigMode,
) -> AudioTranscriptionConfig {
{
word_timestamp,
language_hints,
language_codes,
adaptation_phrases,
source_text,
diarization,
custom_vocabulary,
language_auto,
mode,
}
}
///|
///
/// Encodes this value as JSON.
pub extend AudioTranscriptionConfig with ToJson::{to_json}
///|
pub impl ToJson for AudioTranscriptionConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("wordTimestamp", self.word_timestamp)
.opt("languageHints", self.language_hints)
.opt("languageCodes", self.language_codes)
.opt("adaptationPhrases", self.adaptation_phrases)
.opt("sourceText", self.source_text)
.opt("diarization", self.diarization)
.opt("customVocabulary", self.custom_vocabulary)
.opt("languageAuto", self.language_auto)
.opt("mode", self.mode)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend AudioTranscriptionConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioTranscriptionConfig with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
word_timestamp: @sdkjson.opt_field(obj, "wordTimestamp", path),
language_hints: @sdkjson.opt_field(obj, "languageHints", path),
language_codes: @sdkjson.opt_field(obj, "languageCodes", path),
adaptation_phrases: @sdkjson.opt_field(obj, "adaptationPhrases", path),
source_text: @sdkjson.opt_field(obj, "sourceText", path),
diarization: @sdkjson.opt_field(obj, "diarization", path),
custom_vocabulary: @sdkjson.opt_field(obj, "customVocabulary", path),
language_auto: @sdkjson.opt_field(obj, "languageAuto", path),
mode: @sdkjson.opt_field(obj, "mode", path),
}
}
///|
///
/// The configuration for the prebuilt speaker to use.
#derive(Eq, @debug.Debug)
pub(all) struct PrebuiltVoiceConfig {
voice_name : String?
}
///|
pub extend PrebuiltVoiceConfig with Eq::{equal, not_equal}
///|
pub extend PrebuiltVoiceConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a PrebuiltVoiceConfig with omitted optional fields absent.
pub fn PrebuiltVoiceConfig::new(voice_name? : String) -> PrebuiltVoiceConfig {
{ voice_name, }
}
///|
///
/// Encodes this value as JSON.
pub extend PrebuiltVoiceConfig with ToJson::{to_json}
///|
pub impl ToJson for PrebuiltVoiceConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("voiceName", self.voice_name).build()
}
///|
///
/// Decodes this value from JSON.
pub extend PrebuiltVoiceConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PrebuiltVoiceConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ voice_name: @sdkjson.opt_field(obj, "voiceName", path), }
}
///|
///
/// The configuration for the voice to use.
#derive(Eq, @debug.Debug)
pub(all) struct VoiceConfig {
prebuilt_voice_config : PrebuiltVoiceConfig?
voice : String?
}
///|
pub extend VoiceConfig with Eq::{equal, not_equal}
///|
pub extend VoiceConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a VoiceConfig with omitted optional fields absent.
pub fn VoiceConfig::new(
prebuilt_voice_config? : PrebuiltVoiceConfig,
voice? : String,
) -> VoiceConfig {
{ prebuilt_voice_config, voice, }
}
///|
///
/// Encodes this value as JSON.
pub extend VoiceConfig with ToJson::{to_json}
///|
pub impl ToJson for VoiceConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("prebuiltVoiceConfig", self.prebuilt_voice_config)
.opt("voice", self.voice)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend VoiceConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for VoiceConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
prebuilt_voice_config: @sdkjson.opt_field(obj, "prebuiltVoiceConfig", path),
voice: @sdkjson.opt_field(obj, "voice", path),
}
}
///|
///
/// The configuration for a single speaker in a multi speaker setup.
#derive(Eq, @debug.Debug)
pub(all) struct SpeakerVoiceConfig {
speaker : String?
voice_config : VoiceConfig?
}
///|
pub extend SpeakerVoiceConfig with Eq::{equal, not_equal}
///|
pub extend SpeakerVoiceConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a SpeakerVoiceConfig with omitted optional fields absent.
pub fn SpeakerVoiceConfig::new(
speaker? : String,
voice_config? : VoiceConfig,
) -> SpeakerVoiceConfig {
{ speaker, voice_config, }
}
///|
///
/// Encodes this value as JSON.
pub extend SpeakerVoiceConfig with ToJson::{to_json}
///|
pub impl ToJson for SpeakerVoiceConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speaker", self.speaker)
.opt("voiceConfig", self.voice_config)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SpeakerVoiceConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpeakerVoiceConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speaker: @sdkjson.opt_field(obj, "speaker", path),
voice_config: @sdkjson.opt_field(obj, "voiceConfig", path),
}
}
///|
///
/// The configuration for the multi-speaker setup.
#derive(Eq, @debug.Debug)
pub(all) struct MultiSpeakerVoiceConfig {
speaker_voice_configs : Array[SpeakerVoiceConfig]?
}
///|
pub extend MultiSpeakerVoiceConfig with Eq::{equal, not_equal}
///|
pub extend MultiSpeakerVoiceConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a MultiSpeakerVoiceConfig with omitted optional fields absent.
pub fn MultiSpeakerVoiceConfig::new(
speaker_voice_configs? : Array[SpeakerVoiceConfig],
) -> MultiSpeakerVoiceConfig {
{ speaker_voice_configs, }
}
///|
///
/// Encodes this value as JSON.
pub extend MultiSpeakerVoiceConfig with ToJson::{to_json}
///|
pub impl ToJson for MultiSpeakerVoiceConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speakerVoiceConfigs", self.speaker_voice_configs)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend MultiSpeakerVoiceConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for MultiSpeakerVoiceConfig with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
speaker_voice_configs: @sdkjson.opt_field(obj, "speakerVoiceConfigs", path),
}
}
///|
///
/// Optional. Controls text normalization before speech synthesis. Enum values: TEXT_NORMALIZATION_UNSPECIFIED: Unspecified text normalization mode. Defaults to `AUTO`.; AUTO: Automatically determines whether to apply text normalization based on the model and speech mode.; ENABLED: Enables text normalization for numbers, currencies, dates, and units.; DISABLED: Disables text normalization for pre-normalized or phonetic inputs.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SpeechConfigTextNormalization {
TEXTNORMALIZATIONUNSPECIFIED
AUTO
ENABLED
DISABLED
Custom(String)
}
///|
pub extend SpeechConfigTextNormalization with Eq::{equal, not_equal}
///|
pub extend SpeechConfigTextNormalization with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SpeechConfigTextNormalization with ToJson::{to_json}
///|
pub impl ToJson for SpeechConfigTextNormalization with fn to_json(self) {
let raw = match self {
SpeechConfigTextNormalization::TEXTNORMALIZATIONUNSPECIFIED =>
"TEXT_NORMALIZATION_UNSPECIFIED"
SpeechConfigTextNormalization::AUTO => "AUTO"
SpeechConfigTextNormalization::ENABLED => "ENABLED"
SpeechConfigTextNormalization::DISABLED => "DISABLED"
SpeechConfigTextNormalization::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SpeechConfigTextNormalization with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpeechConfigTextNormalization with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TEXT_NORMALIZATION_UNSPECIFIED" =>
Option::Some(
SpeechConfigTextNormalization::TEXTNORMALIZATIONUNSPECIFIED,
)
"AUTO" => Option::Some(SpeechConfigTextNormalization::AUTO)
"ENABLED" => Option::Some(SpeechConfigTextNormalization::ENABLED)
"DISABLED" => Option::Some(SpeechConfigTextNormalization::DISABLED)
_ => Option::None
}
},
raw => SpeechConfigTextNormalization::Custom(raw),
)
}
///|
///
/// Config for speech generation and transcription.
#derive(Eq, @debug.Debug)
pub(all) struct SpeechConfig {
multi_speaker_voice_config : MultiSpeakerVoiceConfig?
language_code : String?
text_normalization : SpeechConfigTextNormalization?
voice_config : VoiceConfig?
}
///|
pub extend SpeechConfig with Eq::{equal, not_equal}
///|
pub extend SpeechConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a SpeechConfig with omitted optional fields absent.
pub fn SpeechConfig::new(
multi_speaker_voice_config? : MultiSpeakerVoiceConfig,
language_code? : String,
text_normalization? : SpeechConfigTextNormalization,
voice_config? : VoiceConfig,
) -> SpeechConfig {
{
multi_speaker_voice_config,
language_code,
text_normalization,
voice_config,
}
}
///|
///
/// Encodes this value as JSON.
pub extend SpeechConfig with ToJson::{to_json}
///|
pub impl ToJson for SpeechConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("multiSpeakerVoiceConfig", self.multi_speaker_voice_config)
.opt("languageCode", self.language_code)
.opt("textNormalization", self.text_normalization)
.opt("voiceConfig", self.voice_config)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SpeechConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpeechConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
multi_speaker_voice_config: @sdkjson.opt_field(
obj, "multiSpeakerVoiceConfig", path,
),
language_code: @sdkjson.opt_field(obj, "languageCode", path),
text_normalization: @sdkjson.opt_field(obj, "textNormalization", path),
voice_config: @sdkjson.opt_field(obj, "voiceConfig", path),
}
}
///|
///
/// The modality associated with this token count. Enum values: MODALITY_UNSPECIFIED: Unspecified modality.; TEXT: Plain text.; IMAGE: Image.; VIDEO: Video.; AUDIO: Audio.; DOCUMENT: Document, e.g. PDF.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ModalityTokenCountModality {
MODALITYUNSPECIFIED
TEXT
IMAGE
VIDEO
AUDIO
DOCUMENT
Unknown(String)
}
///|
pub extend ModalityTokenCountModality with Eq::{equal, not_equal}
///|
pub extend ModalityTokenCountModality with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ModalityTokenCountModality with ToJson::{to_json}
///|
pub impl ToJson for ModalityTokenCountModality with fn to_json(self) {
let raw = match self {
ModalityTokenCountModality::MODALITYUNSPECIFIED => "MODALITY_UNSPECIFIED"
ModalityTokenCountModality::TEXT => "TEXT"
ModalityTokenCountModality::IMAGE => "IMAGE"
ModalityTokenCountModality::VIDEO => "VIDEO"
ModalityTokenCountModality::AUDIO => "AUDIO"
ModalityTokenCountModality::DOCUMENT => "DOCUMENT"
ModalityTokenCountModality::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ModalityTokenCountModality with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ModalityTokenCountModality with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODALITY_UNSPECIFIED" =>
Option::Some(ModalityTokenCountModality::MODALITYUNSPECIFIED)
"TEXT" => Option::Some(ModalityTokenCountModality::TEXT)
"IMAGE" => Option::Some(ModalityTokenCountModality::IMAGE)
"VIDEO" => Option::Some(ModalityTokenCountModality::VIDEO)
"AUDIO" => Option::Some(ModalityTokenCountModality::AUDIO)
"DOCUMENT" => Option::Some(ModalityTokenCountModality::DOCUMENT)
_ => Option::None
}
},
raw => ModalityTokenCountModality::Unknown(raw),
)
}
///|
///
/// Represents token counting info for a single modality.
#derive(Eq, @debug.Debug)
pub(all) struct ModalityTokenCount {
modality : ModalityTokenCountModality?
token_count : Int32?
}
///|
pub extend ModalityTokenCount with Eq::{equal, not_equal}
///|
pub extend ModalityTokenCount with @debug.Debug::{to_repr}
///|
///
/// Creates a ModalityTokenCount with omitted optional fields absent.
pub fn ModalityTokenCount::new(
modality? : ModalityTokenCountModality,
token_count? : Int32,
) -> ModalityTokenCount {
{ modality, token_count, }
}
///|
///
/// Encodes this value as JSON.
pub extend ModalityTokenCount with ToJson::{to_json}
///|
pub impl ToJson for ModalityTokenCount with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("modality", self.modality)
.opt("tokenCount", self.token_count)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ModalityTokenCount with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ModalityTokenCount with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
modality: @sdkjson.opt_field(obj, "modality", path),
token_count: @sdkjson.opt_field(obj, "tokenCount", path),
}
}
///|
///
/// Output only. Service tier of the request. Enum values: unspecified: Default service tier, which is standard.; standard: Standard service tier.; flex: Flex service tier.; priority: Priority service tier.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum UsageMetadataServiceTier {
Unspecified
Standard
Flex
Priority
Unknown(String)
}
///|
pub extend UsageMetadataServiceTier with Eq::{equal, not_equal}
///|
pub extend UsageMetadataServiceTier with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend UsageMetadataServiceTier with ToJson::{to_json}
///|
pub impl ToJson for UsageMetadataServiceTier with fn to_json(self) {
let raw = match self {
UsageMetadataServiceTier::Unspecified => "unspecified"
UsageMetadataServiceTier::Standard => "standard"
UsageMetadataServiceTier::Flex => "flex"
UsageMetadataServiceTier::Priority => "priority"
UsageMetadataServiceTier::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend UsageMetadataServiceTier with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for UsageMetadataServiceTier with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"unspecified" => Option::Some(UsageMetadataServiceTier::Unspecified)
"standard" => Option::Some(UsageMetadataServiceTier::Standard)
"flex" => Option::Some(UsageMetadataServiceTier::Flex)
"priority" => Option::Some(UsageMetadataServiceTier::Priority)
_ => Option::None
}
},
raw => UsageMetadataServiceTier::Unknown(raw),
)
}
///|
///
/// Metadata on the generation request's token usage.
#derive(Eq, @debug.Debug)
pub(all) struct UsageMetadata {
prompt_token_count : Int32?
prompt_tokens_details : Array[ModalityTokenCount]?
tool_use_prompt_token_count : Int32?
cached_content_token_count : Int32?
candidates_tokens_details : Array[ModalityTokenCount]?
tool_use_prompt_tokens_details : Array[ModalityTokenCount]?
service_tier : UsageMetadataServiceTier?
thoughts_token_count : Int32?
candidates_token_count : Int32?
cache_tokens_details : Array[ModalityTokenCount]?
total_token_count : Int32?
}
///|
pub extend UsageMetadata with Eq::{equal, not_equal}
///|
pub extend UsageMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a UsageMetadata with omitted optional fields absent.
pub fn UsageMetadata::new(
prompt_token_count? : Int32,
prompt_tokens_details? : Array[ModalityTokenCount],
tool_use_prompt_token_count? : Int32,
cached_content_token_count? : Int32,
candidates_tokens_details? : Array[ModalityTokenCount],
tool_use_prompt_tokens_details? : Array[ModalityTokenCount],
service_tier? : UsageMetadataServiceTier,
thoughts_token_count? : Int32,
candidates_token_count? : Int32,
cache_tokens_details? : Array[ModalityTokenCount],
total_token_count? : Int32,
) -> UsageMetadata {
{
prompt_token_count,
prompt_tokens_details,
tool_use_prompt_token_count,
cached_content_token_count,
candidates_tokens_details,
tool_use_prompt_tokens_details,
service_tier,
thoughts_token_count,
candidates_token_count,
cache_tokens_details,
total_token_count,
}
}
///|
///
/// Encodes this value as JSON.
pub extend UsageMetadata with ToJson::{to_json}
///|
pub impl ToJson for UsageMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("promptTokenCount", self.prompt_token_count)
.opt("promptTokensDetails", self.prompt_tokens_details)
.opt("toolUsePromptTokenCount", self.tool_use_prompt_token_count)
.opt("cachedContentTokenCount", self.cached_content_token_count)
.opt("candidatesTokensDetails", self.candidates_tokens_details)
.opt("toolUsePromptTokensDetails", self.tool_use_prompt_tokens_details)
.opt("serviceTier", self.service_tier)
.opt("thoughtsTokenCount", self.thoughts_token_count)
.opt("candidatesTokenCount", self.candidates_token_count)
.opt("cacheTokensDetails", self.cache_tokens_details)
.opt("totalTokenCount", self.total_token_count)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend UsageMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for UsageMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
prompt_token_count: @sdkjson.opt_field(obj, "promptTokenCount", path),
prompt_tokens_details: @sdkjson.opt_field(obj, "promptTokensDetails", path),
tool_use_prompt_token_count: @sdkjson.opt_field(
obj, "toolUsePromptTokenCount", path,
),
cached_content_token_count: @sdkjson.opt_field(
obj, "cachedContentTokenCount", path,
),
candidates_tokens_details: @sdkjson.opt_field(
obj, "candidatesTokensDetails", path,
),
tool_use_prompt_tokens_details: @sdkjson.opt_field(
obj, "toolUsePromptTokensDetails", path,
),
service_tier: @sdkjson.opt_field(obj, "serviceTier", path),
thoughts_token_count: @sdkjson.opt_field(obj, "thoughtsTokenCount", path),
candidates_token_count: @sdkjson.opt_field(
obj, "candidatesTokenCount", path,
),
cache_tokens_details: @sdkjson.opt_field(obj, "cacheTokensDetails", path),
total_token_count: @sdkjson.opt_field(obj, "totalTokenCount", path),
}
}
///|
///
/// A response from `CountTokens`. It returns the model's `token_count` for the `prompt`.
#derive(Eq, @debug.Debug)
pub(all) struct CountTokensResponse {
total_tokens : Int32?
cache_tokens_details : Array[ModalityTokenCount]?
cached_content_token_count : Int32?
prompt_tokens_details : Array[ModalityTokenCount]?
}
///|
pub extend CountTokensResponse with Eq::{equal, not_equal}
///|
pub extend CountTokensResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a CountTokensResponse with omitted optional fields absent.
pub fn CountTokensResponse::new(
total_tokens? : Int32,
cache_tokens_details? : Array[ModalityTokenCount],
cached_content_token_count? : Int32,
prompt_tokens_details? : Array[ModalityTokenCount],
) -> CountTokensResponse {
{
total_tokens,
cache_tokens_details,
cached_content_token_count,
prompt_tokens_details,
}
}
///|
///
/// Encodes this value as JSON.
pub extend CountTokensResponse with ToJson::{to_json}
///|
pub impl ToJson for CountTokensResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("totalTokens", self.total_tokens)
.opt("cacheTokensDetails", self.cache_tokens_details)
.opt("cachedContentTokenCount", self.cached_content_token_count)
.opt("promptTokensDetails", self.prompt_tokens_details)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CountTokensResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CountTokensResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
total_tokens: @sdkjson.opt_field(obj, "totalTokens", path),
cache_tokens_details: @sdkjson.opt_field(obj, "cacheTokensDetails", path),
cached_content_token_count: @sdkjson.opt_field(
obj, "cachedContentTokenCount", path,
),
prompt_tokens_details: @sdkjson.opt_field(obj, "promptTokensDetails", path),
}
}
///|
///
/// Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO. Enum values: MODE_UNSPECIFIED: Unspecified function calling mode. This value should not be used.; AUTO: Default model behavior, model decides to predict either a function call or a natural language response.; ANY: Model is constrained to always predicting a function call only. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".; NONE: Model will not predict any function call. Model behavior is same as when not passing any function declarations.; VALIDATED: Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FunctionCallingConfigMode {
MODEUNSPECIFIED
AUTO
ANY
NONE
VALIDATED
Unknown(String)
}
///|
pub extend FunctionCallingConfigMode with Eq::{equal, not_equal}
///|
pub extend FunctionCallingConfigMode with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FunctionCallingConfigMode with ToJson::{to_json}
///|
pub impl ToJson for FunctionCallingConfigMode with fn to_json(self) {
let raw = match self {
FunctionCallingConfigMode::MODEUNSPECIFIED => "MODE_UNSPECIFIED"
FunctionCallingConfigMode::AUTO => "AUTO"
FunctionCallingConfigMode::ANY => "ANY"
FunctionCallingConfigMode::NONE => "NONE"
FunctionCallingConfigMode::VALIDATED => "VALIDATED"
FunctionCallingConfigMode::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FunctionCallingConfigMode with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionCallingConfigMode with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODE_UNSPECIFIED" =>
Option::Some(FunctionCallingConfigMode::MODEUNSPECIFIED)
"AUTO" => Option::Some(FunctionCallingConfigMode::AUTO)
"ANY" => Option::Some(FunctionCallingConfigMode::ANY)
"NONE" => Option::Some(FunctionCallingConfigMode::NONE)
"VALIDATED" => Option::Some(FunctionCallingConfigMode::VALIDATED)
_ => Option::None
}
},
raw => FunctionCallingConfigMode::Unknown(raw),
)
}
///|
///
/// Configuration for specifying function calling behavior.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionCallingConfig {
mode : FunctionCallingConfigMode?
allowed_function_names : Array[String]?
}
///|
pub extend FunctionCallingConfig with Eq::{equal, not_equal}
///|
pub extend FunctionCallingConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionCallingConfig with omitted optional fields absent.
pub fn FunctionCallingConfig::new(
mode? : FunctionCallingConfigMode,
allowed_function_names? : Array[String],
) -> FunctionCallingConfig {
{ mode, allowed_function_names, }
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionCallingConfig with ToJson::{to_json}
///|
pub impl ToJson for FunctionCallingConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("mode", self.mode)
.opt("allowedFunctionNames", self.allowed_function_names)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionCallingConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionCallingConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
mode: @sdkjson.opt_field(obj, "mode", path),
allowed_function_names: @sdkjson.opt_field(
obj, "allowedFunctionNames", path,
),
}
}
///|
///
/// Encapsulates a snippet of a user review that answers a question about the features of a specific place in Google Maps.
#derive(Eq, @debug.Debug)
pub(all) struct ReviewSnippet {
review_id : String?
google_maps_uri : String?
title : String?
}
///|
pub extend ReviewSnippet with Eq::{equal, not_equal}
///|
pub extend ReviewSnippet with @debug.Debug::{to_repr}
///|
///
/// Creates a ReviewSnippet with omitted optional fields absent.
pub fn ReviewSnippet::new(
review_id? : String,
google_maps_uri? : String,
title? : String,
) -> ReviewSnippet {
{ review_id, google_maps_uri, title, }
}
///|
///
/// Encodes this value as JSON.
pub extend ReviewSnippet with ToJson::{to_json}
///|
pub impl ToJson for ReviewSnippet with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("reviewId", self.review_id)
.opt("googleMapsUri", self.google_maps_uri)
.opt("title", self.title)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ReviewSnippet with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ReviewSnippet with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
review_id: @sdkjson.opt_field(obj, "reviewId", path),
google_maps_uri: @sdkjson.opt_field(obj, "googleMapsUri", path),
title: @sdkjson.opt_field(obj, "title", path),
}
}
///|
///
/// Collection of sources that provide answers about the features of a given place in Google Maps. Each PlaceAnswerSources message corresponds to a specific place in Google Maps. The Google Maps tool used these sources in order to answer questions about features of the place (e.g: "does Bar Foo have Wifi" or "is Foo Bar wheelchair accessible?"). Currently we only support review snippets as sources.
#derive(Eq, @debug.Debug)
pub(all) struct PlaceAnswerSources {
review_snippets : Array[ReviewSnippet]?
}
///|
pub extend PlaceAnswerSources with Eq::{equal, not_equal}
///|
pub extend PlaceAnswerSources with @debug.Debug::{to_repr}
///|
///
/// Creates a PlaceAnswerSources with omitted optional fields absent.
pub fn PlaceAnswerSources::new(
review_snippets? : Array[ReviewSnippet],
) -> PlaceAnswerSources {
{ review_snippets, }
}
///|
///
/// Encodes this value as JSON.
pub extend PlaceAnswerSources with ToJson::{to_json}
///|
pub impl ToJson for PlaceAnswerSources with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("reviewSnippets", self.review_snippets).build()
}
///|
///
/// Decodes this value from JSON.
pub extend PlaceAnswerSources with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PlaceAnswerSources with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ review_snippets: @sdkjson.opt_field(obj, "reviewSnippets", path), }
}
///|
///
/// A grounding chunk from Google Maps. A Maps chunk corresponds to a single place.
#derive(Eq, @debug.Debug)
pub(all) struct Maps {
uri : String?
place_answer_sources : PlaceAnswerSources?
place_id : String?
text : String?
title : String?
}
///|
pub extend Maps with Eq::{equal, not_equal}
///|
pub extend Maps with @debug.Debug::{to_repr}
///|
///
/// Creates a Maps with omitted optional fields absent.
pub fn Maps::new(
uri? : String,
place_answer_sources? : PlaceAnswerSources,
place_id? : String,
text? : String,
title? : String,
) -> Maps {
{ uri, place_answer_sources, place_id, text, title, }
}
///|
///
/// Encodes this value as JSON.
pub extend Maps with ToJson::{to_json}
///|
pub impl ToJson for Maps with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("uri", self.uri)
.opt("placeAnswerSources", self.place_answer_sources)
.opt("placeId", self.place_id)
.opt("text", self.text)
.opt("title", self.title)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Maps with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Maps with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
uri: @sdkjson.opt_field(obj, "uri", path),
place_answer_sources: @sdkjson.opt_field(obj, "placeAnswerSources", path),
place_id: @sdkjson.opt_field(obj, "placeId", path),
text: @sdkjson.opt_field(obj, "text", path),
title: @sdkjson.opt_field(obj, "title", path),
}
}
///|
///
/// The mode of the predictor to be used in dynamic retrieval. Enum values: MODE_UNSPECIFIED: Always trigger retrieval.; MODE_DYNAMIC: Run retrieval only when system decides it is necessary.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum DynamicRetrievalConfigMode {
MODEUNSPECIFIED
MODEDYNAMIC
Unknown(String)
}
///|
pub extend DynamicRetrievalConfigMode with Eq::{equal, not_equal}
///|
pub extend DynamicRetrievalConfigMode with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend DynamicRetrievalConfigMode with ToJson::{to_json}
///|
pub impl ToJson for DynamicRetrievalConfigMode with fn to_json(self) {
let raw = match self {
DynamicRetrievalConfigMode::MODEUNSPECIFIED => "MODE_UNSPECIFIED"
DynamicRetrievalConfigMode::MODEDYNAMIC => "MODE_DYNAMIC"
DynamicRetrievalConfigMode::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend DynamicRetrievalConfigMode with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for DynamicRetrievalConfigMode with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODE_UNSPECIFIED" =>
Option::Some(DynamicRetrievalConfigMode::MODEUNSPECIFIED)
"MODE_DYNAMIC" => Option::Some(DynamicRetrievalConfigMode::MODEDYNAMIC)
_ => Option::None
}
},
raw => DynamicRetrievalConfigMode::Unknown(raw),
)
}
///|
///
/// Describes the options to customize dynamic retrieval.
#derive(Eq, @debug.Debug)
pub(all) struct DynamicRetrievalConfig {
dynamic_threshold : Double?
mode : DynamicRetrievalConfigMode?
}
///|
pub extend DynamicRetrievalConfig with Eq::{equal, not_equal}
///|
pub extend DynamicRetrievalConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a DynamicRetrievalConfig with omitted optional fields absent.
pub fn DynamicRetrievalConfig::new(
dynamic_threshold? : Double,
mode? : DynamicRetrievalConfigMode,
) -> DynamicRetrievalConfig {
{ dynamic_threshold, mode, }
}
///|
///
/// Encodes this value as JSON.
pub extend DynamicRetrievalConfig with ToJson::{to_json}
///|
pub impl ToJson for DynamicRetrievalConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("dynamicThreshold", self.dynamic_threshold)
.opt("mode", self.mode)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend DynamicRetrievalConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for DynamicRetrievalConfig with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
dynamic_threshold: @sdkjson.opt_field(obj, "dynamicThreshold", path),
mode: @sdkjson.opt_field(obj, "mode", path),
}
}
///|
///
/// A list of string values.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingChunkStringList {
values : Array[String]?
}
///|
pub extend GroundingChunkStringList with Eq::{equal, not_equal}
///|
pub extend GroundingChunkStringList with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingChunkStringList with omitted optional fields absent.
pub fn GroundingChunkStringList::new(
values? : Array[String],
) -> GroundingChunkStringList {
{ values, }
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingChunkStringList with ToJson::{to_json}
///|
pub impl ToJson for GroundingChunkStringList with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("values", self.values).build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingChunkStringList with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingChunkStringList with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{ values: @sdkjson.opt_field(obj, "values", path), }
}
///|
///
/// User provided metadata about the GroundingFact.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingChunkCustomMetadata {
string_list_value : GroundingChunkStringList?
string_value : String?
numeric_value : Double?
key : String?
}
///|
pub extend GroundingChunkCustomMetadata with Eq::{equal, not_equal}
///|
pub extend GroundingChunkCustomMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingChunkCustomMetadata with omitted optional fields absent.
pub fn GroundingChunkCustomMetadata::new(
string_list_value? : GroundingChunkStringList,
string_value? : String,
numeric_value? : Double,
key? : String,
) -> GroundingChunkCustomMetadata {
{ string_list_value, string_value, numeric_value, key, }
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingChunkCustomMetadata with ToJson::{to_json}
///|
pub impl ToJson for GroundingChunkCustomMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("stringListValue", self.string_list_value)
.opt("stringValue", self.string_value)
.opt("numericValue", self.numeric_value)
.opt("key", self.key)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingChunkCustomMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingChunkCustomMetadata with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
string_list_value: @sdkjson.opt_field(obj, "stringListValue", path),
string_value: @sdkjson.opt_field(obj, "stringValue", path),
numeric_value: @sdkjson.opt_field(obj, "numericValue", path),
key: @sdkjson.opt_field(obj, "key", path),
}
}
///|
///
/// Different types of search that can be enabled on the GoogleSearch tool.
#derive(Eq, @debug.Debug)
pub(all) struct SearchTypes {
web_search : Json?
image_search : Json?
}
///|
pub extend SearchTypes with Eq::{equal, not_equal}
///|
pub extend SearchTypes with @debug.Debug::{to_repr}
///|
///
/// Creates a SearchTypes with omitted optional fields absent.
pub fn SearchTypes::new(
web_search? : Json,
image_search? : Json,
) -> SearchTypes {
{ web_search, image_search, }
}
///|
///
/// Encodes this value as JSON.
pub extend SearchTypes with ToJson::{to_json}
///|
pub impl ToJson for SearchTypes with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("webSearch", self.web_search)
.opt("imageSearch", self.image_search)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SearchTypes with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SearchTypes with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
web_search: @sdkjson.opt_field(obj, "webSearch", path),
image_search: @sdkjson.opt_field(obj, "imageSearch", path),
}
}
///|
///
/// Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
#derive(Eq, @debug.Debug)
pub(all) struct Interval {
end_time : String?
start_time : String?
}
///|
pub extend Interval with Eq::{equal, not_equal}
///|
pub extend Interval with @debug.Debug::{to_repr}
///|
///
/// Creates a Interval with omitted optional fields absent.
pub fn Interval::new(end_time? : String, start_time? : String) -> Interval {
{ end_time, start_time, }
}
///|
///
/// Encodes this value as JSON.
pub extend Interval with ToJson::{to_json}
///|
pub impl ToJson for Interval with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("endTime", self.end_time)
.opt("startTime", self.start_time)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Interval with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Interval with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
end_time: @sdkjson.opt_field(obj, "endTime", path),
start_time: @sdkjson.opt_field(obj, "startTime", path),
}
}
///|
///
/// GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleSearch {
search_types : SearchTypes?
time_range_filter : Interval?
}
///|
pub extend GoogleSearch with Eq::{equal, not_equal}
///|
pub extend GoogleSearch with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleSearch with omitted optional fields absent.
pub fn GoogleSearch::new(
search_types? : SearchTypes,
time_range_filter? : Interval,
) -> GoogleSearch {
{ search_types, time_range_filter, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleSearch with ToJson::{to_json}
///|
pub impl ToJson for GoogleSearch with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("searchTypes", self.search_types)
.opt("timeRangeFilter", self.time_range_filter)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleSearch with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GoogleSearch with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
search_types: @sdkjson.opt_field(obj, "searchTypes", path),
time_range_filter: @sdkjson.opt_field(obj, "timeRangeFilter", path),
}
}
///|
///
/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
#derive(Eq, @debug.Debug)
pub(all) struct Status {
message : String?
code : Int32?
details : Array[Map[String, Json]]?
}
///|
pub extend Status with Eq::{equal, not_equal}
///|
pub extend Status with @debug.Debug::{to_repr}
///|
///
/// Creates a Status with omitted optional fields absent.
pub fn Status::new(
message? : String,
code? : Int32,
details? : Array[Map[String, Json]],
) -> Status {
{ message, code, details, }
}
///|
///
/// Encodes this value as JSON.
pub extend Status with ToJson::{to_json}
///|
pub impl ToJson for Status with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("message", self.message)
.opt("code", self.code)
.opt("details", self.details)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Status with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Status with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
message: @sdkjson.opt_field(obj, "message", path),
code: @sdkjson.opt_field(obj, "code", path),
details: @sdkjson.opt_field(obj, "details", path),
}
}
///|
///
/// Candidate for the logprobs token and score.
#derive(Eq, @debug.Debug)
pub(all) struct LogprobsResultCandidate {
token : String?
token_id : Int32?
log_probability : Double?
}
///|
pub extend LogprobsResultCandidate with Eq::{equal, not_equal}
///|
pub extend LogprobsResultCandidate with @debug.Debug::{to_repr}
///|
///
/// Creates a LogprobsResultCandidate with omitted optional fields absent.
pub fn LogprobsResultCandidate::new(
token? : String,
token_id? : Int32,
log_probability? : Double,
) -> LogprobsResultCandidate {
{ token, token_id, log_probability, }
}
///|
///
/// Encodes this value as JSON.
pub extend LogprobsResultCandidate with ToJson::{to_json}
///|
pub impl ToJson for LogprobsResultCandidate with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("token", self.token)
.opt("tokenId", self.token_id)
.opt("logProbability", self.log_probability)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend LogprobsResultCandidate with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for LogprobsResultCandidate with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
token: @sdkjson.opt_field(obj, "token", path),
token_id: @sdkjson.opt_field(obj, "tokenId", path),
log_probability: @sdkjson.opt_field(obj, "logProbability", path),
}
}
///|
///
/// Speech metadata for `text` parts.
#derive(Eq, @debug.Debug)
pub(all) struct SpeechMetadata {
speaker : String?
style : String?
}
///|
pub extend SpeechMetadata with Eq::{equal, not_equal}
///|
pub extend SpeechMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a SpeechMetadata with omitted optional fields absent.
pub fn SpeechMetadata::new(
speaker? : String,
style? : String,
) -> SpeechMetadata {
{ speaker, style, }
}
///|
///
/// Encodes this value as JSON.
pub extend SpeechMetadata with ToJson::{to_json}
///|
pub impl ToJson for SpeechMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speaker", self.speaker)
.opt("style", self.style)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SpeechMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpeechMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speaker: @sdkjson.opt_field(obj, "speaker", path),
style: @sdkjson.opt_field(obj, "style", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartTextMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartTextMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartTextMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartTextMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartTextMediaProcessing with fn to_json(self) {
let raw = match self {
PartTextMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartTextMediaProcessing::STATIC => "STATIC"
PartTextMediaProcessing::AGENTIC => "AGENTIC"
PartTextMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartTextMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartTextMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(PartTextMediaProcessing::MEDIAPROCESSINGUNSPECIFIED)
"STATIC" => Option::Some(PartTextMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartTextMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartTextMediaProcessing::Unknown(raw),
)
}
///|
///
/// Enum values: CONTENT_LAYER_UNSPECIFIED: Default value.; FRAMES: Extract video frames.; AUDIO: Extract audio track.; TRANSCRIPT: Extract audio transcript.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum VideoMetadataContentLayersItem {
CONTENTLAYERUNSPECIFIED
FRAMES
AUDIO
TRANSCRIPT
Unknown(String)
}
///|
pub extend VideoMetadataContentLayersItem with Eq::{equal, not_equal}
///|
pub extend VideoMetadataContentLayersItem with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend VideoMetadataContentLayersItem with ToJson::{to_json}
///|
pub impl ToJson for VideoMetadataContentLayersItem with fn to_json(self) {
let raw = match self {
VideoMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED =>
"CONTENT_LAYER_UNSPECIFIED"
VideoMetadataContentLayersItem::FRAMES => "FRAMES"
VideoMetadataContentLayersItem::AUDIO => "AUDIO"
VideoMetadataContentLayersItem::TRANSCRIPT => "TRANSCRIPT"
VideoMetadataContentLayersItem::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend VideoMetadataContentLayersItem with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for VideoMetadataContentLayersItem with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"CONTENT_LAYER_UNSPECIFIED" =>
Option::Some(VideoMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED)
"FRAMES" => Option::Some(VideoMetadataContentLayersItem::FRAMES)
"AUDIO" => Option::Some(VideoMetadataContentLayersItem::AUDIO)
"TRANSCRIPT" => Option::Some(VideoMetadataContentLayersItem::TRANSCRIPT)
_ => Option::None
}
},
raw => VideoMetadataContentLayersItem::Unknown(raw),
)
}
///|
///
/// Metadata describes the input video content. Set this in `Part.video_metadata` or `FunctionResponsePart.video_metadata` when `inline_data` or `file_data` contains video to configure static video preprocessing (such as time clipping, frame rate, maximum frame count, or extracted content layers).
#derive(Eq, @debug.Debug)
pub(all) struct VideoMetadata {
fps : Double?
end_offset : String?
content_layers : Array[VideoMetadataContentLayersItem]?
start_offset : String?
}
///|
pub extend VideoMetadata with Eq::{equal, not_equal}
///|
pub extend VideoMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a VideoMetadata with omitted optional fields absent.
pub fn VideoMetadata::new(
fps? : Double,
end_offset? : String,
content_layers? : Array[VideoMetadataContentLayersItem],
start_offset? : String,
) -> VideoMetadata {
{ fps, end_offset, content_layers, start_offset, }
}
///|
///
/// Encodes this value as JSON.
pub extend VideoMetadata with ToJson::{to_json}
///|
pub impl ToJson for VideoMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("fps", self.fps)
.opt("endOffset", self.end_offset)
.opt("contentLayers", self.content_layers)
.opt("startOffset", self.start_offset)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend VideoMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for VideoMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
fps: @sdkjson.opt_field(obj, "fps", path),
end_offset: @sdkjson.opt_field(obj, "endOffset", path),
content_layers: @sdkjson.opt_field(obj, "contentLayers", path),
start_offset: @sdkjson.opt_field(obj, "startOffset", path),
}
}
///|
///
/// Information about a single recognized word.
#derive(Eq, @debug.Debug)
pub(all) struct WordInfo {
end_offset : String?
start_offset : String?
word : String?
}
///|
pub extend WordInfo with Eq::{equal, not_equal}
///|
pub extend WordInfo with @debug.Debug::{to_repr}
///|
///
/// Creates a WordInfo with omitted optional fields absent.
pub fn WordInfo::new(
end_offset? : String,
start_offset? : String,
word? : String,
) -> WordInfo {
{ end_offset, start_offset, word, }
}
///|
///
/// Encodes this value as JSON.
pub extend WordInfo with ToJson::{to_json}
///|
pub impl ToJson for WordInfo with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("endOffset", self.end_offset)
.opt("startOffset", self.start_offset)
.opt("word", self.word)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend WordInfo with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for WordInfo with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
end_offset: @sdkjson.opt_field(obj, "endOffset", path),
start_offset: @sdkjson.opt_field(obj, "startOffset", path),
word: @sdkjson.opt_field(obj, "word", path),
}
}
///|
///
/// The transcription of an audio part. For multi-speaker audio, each speaker segment is a separate Part with its own AudioTranscription carrying the speaker_label.
#derive(Eq, @debug.Debug)
pub(all) struct AudioTranscription {
text : String?
words : Array[WordInfo]?
speaker_label : String?
}
///|
pub extend AudioTranscription with Eq::{equal, not_equal}
///|
pub extend AudioTranscription with @debug.Debug::{to_repr}
///|
///
/// Creates a AudioTranscription with omitted optional fields absent.
pub fn AudioTranscription::new(
text? : String,
words? : Array[WordInfo],
speaker_label? : String,
) -> AudioTranscription {
{ text, words, speaker_label, }
}
///|
///
/// Encodes this value as JSON.
pub extend AudioTranscription with ToJson::{to_json}
///|
pub impl ToJson for AudioTranscription with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("text", self.text)
.opt("words", self.words)
.opt("speakerLabel", self.speaker_label)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend AudioTranscription with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioTranscription with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
text: @sdkjson.opt_field(obj, "text", path),
words: @sdkjson.opt_field(obj, "words", path),
speaker_label: @sdkjson.opt_field(obj, "speakerLabel", path),
}
}
///|
///
/// The tokenization quality used for given media. for Gemini API support . Enum values: MEDIA_RESOLUTION_UNSPECIFIED: Media resolution has not been set.; MEDIA_RESOLUTION_LOW: Media resolution set to low.; MEDIA_RESOLUTION_MEDIUM: Media resolution set to medium.; MEDIA_RESOLUTION_HIGH: Media resolution set to high.; MEDIA_RESOLUTION_ULTRA_HIGH: Media resolution set to ultra high.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum V1mainMediaResolutionLevel {
MEDIARESOLUTIONUNSPECIFIED
MEDIARESOLUTIONLOW
MEDIARESOLUTIONMEDIUM
MEDIARESOLUTIONHIGH
MEDIARESOLUTIONULTRAHIGH
Unknown(String)
}
///|
pub extend V1mainMediaResolutionLevel with Eq::{equal, not_equal}
///|
pub extend V1mainMediaResolutionLevel with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend V1mainMediaResolutionLevel with ToJson::{to_json}
///|
pub impl ToJson for V1mainMediaResolutionLevel with fn to_json(self) {
let raw = match self {
V1mainMediaResolutionLevel::MEDIARESOLUTIONUNSPECIFIED =>
"MEDIA_RESOLUTION_UNSPECIFIED"
V1mainMediaResolutionLevel::MEDIARESOLUTIONLOW => "MEDIA_RESOLUTION_LOW"
V1mainMediaResolutionLevel::MEDIARESOLUTIONMEDIUM =>
"MEDIA_RESOLUTION_MEDIUM"
V1mainMediaResolutionLevel::MEDIARESOLUTIONHIGH => "MEDIA_RESOLUTION_HIGH"
V1mainMediaResolutionLevel::MEDIARESOLUTIONULTRAHIGH =>
"MEDIA_RESOLUTION_ULTRA_HIGH"
V1mainMediaResolutionLevel::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend V1mainMediaResolutionLevel with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for V1mainMediaResolutionLevel with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_RESOLUTION_UNSPECIFIED" =>
Option::Some(V1mainMediaResolutionLevel::MEDIARESOLUTIONUNSPECIFIED)
"MEDIA_RESOLUTION_LOW" =>
Option::Some(V1mainMediaResolutionLevel::MEDIARESOLUTIONLOW)
"MEDIA_RESOLUTION_MEDIUM" =>
Option::Some(V1mainMediaResolutionLevel::MEDIARESOLUTIONMEDIUM)
"MEDIA_RESOLUTION_HIGH" =>
Option::Some(V1mainMediaResolutionLevel::MEDIARESOLUTIONHIGH)
"MEDIA_RESOLUTION_ULTRA_HIGH" =>
Option::Some(V1mainMediaResolutionLevel::MEDIARESOLUTIONULTRAHIGH)
_ => Option::None
}
},
raw => V1mainMediaResolutionLevel::Unknown(raw),
)
}
///|
///
/// Media resolution for tokenization.
#derive(Eq, @debug.Debug)
pub(all) struct V1mainMediaResolution {
level : V1mainMediaResolutionLevel?
}
///|
pub extend V1mainMediaResolution with Eq::{equal, not_equal}
///|
pub extend V1mainMediaResolution with @debug.Debug::{to_repr}
///|
///
/// Creates a V1mainMediaResolution with omitted optional fields absent.
pub fn V1mainMediaResolution::new(
level? : V1mainMediaResolutionLevel,
) -> V1mainMediaResolution {
{ level, }
}
///|
///
/// Encodes this value as JSON.
pub extend V1mainMediaResolution with ToJson::{to_json}
///|
pub impl ToJson for V1mainMediaResolution with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("level", self.level).build()
}
///|
///
/// Decodes this value from JSON.
pub extend V1mainMediaResolution with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for V1mainMediaResolution with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ level: @sdkjson.opt_field(obj, "level", path), }
}
///|
///
/// Generated representation of PartText.
#derive(Eq, @debug.Debug)
pub(all) struct PartText {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
text : String
media_processing : PartTextMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartText with Eq::{equal, not_equal}
///|
pub extend PartText with @debug.Debug::{to_repr}
///|
///
/// Creates a PartText with omitted optional fields absent.
pub fn PartText::new(
text~ : String,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartTextMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartText {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
text,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartText with ToJson::{to_json}
///|
pub impl ToJson for PartText with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.field("text", self.text)
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartText with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartText with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
text: required_field(obj, "text", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Raw media bytes. Text should not be sent as raw bytes, use the 'text' field.
#derive(Eq, @debug.Debug)
pub(all) struct Blob {
data : String?
mime_type : String?
display_name : String?
}
///|
pub extend Blob with Eq::{equal, not_equal}
///|
pub extend Blob with @debug.Debug::{to_repr}
///|
///
/// Creates a Blob with omitted optional fields absent.
pub fn Blob::new(
data? : String,
mime_type? : String,
display_name? : String,
) -> Blob {
{ data, mime_type, display_name, }
}
///|
///
/// Encodes this value as JSON.
pub extend Blob with ToJson::{to_json}
///|
pub impl ToJson for Blob with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("data", self.data)
.opt("mimeType", self.mime_type)
.opt("displayName", self.display_name)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Blob with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Blob with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
data: @sdkjson.opt_field(obj, "data", path),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
display_name: @sdkjson.opt_field(obj, "displayName", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartInlineDataMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartInlineDataMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartInlineDataMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartInlineDataMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartInlineDataMediaProcessing with fn to_json(self) {
let raw = match self {
PartInlineDataMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartInlineDataMediaProcessing::STATIC => "STATIC"
PartInlineDataMediaProcessing::AGENTIC => "AGENTIC"
PartInlineDataMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartInlineDataMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartInlineDataMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartInlineDataMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartInlineDataMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartInlineDataMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartInlineDataMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartInlineData.
#derive(Eq, @debug.Debug)
pub(all) struct PartInlineData {
inline_data : Blob
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
media_processing : PartInlineDataMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartInlineData with Eq::{equal, not_equal}
///|
pub extend PartInlineData with @debug.Debug::{to_repr}
///|
///
/// Creates a PartInlineData with omitted optional fields absent.
pub fn PartInlineData::new(
inline_data~ : Blob,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartInlineDataMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartInlineData {
{
inline_data,
speech_metadata,
thought,
thought_signature,
part_metadata,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartInlineData with ToJson::{to_json}
///|
pub impl ToJson for PartInlineData with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.field("inlineData", self.inline_data)
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartInlineData with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartInlineData with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
inline_data: required_field(obj, "inlineData", path),
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// URI based data.
#derive(Eq, @debug.Debug)
pub(all) struct FileData {
display_name : String?
mime_type : String?
file_uri : String?
}
///|
pub extend FileData with Eq::{equal, not_equal}
///|
pub extend FileData with @debug.Debug::{to_repr}
///|
///
/// Creates a FileData with omitted optional fields absent.
pub fn FileData::new(
display_name? : String,
mime_type? : String,
file_uri? : String,
) -> FileData {
{ display_name, mime_type, file_uri, }
}
///|
///
/// Encodes this value as JSON.
pub extend FileData with ToJson::{to_json}
///|
pub impl ToJson for FileData with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("displayName", self.display_name)
.opt("mimeType", self.mime_type)
.opt("fileUri", self.file_uri)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FileData with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FileData with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
display_name: @sdkjson.opt_field(obj, "displayName", path),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
file_uri: @sdkjson.opt_field(obj, "fileUri", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartFileDataMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartFileDataMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartFileDataMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartFileDataMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartFileDataMediaProcessing with fn to_json(self) {
let raw = match self {
PartFileDataMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartFileDataMediaProcessing::STATIC => "STATIC"
PartFileDataMediaProcessing::AGENTIC => "AGENTIC"
PartFileDataMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartFileDataMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFileDataMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(PartFileDataMediaProcessing::MEDIAPROCESSINGUNSPECIFIED)
"STATIC" => Option::Some(PartFileDataMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartFileDataMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartFileDataMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartFileData.
#derive(Eq, @debug.Debug)
pub(all) struct PartFileData {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
file_data : FileData
part_metadata : Map[String, Json]?
media_processing : PartFileDataMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartFileData with Eq::{equal, not_equal}
///|
pub extend PartFileData with @debug.Debug::{to_repr}
///|
///
/// Creates a PartFileData with omitted optional fields absent.
pub fn PartFileData::new(
file_data~ : FileData,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartFileDataMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartFileData {
{
speech_metadata,
thought,
thought_signature,
file_data,
part_metadata,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartFileData with ToJson::{to_json}
///|
pub impl ToJson for PartFileData with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.field("fileData", self.file_data)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartFileData with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFileData with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
file_data: required_field(obj, "fileData", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartFunctionCallMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartFunctionCallMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartFunctionCallMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartFunctionCallMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartFunctionCallMediaProcessing with fn to_json(self) {
let raw = match self {
PartFunctionCallMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartFunctionCallMediaProcessing::STATIC => "STATIC"
PartFunctionCallMediaProcessing::AGENTIC => "AGENTIC"
PartFunctionCallMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartFunctionCallMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFunctionCallMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartFunctionCallMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartFunctionCallMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartFunctionCallMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartFunctionCallMediaProcessing::Unknown(raw),
)
}
///|
///
/// A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionCall {
name : String?
args : Map[String, Json]?
id : String?
}
///|
pub extend FunctionCall with Eq::{equal, not_equal}
///|
pub extend FunctionCall with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionCall with omitted optional fields absent.
pub fn FunctionCall::new(
name? : String,
args? : Map[String, Json],
id? : String,
) -> FunctionCall {
{ name, args, id, }
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionCall with ToJson::{to_json}
///|
pub impl ToJson for FunctionCall with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("name", self.name)
.opt("args", self.args.map(value => json_map_to_json(value)))
.opt("id", self.id)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionCall with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionCall with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
name: @sdkjson.opt_field(obj, "name", path),
args: decode_optional_json_map(obj, "args", path),
id: @sdkjson.opt_field(obj, "id", path),
}
}
///|
///
/// Generated representation of PartFunctionCall.
#derive(Eq, @debug.Debug)
pub(all) struct PartFunctionCall {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
media_processing : PartFunctionCallMediaProcessing?
function_call : FunctionCall
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartFunctionCall with Eq::{equal, not_equal}
///|
pub extend PartFunctionCall with @debug.Debug::{to_repr}
///|
///
/// Creates a PartFunctionCall with omitted optional fields absent.
pub fn PartFunctionCall::new(
function_call~ : FunctionCall,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartFunctionCallMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartFunctionCall {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
media_processing,
function_call,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartFunctionCall with ToJson::{to_json}
///|
pub impl ToJson for PartFunctionCall with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.opt("mediaProcessing", self.media_processing)
.field("functionCall", self.function_call)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartFunctionCall with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFunctionCall with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
function_call: required_field(obj, "functionCall", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE. Enum values: SCHEDULING_UNSPECIFIED: This value is unused.; SILENT: Only add the result to the conversation context, do not interrupt or trigger generation.; WHEN_IDLE: Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation.; INTERRUPT: Add the result to the conversation context, interrupt ongoing generation and prompt to generate output.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FunctionResponseScheduling {
SCHEDULINGUNSPECIFIED
SILENT
WHENIDLE
INTERRUPT
Unknown(String)
}
///|
pub extend FunctionResponseScheduling with Eq::{equal, not_equal}
///|
pub extend FunctionResponseScheduling with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FunctionResponseScheduling with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponseScheduling with fn to_json(self) {
let raw = match self {
FunctionResponseScheduling::SCHEDULINGUNSPECIFIED =>
"SCHEDULING_UNSPECIFIED"
FunctionResponseScheduling::SILENT => "SILENT"
FunctionResponseScheduling::WHENIDLE => "WHEN_IDLE"
FunctionResponseScheduling::INTERRUPT => "INTERRUPT"
FunctionResponseScheduling::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FunctionResponseScheduling with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponseScheduling with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"SCHEDULING_UNSPECIFIED" =>
Option::Some(FunctionResponseScheduling::SCHEDULINGUNSPECIFIED)
"SILENT" => Option::Some(FunctionResponseScheduling::SILENT)
"WHEN_IDLE" => Option::Some(FunctionResponseScheduling::WHENIDLE)
"INTERRUPT" => Option::Some(FunctionResponseScheduling::INTERRUPT)
_ => Option::None
}
},
raw => FunctionResponseScheduling::Unknown(raw),
)
}
///|
///
/// Raw media bytes for function response. Text should not be sent as raw bytes, use the 'FunctionResponse.response' field.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionResponseBlob {
mime_type : String?
data : String?
display_name : String?
}
///|
pub extend FunctionResponseBlob with Eq::{equal, not_equal}
///|
pub extend FunctionResponseBlob with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionResponseBlob with omitted optional fields absent.
pub fn FunctionResponseBlob::new(
mime_type? : String,
data? : String,
display_name? : String,
) -> FunctionResponseBlob {
{ mime_type, data, display_name, }
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionResponseBlob with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponseBlob with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("mimeType", self.mime_type)
.opt("data", self.data)
.opt("displayName", self.display_name)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionResponseBlob with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponseBlob with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
data: @sdkjson.opt_field(obj, "data", path),
display_name: @sdkjson.opt_field(obj, "displayName", path),
}
}
///|
///
/// Metadata describes the input audio content. Set this in `Part.audio_metadata` or `FunctionResponsePart.audio_metadata` when `inline_data` or `file_data` contains audio to configure static audio preprocessing.
#derive(Eq, @debug.Debug)
pub(all) struct AudioMetadata {
start_offset : String?
end_offset : String?
}
///|
pub extend AudioMetadata with Eq::{equal, not_equal}
///|
pub extend AudioMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a AudioMetadata with omitted optional fields absent.
pub fn AudioMetadata::new(
start_offset? : String,
end_offset? : String,
) -> AudioMetadata {
{ start_offset, end_offset, }
}
///|
///
/// Encodes this value as JSON.
pub extend AudioMetadata with ToJson::{to_json}
///|
pub impl ToJson for AudioMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("startOffset", self.start_offset)
.opt("endOffset", self.end_offset)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend AudioMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AudioMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
start_offset: @sdkjson.opt_field(obj, "startOffset", path),
end_offset: @sdkjson.opt_field(obj, "endOffset", path),
}
}
///|
///
/// Enum values: CONTENT_LAYER_UNSPECIFIED: Default value.; DATA: Cell values, merges, and formats.; FORMULAS: Formula expressions and their computed results.; VISUAL: A rendered image of the sheet.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SpreadsheetMetadataContentLayersItem {
CONTENTLAYERUNSPECIFIED
DATA
FORMULAS
VISUAL
Unknown(String)
}
///|
pub extend SpreadsheetMetadataContentLayersItem with Eq::{equal, not_equal}
///|
pub extend SpreadsheetMetadataContentLayersItem with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SpreadsheetMetadataContentLayersItem with ToJson::{to_json}
///|
pub impl ToJson for SpreadsheetMetadataContentLayersItem with fn to_json(self) {
let raw = match self {
SpreadsheetMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED =>
"CONTENT_LAYER_UNSPECIFIED"
SpreadsheetMetadataContentLayersItem::DATA => "DATA"
SpreadsheetMetadataContentLayersItem::FORMULAS => "FORMULAS"
SpreadsheetMetadataContentLayersItem::VISUAL => "VISUAL"
SpreadsheetMetadataContentLayersItem::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SpreadsheetMetadataContentLayersItem with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpreadsheetMetadataContentLayersItem with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"CONTENT_LAYER_UNSPECIFIED" =>
Option::Some(
SpreadsheetMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED,
)
"DATA" => Option::Some(SpreadsheetMetadataContentLayersItem::DATA)
"FORMULAS" =>
Option::Some(SpreadsheetMetadataContentLayersItem::FORMULAS)
"VISUAL" => Option::Some(SpreadsheetMetadataContentLayersItem::VISUAL)
_ => Option::None
}
},
raw => SpreadsheetMetadataContentLayersItem::Unknown(raw),
)
}
///|
///
/// Metadata describes the input spreadsheet content. Set this in `Part.spreadsheet_metadata` or `FunctionResponsePart.spreadsheet_metadata` when `inline_data` or `file_data` contains a spreadsheet to configure static spreadsheet preprocessing.
#derive(Eq, @debug.Debug)
pub(all) struct SpreadsheetMetadata {
visible_cells : String?
sheet_index : Int32?
content_layers : Array[SpreadsheetMetadataContentLayersItem]?
}
///|
pub extend SpreadsheetMetadata with Eq::{equal, not_equal}
///|
pub extend SpreadsheetMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a SpreadsheetMetadata with omitted optional fields absent.
pub fn SpreadsheetMetadata::new(
visible_cells? : String,
sheet_index? : Int32,
content_layers? : Array[SpreadsheetMetadataContentLayersItem],
) -> SpreadsheetMetadata {
{ visible_cells, sheet_index, content_layers, }
}
///|
///
/// Encodes this value as JSON.
pub extend SpreadsheetMetadata with ToJson::{to_json}
///|
pub impl ToJson for SpreadsheetMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("visibleCells", self.visible_cells)
.opt("sheetIndex", self.sheet_index)
.opt("contentLayers", self.content_layers)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SpreadsheetMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SpreadsheetMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
visible_cells: @sdkjson.opt_field(obj, "visibleCells", path),
sheet_index: @sdkjson.opt_field(obj, "sheetIndex", path),
content_layers: @sdkjson.opt_field(obj, "contentLayers", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field. Enum values: MEDIA_PROCESSING_UNSPECIFIED: Defaults to model-specific processing.; STATIC: Fixed-rate frame extraction. All frames placed in context.; AGENTIC: Model-driven dynamic navigation. Recommended for most use cases.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FunctionResponsePartMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend FunctionResponsePartMediaProcessing with Eq::{equal, not_equal}
///|
pub extend FunctionResponsePartMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FunctionResponsePartMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponsePartMediaProcessing with fn to_json(self) {
let raw = match self {
FunctionResponsePartMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
FunctionResponsePartMediaProcessing::STATIC => "STATIC"
FunctionResponsePartMediaProcessing::AGENTIC => "AGENTIC"
FunctionResponsePartMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FunctionResponsePartMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponsePartMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
FunctionResponsePartMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(FunctionResponsePartMediaProcessing::STATIC)
"AGENTIC" => Option::Some(FunctionResponsePartMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => FunctionResponsePartMediaProcessing::Unknown(raw),
)
}
///|
///
/// Enum values: CONTENT_LAYER_UNSPECIFIED: Default value.; PAGE_IMAGE: Rendered page images.; PAGE_TEXT: Extracted page text.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum DocumentMetadataContentLayersItem {
CONTENTLAYERUNSPECIFIED
PAGEIMAGE
PAGETEXT
Unknown(String)
}
///|
pub extend DocumentMetadataContentLayersItem with Eq::{equal, not_equal}
///|
pub extend DocumentMetadataContentLayersItem with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend DocumentMetadataContentLayersItem with ToJson::{to_json}
///|
pub impl ToJson for DocumentMetadataContentLayersItem with fn to_json(self) {
let raw = match self {
DocumentMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED =>
"CONTENT_LAYER_UNSPECIFIED"
DocumentMetadataContentLayersItem::PAGEIMAGE => "PAGE_IMAGE"
DocumentMetadataContentLayersItem::PAGETEXT => "PAGE_TEXT"
DocumentMetadataContentLayersItem::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend DocumentMetadataContentLayersItem with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for DocumentMetadataContentLayersItem with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"CONTENT_LAYER_UNSPECIFIED" =>
Option::Some(
DocumentMetadataContentLayersItem::CONTENTLAYERUNSPECIFIED,
)
"PAGE_IMAGE" =>
Option::Some(DocumentMetadataContentLayersItem::PAGEIMAGE)
"PAGE_TEXT" => Option::Some(DocumentMetadataContentLayersItem::PAGETEXT)
_ => Option::None
}
},
raw => DocumentMetadataContentLayersItem::Unknown(raw),
)
}
///|
///
/// Metadata describes the input document content. Set this in `Part.document_metadata` or `FunctionResponsePart.document_metadata` when `inline_data` or `file_data` contains a document to configure static document preprocessing.
#derive(Eq, @debug.Debug)
pub(all) struct DocumentMetadata {
end_page : Int32?
start_page : Int32?
content_layers : Array[DocumentMetadataContentLayersItem]?
}
///|
pub extend DocumentMetadata with Eq::{equal, not_equal}
///|
pub extend DocumentMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a DocumentMetadata with omitted optional fields absent.
pub fn DocumentMetadata::new(
end_page? : Int32,
start_page? : Int32,
content_layers? : Array[DocumentMetadataContentLayersItem],
) -> DocumentMetadata {
{ end_page, start_page, content_layers, }
}
///|
///
/// Encodes this value as JSON.
pub extend DocumentMetadata with ToJson::{to_json}
///|
pub impl ToJson for DocumentMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("endPage", self.end_page)
.opt("startPage", self.start_page)
.opt("contentLayers", self.content_layers)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend DocumentMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for DocumentMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
end_page: @sdkjson.opt_field(obj, "endPage", path),
start_page: @sdkjson.opt_field(obj, "startPage", path),
content_layers: @sdkjson.opt_field(obj, "contentLayers", path),
}
}
///|
///
/// URI based data for function response.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionResponseFileData {
display_name : String?
mime_type : String?
file_uri : String?
}
///|
pub extend FunctionResponseFileData with Eq::{equal, not_equal}
///|
pub extend FunctionResponseFileData with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionResponseFileData with omitted optional fields absent.
pub fn FunctionResponseFileData::new(
display_name? : String,
mime_type? : String,
file_uri? : String,
) -> FunctionResponseFileData {
{ display_name, mime_type, file_uri, }
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionResponseFileData with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponseFileData with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("displayName", self.display_name)
.opt("mimeType", self.mime_type)
.opt("fileUri", self.file_uri)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionResponseFileData with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponseFileData with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
display_name: @sdkjson.opt_field(obj, "displayName", path),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
file_uri: @sdkjson.opt_field(obj, "fileUri", path),
}
}
///|
///
/// A datatype containing media that is part of a `FunctionResponse` message. A `FunctionResponsePart` consists of data which has an associated datatype. A `FunctionResponsePart` can only contain one of the accepted types in `FunctionResponsePart.data`. Media can be passed as raw bytes (`inline_data`) or by URI (`file_data`) with an IANA MIME type identifying the type and subtype of the media.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionResponsePart {
inline_data : FunctionResponseBlob?
audio_metadata : AudioMetadata?
spreadsheet_metadata : SpreadsheetMetadata?
video_metadata : VideoMetadata?
media_processing : FunctionResponsePartMediaProcessing?
media_resolution : V1mainMediaResolution?
document_metadata : DocumentMetadata?
file_data : FunctionResponseFileData?
}
///|
pub extend FunctionResponsePart with Eq::{equal, not_equal}
///|
pub extend FunctionResponsePart with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionResponsePart with omitted optional fields absent.
pub fn FunctionResponsePart::new(
inline_data? : FunctionResponseBlob,
audio_metadata? : AudioMetadata,
spreadsheet_metadata? : SpreadsheetMetadata,
video_metadata? : VideoMetadata,
media_processing? : FunctionResponsePartMediaProcessing,
media_resolution? : V1mainMediaResolution,
document_metadata? : DocumentMetadata,
file_data? : FunctionResponseFileData,
) -> FunctionResponsePart {
{
inline_data,
audio_metadata,
spreadsheet_metadata,
video_metadata,
media_processing,
media_resolution,
document_metadata,
file_data,
}
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionResponsePart with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponsePart with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("inlineData", self.inline_data)
.opt("audioMetadata", self.audio_metadata)
.opt("spreadsheetMetadata", self.spreadsheet_metadata)
.opt("videoMetadata", self.video_metadata)
.opt("mediaProcessing", self.media_processing)
.opt("mediaResolution", self.media_resolution)
.opt("documentMetadata", self.document_metadata)
.opt("fileData", self.file_data)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionResponsePart with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponsePart with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
inline_data: @sdkjson.opt_field(obj, "inlineData", path),
audio_metadata: @sdkjson.opt_field(obj, "audioMetadata", path),
spreadsheet_metadata: @sdkjson.opt_field(obj, "spreadsheetMetadata", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
document_metadata: @sdkjson.opt_field(obj, "documentMetadata", path),
file_data: @sdkjson.opt_field(obj, "fileData", path),
}
}
///|
///
/// The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionResponse {
scheduling : FunctionResponseScheduling?
id : String?
will_continue : Bool?
name : String?
response : Map[String, Json]?
parts : Array[FunctionResponsePart]?
}
///|
pub extend FunctionResponse with Eq::{equal, not_equal}
///|
pub extend FunctionResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionResponse with omitted optional fields absent.
pub fn FunctionResponse::new(
scheduling? : FunctionResponseScheduling,
id? : String,
will_continue? : Bool,
name? : String,
response? : Map[String, Json],
parts? : Array[FunctionResponsePart],
) -> FunctionResponse {
{ scheduling, id, will_continue, name, response, parts, }
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionResponse with ToJson::{to_json}
///|
pub impl ToJson for FunctionResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("scheduling", self.scheduling)
.opt("id", self.id)
.opt("willContinue", self.will_continue)
.opt("name", self.name)
.opt("response", self.response.map(value => json_map_to_json(value)))
.opt("parts", self.parts)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
scheduling: @sdkjson.opt_field(obj, "scheduling", path),
id: @sdkjson.opt_field(obj, "id", path),
will_continue: @sdkjson.opt_field(obj, "willContinue", path),
name: @sdkjson.opt_field(obj, "name", path),
response: decode_optional_json_map(obj, "response", path),
parts: @sdkjson.opt_field(obj, "parts", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartFunctionResponseMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartFunctionResponseMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartFunctionResponseMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartFunctionResponseMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartFunctionResponseMediaProcessing with fn to_json(self) {
let raw = match self {
PartFunctionResponseMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartFunctionResponseMediaProcessing::STATIC => "STATIC"
PartFunctionResponseMediaProcessing::AGENTIC => "AGENTIC"
PartFunctionResponseMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartFunctionResponseMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFunctionResponseMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartFunctionResponseMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartFunctionResponseMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartFunctionResponseMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartFunctionResponseMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartFunctionResponse.
#derive(Eq, @debug.Debug)
pub(all) struct PartFunctionResponse {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
function_response : FunctionResponse
media_processing : PartFunctionResponseMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartFunctionResponse with Eq::{equal, not_equal}
///|
pub extend PartFunctionResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a PartFunctionResponse with omitted optional fields absent.
pub fn PartFunctionResponse::new(
function_response~ : FunctionResponse,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartFunctionResponseMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartFunctionResponse {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
function_response,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartFunctionResponse with ToJson::{to_json}
///|
pub impl ToJson for PartFunctionResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.field("functionResponse", self.function_response)
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartFunctionResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartFunctionResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
function_response: required_field(obj, "functionResponse", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Required. Programming language of the `code`. Enum values: LANGUAGE_UNSPECIFIED: Unspecified language. This value should not be used.; PYTHON: Python >= 3.10, with numpy and simpy available. Python is the default language.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ExecutableCodeLanguage {
LANGUAGEUNSPECIFIED
PYTHON
Unknown(String)
}
///|
pub extend ExecutableCodeLanguage with Eq::{equal, not_equal}
///|
pub extend ExecutableCodeLanguage with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ExecutableCodeLanguage with ToJson::{to_json}
///|
pub impl ToJson for ExecutableCodeLanguage with fn to_json(self) {
let raw = match self {
ExecutableCodeLanguage::LANGUAGEUNSPECIFIED => "LANGUAGE_UNSPECIFIED"
ExecutableCodeLanguage::PYTHON => "PYTHON"
ExecutableCodeLanguage::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ExecutableCodeLanguage with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ExecutableCodeLanguage with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"LANGUAGE_UNSPECIFIED" =>
Option::Some(ExecutableCodeLanguage::LANGUAGEUNSPECIFIED)
"PYTHON" => Option::Some(ExecutableCodeLanguage::PYTHON)
_ => Option::None
}
},
raw => ExecutableCodeLanguage::Unknown(raw),
)
}
///|
///
/// Code generated by the model that is meant to be executed, and the result returned to the model. Only generated when using the `CodeExecution` tool, in which the code will be automatically executed, and a corresponding `CodeExecutionResult` will also be generated.
#derive(Eq, @debug.Debug)
pub(all) struct ExecutableCode {
code : String?
id : String?
language : ExecutableCodeLanguage?
}
///|
pub extend ExecutableCode with Eq::{equal, not_equal}
///|
pub extend ExecutableCode with @debug.Debug::{to_repr}
///|
///
/// Creates a ExecutableCode with omitted optional fields absent.
pub fn ExecutableCode::new(
code? : String,
id? : String,
language? : ExecutableCodeLanguage,
) -> ExecutableCode {
{ code, id, language, }
}
///|
///
/// Encodes this value as JSON.
pub extend ExecutableCode with ToJson::{to_json}
///|
pub impl ToJson for ExecutableCode with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("code", self.code)
.opt("id", self.id)
.opt("language", self.language)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ExecutableCode with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ExecutableCode with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
code: @sdkjson.opt_field(obj, "code", path),
id: @sdkjson.opt_field(obj, "id", path),
language: @sdkjson.opt_field(obj, "language", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartExecutableCodeMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartExecutableCodeMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartExecutableCodeMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartExecutableCodeMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartExecutableCodeMediaProcessing with fn to_json(self) {
let raw = match self {
PartExecutableCodeMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartExecutableCodeMediaProcessing::STATIC => "STATIC"
PartExecutableCodeMediaProcessing::AGENTIC => "AGENTIC"
PartExecutableCodeMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartExecutableCodeMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartExecutableCodeMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartExecutableCodeMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartExecutableCodeMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartExecutableCodeMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartExecutableCodeMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartExecutableCode.
#derive(Eq, @debug.Debug)
pub(all) struct PartExecutableCode {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
executable_code : ExecutableCode
media_processing : PartExecutableCodeMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartExecutableCode with Eq::{equal, not_equal}
///|
pub extend PartExecutableCode with @debug.Debug::{to_repr}
///|
///
/// Creates a PartExecutableCode with omitted optional fields absent.
pub fn PartExecutableCode::new(
executable_code~ : ExecutableCode,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartExecutableCodeMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartExecutableCode {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
executable_code,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartExecutableCode with ToJson::{to_json}
///|
pub impl ToJson for PartExecutableCode with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.field("executableCode", self.executable_code)
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartExecutableCode with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartExecutableCode with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
executable_code: required_field(obj, "executableCode", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Required. Outcome of the code execution. Enum values: OUTCOME_UNSPECIFIED: Unspecified status. This value should not be used.; OUTCOME_OK: Code execution completed successfully. `output` contains the stdout, if any.; OUTCOME_FAILED: Code execution failed. `output` contains the stderr and stdout, if any.; OUTCOME_DEADLINE_EXCEEDED: Code execution ran for too long, and was cancelled. There may or may not be a partial `output` present.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CodeExecutionResultOutcome {
OUTCOMEUNSPECIFIED
OUTCOMEOK
OUTCOMEFAILED
OUTCOMEDEADLINEEXCEEDED
Unknown(String)
}
///|
pub extend CodeExecutionResultOutcome with Eq::{equal, not_equal}
///|
pub extend CodeExecutionResultOutcome with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend CodeExecutionResultOutcome with ToJson::{to_json}
///|
pub impl ToJson for CodeExecutionResultOutcome with fn to_json(self) {
let raw = match self {
CodeExecutionResultOutcome::OUTCOMEUNSPECIFIED => "OUTCOME_UNSPECIFIED"
CodeExecutionResultOutcome::OUTCOMEOK => "OUTCOME_OK"
CodeExecutionResultOutcome::OUTCOMEFAILED => "OUTCOME_FAILED"
CodeExecutionResultOutcome::OUTCOMEDEADLINEEXCEEDED =>
"OUTCOME_DEADLINE_EXCEEDED"
CodeExecutionResultOutcome::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend CodeExecutionResultOutcome with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CodeExecutionResultOutcome with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"OUTCOME_UNSPECIFIED" =>
Option::Some(CodeExecutionResultOutcome::OUTCOMEUNSPECIFIED)
"OUTCOME_OK" => Option::Some(CodeExecutionResultOutcome::OUTCOMEOK)
"OUTCOME_FAILED" =>
Option::Some(CodeExecutionResultOutcome::OUTCOMEFAILED)
"OUTCOME_DEADLINE_EXCEEDED" =>
Option::Some(CodeExecutionResultOutcome::OUTCOMEDEADLINEEXCEEDED)
_ => Option::None
}
},
raw => CodeExecutionResultOutcome::Unknown(raw),
)
}
///|
///
/// Result of executing the `ExecutableCode`. Generated only when the `CodeExecution` tool is used.
#derive(Eq, @debug.Debug)
pub(all) struct CodeExecutionResult {
id : String?
outcome : CodeExecutionResultOutcome?
output : String?
}
///|
pub extend CodeExecutionResult with Eq::{equal, not_equal}
///|
pub extend CodeExecutionResult with @debug.Debug::{to_repr}
///|
///
/// Creates a CodeExecutionResult with omitted optional fields absent.
pub fn CodeExecutionResult::new(
id? : String,
outcome? : CodeExecutionResultOutcome,
output? : String,
) -> CodeExecutionResult {
{ id, outcome, output, }
}
///|
///
/// Encodes this value as JSON.
pub extend CodeExecutionResult with ToJson::{to_json}
///|
pub impl ToJson for CodeExecutionResult with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("id", self.id)
.opt("outcome", self.outcome)
.opt("output", self.output)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CodeExecutionResult with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CodeExecutionResult with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
id: @sdkjson.opt_field(obj, "id", path),
outcome: @sdkjson.opt_field(obj, "outcome", path),
output: @sdkjson.opt_field(obj, "output", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartCodeExecutionResultMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartCodeExecutionResultMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartCodeExecutionResultMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartCodeExecutionResultMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartCodeExecutionResultMediaProcessing with fn to_json(self) {
let raw = match self {
PartCodeExecutionResultMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartCodeExecutionResultMediaProcessing::STATIC => "STATIC"
PartCodeExecutionResultMediaProcessing::AGENTIC => "AGENTIC"
PartCodeExecutionResultMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartCodeExecutionResultMediaProcessing with @json.FromJson::{
from_json,
}
///|
pub impl @json.FromJson for PartCodeExecutionResultMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartCodeExecutionResultMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartCodeExecutionResultMediaProcessing::STATIC)
"AGENTIC" =>
Option::Some(PartCodeExecutionResultMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartCodeExecutionResultMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartCodeExecutionResult.
#derive(Eq, @debug.Debug)
pub(all) struct PartCodeExecutionResult {
speech_metadata : SpeechMetadata?
code_execution_result : CodeExecutionResult
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
media_processing : PartCodeExecutionResultMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartCodeExecutionResult with Eq::{equal, not_equal}
///|
pub extend PartCodeExecutionResult with @debug.Debug::{to_repr}
///|
///
/// Creates a PartCodeExecutionResult with omitted optional fields absent.
pub fn PartCodeExecutionResult::new(
code_execution_result~ : CodeExecutionResult,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartCodeExecutionResultMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartCodeExecutionResult {
{
speech_metadata,
code_execution_result,
thought,
thought_signature,
part_metadata,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartCodeExecutionResult with ToJson::{to_json}
///|
pub impl ToJson for PartCodeExecutionResult with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.field("codeExecutionResult", self.code_execution_result)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartCodeExecutionResult with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartCodeExecutionResult with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
code_execution_result: required_field(obj, "codeExecutionResult", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Required. The type of tool that was called. Enum values: TOOL_TYPE_UNSPECIFIED: Unspecified tool type.; GOOGLE_SEARCH_WEB: Google search tool, maps to Tool.google_search.search_types.web_search.; GOOGLE_SEARCH_IMAGE: Image search tool, maps to Tool.google_search.search_types.image_search.; URL_CONTEXT: URL context tool, maps to Tool.url_context.; GOOGLE_MAPS: Google maps tool, maps to Tool.google_maps.; FILE_SEARCH: File search tool, maps to Tool.file_search.; MEDIA_PROCESSING: Media processing tool types (e.g. video, audio, etc.), maps to invisible tools used for multimodal understanding like GOOGLE_UNDERSTANDING_VIDEO.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolCallToolType {
TOOLTYPEUNSPECIFIED
GOOGLESEARCHWEB
GOOGLESEARCHIMAGE
URLCONTEXT
GOOGLEMAPS
FILESEARCH
MEDIAPROCESSING
Unknown(String)
}
///|
pub extend ToolCallToolType with Eq::{equal, not_equal}
///|
pub extend ToolCallToolType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ToolCallToolType with ToJson::{to_json}
///|
pub impl ToJson for ToolCallToolType with fn to_json(self) {
let raw = match self {
ToolCallToolType::TOOLTYPEUNSPECIFIED => "TOOL_TYPE_UNSPECIFIED"
ToolCallToolType::GOOGLESEARCHWEB => "GOOGLE_SEARCH_WEB"
ToolCallToolType::GOOGLESEARCHIMAGE => "GOOGLE_SEARCH_IMAGE"
ToolCallToolType::URLCONTEXT => "URL_CONTEXT"
ToolCallToolType::GOOGLEMAPS => "GOOGLE_MAPS"
ToolCallToolType::FILESEARCH => "FILE_SEARCH"
ToolCallToolType::MEDIAPROCESSING => "MEDIA_PROCESSING"
ToolCallToolType::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ToolCallToolType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ToolCallToolType with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TOOL_TYPE_UNSPECIFIED" =>
Option::Some(ToolCallToolType::TOOLTYPEUNSPECIFIED)
"GOOGLE_SEARCH_WEB" => Option::Some(ToolCallToolType::GOOGLESEARCHWEB)
"GOOGLE_SEARCH_IMAGE" =>
Option::Some(ToolCallToolType::GOOGLESEARCHIMAGE)
"URL_CONTEXT" => Option::Some(ToolCallToolType::URLCONTEXT)
"GOOGLE_MAPS" => Option::Some(ToolCallToolType::GOOGLEMAPS)
"FILE_SEARCH" => Option::Some(ToolCallToolType::FILESEARCH)
"MEDIA_PROCESSING" => Option::Some(ToolCallToolType::MEDIAPROCESSING)
_ => Option::None
}
},
raw => ToolCallToolType::Unknown(raw),
)
}
///|
///
/// A predicted server-side `ToolCall` returned from the model. This message contains information about a tool that the model wants to invoke. The client is NOT expected to execute this `ToolCall`. Instead, the client should pass this `ToolCall` back to the API in a subsequent turn within a `Content` message, along with the corresponding `ToolResponse`.
#derive(Eq, @debug.Debug)
pub(all) struct ToolCall {
args : Map[String, Json]?
tool_name : String?
id : String?
tool_type : ToolCallToolType?
}
///|
pub extend ToolCall with Eq::{equal, not_equal}
///|
pub extend ToolCall with @debug.Debug::{to_repr}
///|
///
/// Creates a ToolCall with omitted optional fields absent.
pub fn ToolCall::new(
args? : Map[String, Json],
tool_name? : String,
id? : String,
tool_type? : ToolCallToolType,
) -> ToolCall {
{ args, tool_name, id, tool_type, }
}
///|
///
/// Encodes this value as JSON.
pub extend ToolCall with ToJson::{to_json}
///|
pub impl ToJson for ToolCall with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("args", self.args.map(value => json_map_to_json(value)))
.opt("toolName", self.tool_name)
.opt("id", self.id)
.opt("toolType", self.tool_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ToolCall with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ToolCall with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
args: decode_optional_json_map(obj, "args", path),
tool_name: @sdkjson.opt_field(obj, "toolName", path),
id: @sdkjson.opt_field(obj, "id", path),
tool_type: @sdkjson.opt_field(obj, "toolType", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartToolCallMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartToolCallMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartToolCallMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartToolCallMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartToolCallMediaProcessing with fn to_json(self) {
let raw = match self {
PartToolCallMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartToolCallMediaProcessing::STATIC => "STATIC"
PartToolCallMediaProcessing::AGENTIC => "AGENTIC"
PartToolCallMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartToolCallMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartToolCallMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(PartToolCallMediaProcessing::MEDIAPROCESSINGUNSPECIFIED)
"STATIC" => Option::Some(PartToolCallMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartToolCallMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartToolCallMediaProcessing::Unknown(raw),
)
}
///|
///
/// Generated representation of PartToolCall.
#derive(Eq, @debug.Debug)
pub(all) struct PartToolCall {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
tool_call : ToolCall
media_processing : PartToolCallMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartToolCall with Eq::{equal, not_equal}
///|
pub extend PartToolCall with @debug.Debug::{to_repr}
///|
///
/// Creates a PartToolCall with omitted optional fields absent.
pub fn PartToolCall::new(
tool_call~ : ToolCall,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartToolCallMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartToolCall {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
tool_call,
media_processing,
video_metadata,
audio_transcription,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartToolCall with ToJson::{to_json}
///|
pub impl ToJson for PartToolCall with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.field("toolCall", self.tool_call)
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartToolCall with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartToolCall with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
tool_call: required_field(obj, "toolCall", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PartToolResponseMediaProcessing {
MEDIAPROCESSINGUNSPECIFIED
STATIC
AGENTIC
Unknown(String)
}
///|
pub extend PartToolResponseMediaProcessing with Eq::{equal, not_equal}
///|
pub extend PartToolResponseMediaProcessing with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PartToolResponseMediaProcessing with ToJson::{to_json}
///|
pub impl ToJson for PartToolResponseMediaProcessing with fn to_json(self) {
let raw = match self {
PartToolResponseMediaProcessing::MEDIAPROCESSINGUNSPECIFIED =>
"MEDIA_PROCESSING_UNSPECIFIED"
PartToolResponseMediaProcessing::STATIC => "STATIC"
PartToolResponseMediaProcessing::AGENTIC => "AGENTIC"
PartToolResponseMediaProcessing::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PartToolResponseMediaProcessing with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartToolResponseMediaProcessing with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_PROCESSING_UNSPECIFIED" =>
Option::Some(
PartToolResponseMediaProcessing::MEDIAPROCESSINGUNSPECIFIED,
)
"STATIC" => Option::Some(PartToolResponseMediaProcessing::STATIC)
"AGENTIC" => Option::Some(PartToolResponseMediaProcessing::AGENTIC)
_ => Option::None
}
},
raw => PartToolResponseMediaProcessing::Unknown(raw),
)
}
///|
///
/// Required. The type of tool that was called, matching the `tool_type` in the corresponding `ToolCall`. Enum values: TOOL_TYPE_UNSPECIFIED: Unspecified tool type.; GOOGLE_SEARCH_WEB: Google search tool, maps to Tool.google_search.search_types.web_search.; GOOGLE_SEARCH_IMAGE: Image search tool, maps to Tool.google_search.search_types.image_search.; URL_CONTEXT: URL context tool, maps to Tool.url_context.; GOOGLE_MAPS: Google maps tool, maps to Tool.google_maps.; FILE_SEARCH: File search tool, maps to Tool.file_search.; MEDIA_PROCESSING: Media processing tool types (e.g. video, audio, etc.), maps to invisible tools used for multimodal understanding like GOOGLE_UNDERSTANDING_VIDEO.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ToolResponseToolType {
TOOLTYPEUNSPECIFIED
GOOGLESEARCHWEB
GOOGLESEARCHIMAGE
URLCONTEXT
GOOGLEMAPS
FILESEARCH
MEDIAPROCESSING
Unknown(String)
}
///|
pub extend ToolResponseToolType with Eq::{equal, not_equal}
///|
pub extend ToolResponseToolType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ToolResponseToolType with ToJson::{to_json}
///|
pub impl ToJson for ToolResponseToolType with fn to_json(self) {
let raw = match self {
ToolResponseToolType::TOOLTYPEUNSPECIFIED => "TOOL_TYPE_UNSPECIFIED"
ToolResponseToolType::GOOGLESEARCHWEB => "GOOGLE_SEARCH_WEB"
ToolResponseToolType::GOOGLESEARCHIMAGE => "GOOGLE_SEARCH_IMAGE"
ToolResponseToolType::URLCONTEXT => "URL_CONTEXT"
ToolResponseToolType::GOOGLEMAPS => "GOOGLE_MAPS"
ToolResponseToolType::FILESEARCH => "FILE_SEARCH"
ToolResponseToolType::MEDIAPROCESSING => "MEDIA_PROCESSING"
ToolResponseToolType::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ToolResponseToolType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ToolResponseToolType with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TOOL_TYPE_UNSPECIFIED" =>
Option::Some(ToolResponseToolType::TOOLTYPEUNSPECIFIED)
"GOOGLE_SEARCH_WEB" =>
Option::Some(ToolResponseToolType::GOOGLESEARCHWEB)
"GOOGLE_SEARCH_IMAGE" =>
Option::Some(ToolResponseToolType::GOOGLESEARCHIMAGE)
"URL_CONTEXT" => Option::Some(ToolResponseToolType::URLCONTEXT)
"GOOGLE_MAPS" => Option::Some(ToolResponseToolType::GOOGLEMAPS)
"FILE_SEARCH" => Option::Some(ToolResponseToolType::FILESEARCH)
"MEDIA_PROCESSING" =>
Option::Some(ToolResponseToolType::MEDIAPROCESSING)
_ => Option::None
}
},
raw => ToolResponseToolType::Unknown(raw),
)
}
///|
///
/// The output from a server-side `ToolCall` execution. This message contains the results of a tool invocation that was initiated by a `ToolCall` from the model. The client should pass this `ToolResponse` back to the API in a subsequent turn within a `Content` message, along with the corresponding `ToolCall`.
#derive(Eq, @debug.Debug)
pub(all) struct ToolResponse {
response : Map[String, Json]?
id : String?
tool_type : ToolResponseToolType?
}
///|
pub extend ToolResponse with Eq::{equal, not_equal}
///|
pub extend ToolResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a ToolResponse with omitted optional fields absent.
pub fn ToolResponse::new(
response? : Map[String, Json],
id? : String,
tool_type? : ToolResponseToolType,
) -> ToolResponse {
{ response, id, tool_type, }
}
///|
///
/// Encodes this value as JSON.
pub extend ToolResponse with ToJson::{to_json}
///|
pub impl ToJson for ToolResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("response", self.response.map(value => json_map_to_json(value)))
.opt("id", self.id)
.opt("toolType", self.tool_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ToolResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ToolResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
response: decode_optional_json_map(obj, "response", path),
id: @sdkjson.opt_field(obj, "id", path),
tool_type: @sdkjson.opt_field(obj, "toolType", path),
}
}
///|
///
/// Generated representation of PartToolResponse.
#derive(Eq, @debug.Debug)
pub(all) struct PartToolResponse {
speech_metadata : SpeechMetadata?
thought : Bool?
thought_signature : String?
part_metadata : Map[String, Json]?
media_processing : PartToolResponseMediaProcessing?
video_metadata : VideoMetadata?
audio_transcription : AudioTranscription?
tool_response : ToolResponse
media_resolution : V1mainMediaResolution?
}
///|
pub extend PartToolResponse with Eq::{equal, not_equal}
///|
pub extend PartToolResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a PartToolResponse with omitted optional fields absent.
pub fn PartToolResponse::new(
tool_response~ : ToolResponse,
speech_metadata? : SpeechMetadata,
thought? : Bool,
thought_signature? : String,
part_metadata? : Map[String, Json],
media_processing? : PartToolResponseMediaProcessing,
video_metadata? : VideoMetadata,
audio_transcription? : AudioTranscription,
media_resolution? : V1mainMediaResolution,
) -> PartToolResponse {
{
speech_metadata,
thought,
thought_signature,
part_metadata,
media_processing,
video_metadata,
audio_transcription,
tool_response,
media_resolution,
}
}
///|
///
/// Encodes this value as JSON.
pub extend PartToolResponse with ToJson::{to_json}
///|
pub impl ToJson for PartToolResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("speechMetadata", self.speech_metadata)
.opt("thought", self.thought)
.opt("thoughtSignature", self.thought_signature)
.opt("partMetadata", self.part_metadata.map(value => json_map_to_json(value)))
.opt("mediaProcessing", self.media_processing)
.opt("videoMetadata", self.video_metadata)
.opt("audioTranscription", self.audio_transcription)
.field("toolResponse", self.tool_response)
.opt("mediaResolution", self.media_resolution)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PartToolResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PartToolResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
speech_metadata: @sdkjson.opt_field(obj, "speechMetadata", path),
thought: @sdkjson.opt_field(obj, "thought", path),
thought_signature: @sdkjson.opt_field(obj, "thoughtSignature", path),
part_metadata: decode_optional_json_map(obj, "partMetadata", path),
media_processing: @sdkjson.opt_field(obj, "mediaProcessing", path),
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
audio_transcription: @sdkjson.opt_field(obj, "audioTranscription", path),
tool_response: required_field(obj, "toolResponse", path),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
}
}
///|
///
/// A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes.
#derive(Eq, @debug.Debug)
pub(all) enum Part {
Text(PartText)
InlineData(PartInlineData)
FileData(PartFileData)
FunctionCall(PartFunctionCall)
FunctionResponse(PartFunctionResponse)
ExecutableCode(PartExecutableCode)
CodeExecutionResult(PartCodeExecutionResult)
ToolCall(PartToolCall)
ToolResponse(PartToolResponse)
}
///|
pub extend Part with Eq::{equal, not_equal}
///|
pub extend Part with @debug.Debug::{to_repr}
///|
pub extend Part with ToJson::{to_json}
///|
pub impl ToJson for Part with fn to_json(self) {
match self {
Part::Text(payload) => @json.Json::Json(payload)
Part::InlineData(payload) => @json.Json::Json(payload)
Part::FileData(payload) => @json.Json::Json(payload)
Part::FunctionCall(payload) => @json.Json::Json(payload)
Part::FunctionResponse(payload) => @json.Json::Json(payload)
Part::ExecutableCode(payload) => @json.Json::Json(payload)
Part::CodeExecutionResult(payload) => @json.Json::Json(payload)
Part::ToolCall(payload) => @json.Json::Json(payload)
Part::ToolResponse(payload) => @json.Json::Json(payload)
}
}
///|
pub extend Part with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Part with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
let mut count = 0
if obj.contains("text") {
count += 1
}
if obj.contains("inlineData") {
count += 1
}
if obj.contains("fileData") {
count += 1
}
if obj.contains("functionCall") {
count += 1
}
if obj.contains("functionResponse") {
count += 1
}
if obj.contains("executableCode") {
count += 1
}
if obj.contains("codeExecutionResult") {
count += 1
}
if obj.contains("toolCall") {
count += 1
}
if obj.contains("toolResponse") {
count += 1
}
if count != 1 {
raise @json.JsonDecodeError::JsonDecodeError(
(path, "expected exactly one data field"),
)
}
if obj.contains("text") {
return Part::Text(@json.from_json(value, path~))
}
if obj.contains("inlineData") {
return Part::InlineData(@json.from_json(value, path~))
}
if obj.contains("fileData") {
return Part::FileData(@json.from_json(value, path~))
}
if obj.contains("functionCall") {
return Part::FunctionCall(@json.from_json(value, path~))
}
if obj.contains("functionResponse") {
return Part::FunctionResponse(@json.from_json(value, path~))
}
if obj.contains("executableCode") {
return Part::ExecutableCode(@json.from_json(value, path~))
}
if obj.contains("codeExecutionResult") {
return Part::CodeExecutionResult(@json.from_json(value, path~))
}
if obj.contains("toolCall") {
return Part::ToolCall(@json.from_json(value, path~))
}
if obj.contains("toolResponse") {
return Part::ToolResponse(@json.from_json(value, path~))
}
raise @json.JsonDecodeError::JsonDecodeError((path, "missing data field"))
}
///|
///
/// The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn.
#derive(Eq, @debug.Debug)
pub(all) struct Content {
parts : Array[Part]?
role : String?
}
///|
pub extend Content with Eq::{equal, not_equal}
///|
pub extend Content with @debug.Debug::{to_repr}
///|
///
/// Creates a Content with omitted optional fields absent.
pub fn Content::new(parts? : Array[Part], role? : String) -> Content {
{ parts, role, }
}
///|
///
/// Encodes this value as JSON.
pub extend Content with ToJson::{to_json}
///|
pub impl ToJson for Content with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("parts", self.parts)
.opt("role", self.role)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Content with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Content with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
parts: @sdkjson.opt_field(obj, "parts", path),
role: @sdkjson.opt_field(obj, "role", path),
}
}
///|
///
/// An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
#derive(Eq, @debug.Debug)
pub(all) struct LatLng {
longitude : Double?
latitude : Double?
}
///|
pub extend LatLng with Eq::{equal, not_equal}
///|
pub extend LatLng with @debug.Debug::{to_repr}
///|
///
/// Creates a LatLng with omitted optional fields absent.
pub fn LatLng::new(longitude? : Double, latitude? : Double) -> LatLng {
{ longitude, latitude, }
}
///|
///
/// Encodes this value as JSON.
pub extend LatLng with ToJson::{to_json}
///|
pub impl ToJson for LatLng with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("longitude", self.longitude)
.opt("latitude", self.latitude)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend LatLng with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for LatLng with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
longitude: @sdkjson.opt_field(obj, "longitude", path),
latitude: @sdkjson.opt_field(obj, "latitude", path),
}
}
///|
///
/// Retrieval config.
#derive(Eq, @debug.Debug)
pub(all) struct RetrievalConfig {
language_code : String?
lat_lng : LatLng?
}
///|
pub extend RetrievalConfig with Eq::{equal, not_equal}
///|
pub extend RetrievalConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a RetrievalConfig with omitted optional fields absent.
pub fn RetrievalConfig::new(
language_code? : String,
lat_lng? : LatLng,
) -> RetrievalConfig {
{ language_code, lat_lng, }
}
///|
///
/// Encodes this value as JSON.
pub extend RetrievalConfig with ToJson::{to_json}
///|
pub impl ToJson for RetrievalConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("languageCode", self.language_code)
.opt("latLng", self.lat_lng)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend RetrievalConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for RetrievalConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
language_code: @sdkjson.opt_field(obj, "languageCode", path),
lat_lng: @sdkjson.opt_field(obj, "latLng", path),
}
}
///|
///
/// The Tool configuration containing parameters for specifying `Tool` use in the request.
#derive(Eq, @debug.Debug)
pub(all) struct ToolConfig {
retrieval_config : RetrievalConfig?
function_calling_config : FunctionCallingConfig?
include_server_side_tool_invocations : Bool?
}
///|
pub extend ToolConfig with Eq::{equal, not_equal}
///|
pub extend ToolConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a ToolConfig with omitted optional fields absent.
pub fn ToolConfig::new(
retrieval_config? : RetrievalConfig,
function_calling_config? : FunctionCallingConfig,
include_server_side_tool_invocations? : Bool,
) -> ToolConfig {
{
retrieval_config,
function_calling_config,
include_server_side_tool_invocations,
}
}
///|
///
/// Encodes this value as JSON.
pub extend ToolConfig with ToJson::{to_json}
///|
pub impl ToJson for ToolConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("retrievalConfig", self.retrieval_config)
.opt("functionCallingConfig", self.function_calling_config)
.opt(
"includeServerSideToolInvocations",
self.include_server_side_tool_invocations,
)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ToolConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ToolConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
retrieval_config: @sdkjson.opt_field(obj, "retrievalConfig", path),
function_calling_config: @sdkjson.opt_field(
obj, "functionCallingConfig", path,
),
include_server_side_tool_invocations: @sdkjson.opt_field(
obj, "includeServerSideToolInvocations", path,
),
}
}
///|
///
/// Enum values: MODALITY_UNSPECIFIED: Default value.; TEXT: Indicates the model should return text.; IMAGE: Indicates the model should return images.; AUDIO: Indicates the model should return audio.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum GenerationConfigResponseModalitiesItem {
MODALITYUNSPECIFIED
TEXT
IMAGE
AUDIO
Custom(String)
}
///|
pub extend GenerationConfigResponseModalitiesItem with Eq::{equal, not_equal}
///|
pub extend GenerationConfigResponseModalitiesItem with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend GenerationConfigResponseModalitiesItem with ToJson::{to_json}
///|
pub impl ToJson for GenerationConfigResponseModalitiesItem with fn to_json(self) {
let raw = match self {
GenerationConfigResponseModalitiesItem::MODALITYUNSPECIFIED =>
"MODALITY_UNSPECIFIED"
GenerationConfigResponseModalitiesItem::TEXT => "TEXT"
GenerationConfigResponseModalitiesItem::IMAGE => "IMAGE"
GenerationConfigResponseModalitiesItem::AUDIO => "AUDIO"
GenerationConfigResponseModalitiesItem::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend GenerationConfigResponseModalitiesItem with @json.FromJson::{
from_json,
}
///|
pub impl @json.FromJson for GenerationConfigResponseModalitiesItem with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODALITY_UNSPECIFIED" =>
Option::Some(
GenerationConfigResponseModalitiesItem::MODALITYUNSPECIFIED,
)
"TEXT" => Option::Some(GenerationConfigResponseModalitiesItem::TEXT)
"IMAGE" => Option::Some(GenerationConfigResponseModalitiesItem::IMAGE)
"AUDIO" => Option::Some(GenerationConfigResponseModalitiesItem::AUDIO)
_ => Option::None
}
},
raw => GenerationConfigResponseModalitiesItem::Custom(raw),
)
}
///|
///
/// Config for image generation features.
#derive(Eq, @debug.Debug)
pub(all) struct ImageConfig {
aspect_ratio : String?
image_size : String?
}
///|
pub extend ImageConfig with Eq::{equal, not_equal}
///|
pub extend ImageConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a ImageConfig with omitted optional fields absent.
pub fn ImageConfig::new(
aspect_ratio? : String,
image_size? : String,
) -> ImageConfig {
{ aspect_ratio, image_size, }
}
///|
///
/// Encodes this value as JSON.
pub extend ImageConfig with ToJson::{to_json}
///|
pub impl ToJson for ImageConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("aspectRatio", self.aspect_ratio)
.opt("imageSize", self.image_size)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ImageConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ImageConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
aspect_ratio: @sdkjson.opt_field(obj, "aspectRatio", path),
image_size: @sdkjson.opt_field(obj, "imageSize", path),
}
}
///|
///
/// Optional. If specified, the media resolution specified will be used. Enum values: MEDIA_RESOLUTION_UNSPECIFIED: Media resolution has not been set.; MEDIA_RESOLUTION_LOW: Media resolution set to low (64 tokens).; MEDIA_RESOLUTION_MEDIUM: Media resolution set to medium (256 tokens).; MEDIA_RESOLUTION_HIGH: Media resolution set to high (zoomed reframing with 256 tokens).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum GenerationConfigMediaResolution {
MEDIARESOLUTIONUNSPECIFIED
MEDIARESOLUTIONLOW
MEDIARESOLUTIONMEDIUM
MEDIARESOLUTIONHIGH
Custom(String)
}
///|
pub extend GenerationConfigMediaResolution with Eq::{equal, not_equal}
///|
pub extend GenerationConfigMediaResolution with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend GenerationConfigMediaResolution with ToJson::{to_json}
///|
pub impl ToJson for GenerationConfigMediaResolution with fn to_json(self) {
let raw = match self {
GenerationConfigMediaResolution::MEDIARESOLUTIONUNSPECIFIED =>
"MEDIA_RESOLUTION_UNSPECIFIED"
GenerationConfigMediaResolution::MEDIARESOLUTIONLOW =>
"MEDIA_RESOLUTION_LOW"
GenerationConfigMediaResolution::MEDIARESOLUTIONMEDIUM =>
"MEDIA_RESOLUTION_MEDIUM"
GenerationConfigMediaResolution::MEDIARESOLUTIONHIGH =>
"MEDIA_RESOLUTION_HIGH"
GenerationConfigMediaResolution::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend GenerationConfigMediaResolution with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GenerationConfigMediaResolution with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MEDIA_RESOLUTION_UNSPECIFIED" =>
Option::Some(
GenerationConfigMediaResolution::MEDIARESOLUTIONUNSPECIFIED,
)
"MEDIA_RESOLUTION_LOW" =>
Option::Some(GenerationConfigMediaResolution::MEDIARESOLUTIONLOW)
"MEDIA_RESOLUTION_MEDIUM" =>
Option::Some(GenerationConfigMediaResolution::MEDIARESOLUTIONMEDIUM)
"MEDIA_RESOLUTION_HIGH" =>
Option::Some(GenerationConfigMediaResolution::MEDIARESOLUTIONHIGH)
_ => Option::None
}
},
raw => GenerationConfigMediaResolution::Custom(raw),
)
}
///|
///
/// Required. Data type. Enum values: TYPE_UNSPECIFIED: Not specified, should not be used.; STRING: String type.; NUMBER: Number type.; INTEGER: Integer type.; BOOLEAN: Boolean type.; ARRAY: Array type.; OBJECT: Object type.; NULL: Null type.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SchemaType {
TYPEUNSPECIFIED
STRING
NUMBER
INTEGER
BOOLEAN
ARRAY
OBJECT
NULL
Unknown(String)
}
///|
pub extend SchemaType with Eq::{equal, not_equal}
///|
pub extend SchemaType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SchemaType with ToJson::{to_json}
///|
pub impl ToJson for SchemaType with fn to_json(self) {
let raw = match self {
SchemaType::TYPEUNSPECIFIED => "TYPE_UNSPECIFIED"
SchemaType::STRING => "STRING"
SchemaType::NUMBER => "NUMBER"
SchemaType::INTEGER => "INTEGER"
SchemaType::BOOLEAN => "BOOLEAN"
SchemaType::ARRAY => "ARRAY"
SchemaType::OBJECT => "OBJECT"
SchemaType::NULL => "NULL"
SchemaType::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SchemaType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SchemaType with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TYPE_UNSPECIFIED" => Option::Some(SchemaType::TYPEUNSPECIFIED)
"STRING" => Option::Some(SchemaType::STRING)
"NUMBER" => Option::Some(SchemaType::NUMBER)
"INTEGER" => Option::Some(SchemaType::INTEGER)
"BOOLEAN" => Option::Some(SchemaType::BOOLEAN)
"ARRAY" => Option::Some(SchemaType::ARRAY)
"OBJECT" => Option::Some(SchemaType::OBJECT)
"NULL" => Option::Some(SchemaType::NULL)
_ => Option::None
}
},
raw => SchemaType::Unknown(raw),
)
}
///|
///
/// The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema).
#derive(Eq, @debug.Debug)
pub(all) struct Schema {
min_items : Int64?
enum_ : Array[String]?
max_properties : Int64?
title : String?
nullable : Bool?
default : Json?
maximum : Double?
max_items : Int64?
min_length : Int64?
max_length : Int64?
properties : Map[String, Schema]?
minimum : Double?
type_ : SchemaType?
format : String?
min_properties : Int64?
any_of : Array[Schema]?
pattern : String?
items : Schema?
required : Array[String]?
property_ordering : Array[String]?
description : String?
example : Json?
}
///|
pub extend Schema with Eq::{equal, not_equal}
///|
pub extend Schema with @debug.Debug::{to_repr}
///|
///
/// Creates a Schema with omitted optional fields absent.
pub fn Schema::new(
min_items? : Int64,
enum_? : Array[String],
max_properties? : Int64,
title? : String,
nullable? : Bool,
default? : Json,
maximum? : Double,
max_items? : Int64,
min_length? : Int64,
max_length? : Int64,
properties? : Map[String, Schema],
minimum? : Double,
type_? : SchemaType,
format? : String,
min_properties? : Int64,
any_of? : Array[Schema],
pattern? : String,
items? : Schema,
required? : Array[String],
property_ordering? : Array[String],
description? : String,
example? : Json,
) -> Schema {
{
min_items,
enum_,
max_properties,
title,
nullable,
default,
maximum,
max_items,
min_length,
max_length,
properties,
minimum,
type_,
format,
min_properties,
any_of,
pattern,
items,
required,
property_ordering,
description,
example,
}
}
///|
///
/// Encodes this value as JSON.
pub extend Schema with ToJson::{to_json}
///|
pub impl ToJson for Schema with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt(
"minItems",
self.min_items.map(value => json_string_int64_to_json(value)),
)
.opt("enum", self.enum_)
.opt(
"maxProperties",
self.max_properties.map(value => json_string_int64_to_json(value)),
)
.opt("title", self.title)
.opt("nullable", self.nullable)
.opt("default", self.default)
.opt("maximum", self.maximum)
.opt(
"maxItems",
self.max_items.map(value => json_string_int64_to_json(value)),
)
.opt(
"minLength",
self.min_length.map(value => json_string_int64_to_json(value)),
)
.opt(
"maxLength",
self.max_length.map(value => json_string_int64_to_json(value)),
)
.opt("properties", self.properties.map(value => json_map_to_json(value)))
.opt("minimum", self.minimum)
.opt("type", self.type_)
.opt("format", self.format)
.opt(
"minProperties",
self.min_properties.map(value => json_string_int64_to_json(value)),
)
.opt("anyOf", self.any_of)
.opt("pattern", self.pattern)
.opt("items", self.items)
.opt("required", self.required)
.opt("propertyOrdering", self.property_ordering)
.opt("description", self.description)
.opt("example", self.example)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Schema with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Schema with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
min_items: decode_optional_custom(obj, "minItems", path, (value, value_path) => {
json_string_int64(value, value_path)
}),
enum_: @sdkjson.opt_field(obj, "enum", path),
max_properties: decode_optional_custom(obj, "maxProperties", path, (
value,
value_path,
) => json_string_int64(value, value_path)),
title: @sdkjson.opt_field(obj, "title", path),
nullable: @sdkjson.opt_field(obj, "nullable", path),
default: @sdkjson.opt_field(obj, "default", path),
maximum: @sdkjson.opt_field(obj, "maximum", path),
max_items: decode_optional_custom(obj, "maxItems", path, (value, value_path) => {
json_string_int64(value, value_path)
}),
min_length: decode_optional_custom(obj, "minLength", path, (
value,
value_path,
) => json_string_int64(value, value_path)),
max_length: decode_optional_custom(obj, "maxLength", path, (
value,
value_path,
) => json_string_int64(value, value_path)),
properties: decode_optional_json_map(obj, "properties", path),
minimum: @sdkjson.opt_field(obj, "minimum", path),
type_: @sdkjson.opt_field(obj, "type", path),
format: @sdkjson.opt_field(obj, "format", path),
min_properties: decode_optional_custom(obj, "minProperties", path, (
value,
value_path,
) => json_string_int64(value, value_path)),
any_of: @sdkjson.opt_field(obj, "anyOf", path),
pattern: @sdkjson.opt_field(obj, "pattern", path),
items: @sdkjson.opt_field(obj, "items", path),
required: @sdkjson.opt_field(obj, "required", path),
property_ordering: @sdkjson.opt_field(obj, "propertyOrdering", path),
description: @sdkjson.opt_field(obj, "description", path),
example: @sdkjson.opt_field(obj, "example", path),
}
}
///|
///
/// Config for translation features.
#derive(Eq, @debug.Debug)
pub(all) struct TranslationConfig {
echo_target_language : Bool?
target_language_code : String?
}
///|
pub extend TranslationConfig with Eq::{equal, not_equal}
///|
pub extend TranslationConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a TranslationConfig with omitted optional fields absent.
pub fn TranslationConfig::new(
echo_target_language? : Bool,
target_language_code? : String,
) -> TranslationConfig {
{ echo_target_language, target_language_code, }
}
///|
///
/// Encodes this value as JSON.
pub extend TranslationConfig with ToJson::{to_json}
///|
pub impl ToJson for TranslationConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("echoTargetLanguage", self.echo_target_language)
.opt("targetLanguageCode", self.target_language_code)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend TranslationConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for TranslationConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
echo_target_language: @sdkjson.opt_field(obj, "echoTargetLanguage", path),
target_language_code: @sdkjson.opt_field(obj, "targetLanguageCode", path),
}
}
///|
///
/// Optional. Controls the maximum depth of the model's internal reasoning process before it produces a response. The default value is model-dependent. Refer to the [Thinking levels guide](https://aistudio.google.com/docs/thinking#thinking-levels) for more details. Recommended for Gemini 3 or later models. Use with earlier models results in an error. Enum values: THINKING_LEVEL_UNSPECIFIED: Default value.; MINIMAL: Little to no thinking.; LOW: Low thinking level.; MEDIUM: Medium thinking level.; HIGH: High thinking level.; XHIGH: XHigh thinking level.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ThinkingConfigThinkingLevel {
THINKINGLEVELUNSPECIFIED
MINIMAL
LOW
MEDIUM
HIGH
XHIGH
Custom(String)
}
///|
pub extend ThinkingConfigThinkingLevel with Eq::{equal, not_equal}
///|
pub extend ThinkingConfigThinkingLevel with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ThinkingConfigThinkingLevel with ToJson::{to_json}
///|
pub impl ToJson for ThinkingConfigThinkingLevel with fn to_json(self) {
let raw = match self {
ThinkingConfigThinkingLevel::THINKINGLEVELUNSPECIFIED =>
"THINKING_LEVEL_UNSPECIFIED"
ThinkingConfigThinkingLevel::MINIMAL => "MINIMAL"
ThinkingConfigThinkingLevel::LOW => "LOW"
ThinkingConfigThinkingLevel::MEDIUM => "MEDIUM"
ThinkingConfigThinkingLevel::HIGH => "HIGH"
ThinkingConfigThinkingLevel::XHIGH => "XHIGH"
ThinkingConfigThinkingLevel::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ThinkingConfigThinkingLevel with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ThinkingConfigThinkingLevel with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"THINKING_LEVEL_UNSPECIFIED" =>
Option::Some(ThinkingConfigThinkingLevel::THINKINGLEVELUNSPECIFIED)
"MINIMAL" => Option::Some(ThinkingConfigThinkingLevel::MINIMAL)
"LOW" => Option::Some(ThinkingConfigThinkingLevel::LOW)
"MEDIUM" => Option::Some(ThinkingConfigThinkingLevel::MEDIUM)
"HIGH" => Option::Some(ThinkingConfigThinkingLevel::HIGH)
"XHIGH" => Option::Some(ThinkingConfigThinkingLevel::XHIGH)
_ => Option::None
}
},
raw => ThinkingConfigThinkingLevel::Custom(raw),
)
}
///|
///
/// Config for thinking features.
#derive(Eq, @debug.Debug)
pub(all) struct ThinkingConfig {
include_thoughts : Bool?
thinking_budget : Int32?
thinking_level : ThinkingConfigThinkingLevel?
}
///|
pub extend ThinkingConfig with Eq::{equal, not_equal}
///|
pub extend ThinkingConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a ThinkingConfig with omitted optional fields absent.
pub fn ThinkingConfig::new(
include_thoughts? : Bool,
thinking_budget? : Int32,
thinking_level? : ThinkingConfigThinkingLevel,
) -> ThinkingConfig {
{ include_thoughts, thinking_budget, thinking_level, }
}
///|
///
/// Encodes this value as JSON.
pub extend ThinkingConfig with ToJson::{to_json}
///|
pub impl ToJson for ThinkingConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("includeThoughts", self.include_thoughts)
.opt("thinkingBudget", self.thinking_budget)
.opt("thinkingLevel", self.thinking_level)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ThinkingConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ThinkingConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
include_thoughts: @sdkjson.opt_field(obj, "includeThoughts", path),
thinking_budget: @sdkjson.opt_field(obj, "thinkingBudget", path),
thinking_level: @sdkjson.opt_field(obj, "thinkingLevel", path),
}
}
///|
///
/// Configuration options for model generation and outputs. Not all parameters are configurable for every model.
#derive(Eq, @debug.Debug)
pub(all) struct GenerationConfig {
stop_sequences : Array[String]?
speech_config : SpeechConfig?
logprobs : Int32?
response_json_schema : Json?
audio_transcription_config : AudioTranscriptionConfig?
seed : Int32?
response_modalities : Array[GenerationConfigResponseModalitiesItem]?
frequency_penalty : Double?
image_config : ImageConfig?
response_json_schema_2 : Json?
response_logprobs : Bool?
candidate_count : Int32?
response_format : ResponseFormatConfig?
enable_enhanced_civic_answers : Bool?
media_resolution : GenerationConfigMediaResolution?
top_p : Double?
response_schema : Schema?
translation_config : TranslationConfig?
top_k : Int32?
max_output_tokens : Int32?
response_mime_type : String?
temperature : Double?
presence_penalty : Double?
thinking_config : ThinkingConfig?
enable_affective_dialog : Bool?
}
///|
pub extend GenerationConfig with Eq::{equal, not_equal}
///|
pub extend GenerationConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a GenerationConfig with omitted optional fields absent.
pub fn GenerationConfig::new(
stop_sequences? : Array[String],
speech_config? : SpeechConfig,
logprobs? : Int32,
response_json_schema? : Json,
audio_transcription_config? : AudioTranscriptionConfig,
seed? : Int32,
response_modalities? : Array[GenerationConfigResponseModalitiesItem],
frequency_penalty? : Double,
image_config? : ImageConfig,
response_json_schema_2? : Json,
response_logprobs? : Bool,
candidate_count? : Int32,
response_format? : ResponseFormatConfig,
enable_enhanced_civic_answers? : Bool,
media_resolution? : GenerationConfigMediaResolution,
top_p? : Double,
response_schema? : Schema,
translation_config? : TranslationConfig,
top_k? : Int32,
max_output_tokens? : Int32,
response_mime_type? : String,
temperature? : Double,
presence_penalty? : Double,
thinking_config? : ThinkingConfig,
enable_affective_dialog? : Bool,
) -> GenerationConfig {
{
stop_sequences,
speech_config,
logprobs,
response_json_schema,
audio_transcription_config,
seed,
response_modalities,
frequency_penalty,
image_config,
response_json_schema_2,
response_logprobs,
candidate_count,
response_format,
enable_enhanced_civic_answers,
media_resolution,
top_p,
response_schema,
translation_config,
top_k,
max_output_tokens,
response_mime_type,
temperature,
presence_penalty,
thinking_config,
enable_affective_dialog,
}
}
///|
///
/// Encodes this value as JSON.
pub extend GenerationConfig with ToJson::{to_json}
///|
pub impl ToJson for GenerationConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("stopSequences", self.stop_sequences)
.opt("speechConfig", self.speech_config)
.opt("logprobs", self.logprobs)
.opt("responseJsonSchema", self.response_json_schema)
.opt("audioTranscriptionConfig", self.audio_transcription_config)
.opt("seed", self.seed)
.opt("responseModalities", self.response_modalities)
.opt("frequencyPenalty", self.frequency_penalty)
.opt("imageConfig", self.image_config)
.opt("_responseJsonSchema", self.response_json_schema_2)
.opt("responseLogprobs", self.response_logprobs)
.opt("candidateCount", self.candidate_count)
.opt("responseFormat", self.response_format)
.opt("enableEnhancedCivicAnswers", self.enable_enhanced_civic_answers)
.opt("mediaResolution", self.media_resolution)
.opt("topP", self.top_p)
.opt("responseSchema", self.response_schema)
.opt("translationConfig", self.translation_config)
.opt("topK", self.top_k)
.opt("maxOutputTokens", self.max_output_tokens)
.opt("responseMimeType", self.response_mime_type)
.opt("temperature", self.temperature)
.opt("presencePenalty", self.presence_penalty)
.opt("thinkingConfig", self.thinking_config)
.opt("enableAffectiveDialog", self.enable_affective_dialog)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GenerationConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GenerationConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
stop_sequences: @sdkjson.opt_field(obj, "stopSequences", path),
speech_config: @sdkjson.opt_field(obj, "speechConfig", path),
logprobs: @sdkjson.opt_field(obj, "logprobs", path),
response_json_schema: @sdkjson.opt_field(obj, "responseJsonSchema", path),
audio_transcription_config: @sdkjson.opt_field(
obj, "audioTranscriptionConfig", path,
),
seed: @sdkjson.opt_field(obj, "seed", path),
response_modalities: @sdkjson.opt_field(obj, "responseModalities", path),
frequency_penalty: @sdkjson.opt_field(obj, "frequencyPenalty", path),
image_config: @sdkjson.opt_field(obj, "imageConfig", path),
response_json_schema_2: @sdkjson.opt_field(obj, "_responseJsonSchema", path),
response_logprobs: @sdkjson.opt_field(obj, "responseLogprobs", path),
candidate_count: @sdkjson.opt_field(obj, "candidateCount", path),
response_format: @sdkjson.opt_field(obj, "responseFormat", path),
enable_enhanced_civic_answers: @sdkjson.opt_field(
obj, "enableEnhancedCivicAnswers", path,
),
media_resolution: @sdkjson.opt_field(obj, "mediaResolution", path),
top_p: @sdkjson.opt_field(obj, "topP", path),
response_schema: @sdkjson.opt_field(obj, "responseSchema", path),
translation_config: @sdkjson.opt_field(obj, "translationConfig", path),
top_k: @sdkjson.opt_field(obj, "topK", path),
max_output_tokens: @sdkjson.opt_field(obj, "maxOutputTokens", path),
response_mime_type: @sdkjson.opt_field(obj, "responseMimeType", path),
temperature: @sdkjson.opt_field(obj, "temperature", path),
presence_penalty: @sdkjson.opt_field(obj, "presencePenalty", path),
thinking_config: @sdkjson.opt_field(obj, "thinkingConfig", path),
enable_affective_dialog: @sdkjson.opt_field(
obj, "enableAffectiveDialog", path,
),
}
}
///|
///
/// Required. The category for this setting. Enum values: HARM_CATEGORY_UNSPECIFIED: Category is unspecified.; HARM_CATEGORY_DEROGATORY: **PaLM** - Negative or harmful comments targeting identity and/or protected attribute. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_TOXICITY: **PaLM** - Content that is rude, disrespectful, or profane. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_VIOLENCE: **PaLM** - Describes scenarios depicting violence against an individual or group, or general descriptions of gore. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_SEXUAL: **PaLM** - Contains references to sexual acts or other lewd content. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_MEDICAL: **PaLM** - Promotes unchecked medical advice. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_DANGEROUS: **PaLM** - Dangerous content that promotes, facilitates, or encourages harmful acts. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_HARASSMENT: **Gemini** - Harassment content.; HARM_CATEGORY_HATE_SPEECH: **Gemini** - Hate speech and content.; HARM_CATEGORY_SEXUALLY_EXPLICIT: **Gemini** - Sexually explicit content.; HARM_CATEGORY_DANGEROUS_CONTENT: **Gemini** - Dangerous content.; HARM_CATEGORY_CIVIC_INTEGRITY: **Gemini** - Content that may be used to harm civic integrity. DEPRECATED: use enable_enhanced_civic_answers instead.; HARM_CATEGORY_JAILBREAK: **Gemini** - Prompts attempting to bypass or subvert the model's safety guidelines (jailbreak attempts).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SafetySettingCategory {
HARMCATEGORYUNSPECIFIED
HARMCATEGORYDEROGATORY
HARMCATEGORYTOXICITY
HARMCATEGORYVIOLENCE
HARMCATEGORYSEXUAL
HARMCATEGORYMEDICAL
HARMCATEGORYDANGEROUS
HARMCATEGORYHARASSMENT
HARMCATEGORYHATESPEECH
HARMCATEGORYSEXUALLYEXPLICIT
HARMCATEGORYDANGEROUSCONTENT
HARMCATEGORYCIVICINTEGRITY
HARMCATEGORYJAILBREAK
Custom(String)
}
///|
pub extend SafetySettingCategory with Eq::{equal, not_equal}
///|
pub extend SafetySettingCategory with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SafetySettingCategory with ToJson::{to_json}
///|
pub impl ToJson for SafetySettingCategory with fn to_json(self) {
let raw = match self {
SafetySettingCategory::HARMCATEGORYUNSPECIFIED =>
"HARM_CATEGORY_UNSPECIFIED"
SafetySettingCategory::HARMCATEGORYDEROGATORY => "HARM_CATEGORY_DEROGATORY"
SafetySettingCategory::HARMCATEGORYTOXICITY => "HARM_CATEGORY_TOXICITY"
SafetySettingCategory::HARMCATEGORYVIOLENCE => "HARM_CATEGORY_VIOLENCE"
SafetySettingCategory::HARMCATEGORYSEXUAL => "HARM_CATEGORY_SEXUAL"
SafetySettingCategory::HARMCATEGORYMEDICAL => "HARM_CATEGORY_MEDICAL"
SafetySettingCategory::HARMCATEGORYDANGEROUS => "HARM_CATEGORY_DANGEROUS"
SafetySettingCategory::HARMCATEGORYHARASSMENT => "HARM_CATEGORY_HARASSMENT"
SafetySettingCategory::HARMCATEGORYHATESPEECH => "HARM_CATEGORY_HATE_SPEECH"
SafetySettingCategory::HARMCATEGORYSEXUALLYEXPLICIT =>
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
SafetySettingCategory::HARMCATEGORYDANGEROUSCONTENT =>
"HARM_CATEGORY_DANGEROUS_CONTENT"
SafetySettingCategory::HARMCATEGORYCIVICINTEGRITY =>
"HARM_CATEGORY_CIVIC_INTEGRITY"
SafetySettingCategory::HARMCATEGORYJAILBREAK => "HARM_CATEGORY_JAILBREAK"
SafetySettingCategory::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SafetySettingCategory with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetySettingCategory with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"HARM_CATEGORY_UNSPECIFIED" =>
Option::Some(SafetySettingCategory::HARMCATEGORYUNSPECIFIED)
"HARM_CATEGORY_DEROGATORY" =>
Option::Some(SafetySettingCategory::HARMCATEGORYDEROGATORY)
"HARM_CATEGORY_TOXICITY" =>
Option::Some(SafetySettingCategory::HARMCATEGORYTOXICITY)
"HARM_CATEGORY_VIOLENCE" =>
Option::Some(SafetySettingCategory::HARMCATEGORYVIOLENCE)
"HARM_CATEGORY_SEXUAL" =>
Option::Some(SafetySettingCategory::HARMCATEGORYSEXUAL)
"HARM_CATEGORY_MEDICAL" =>
Option::Some(SafetySettingCategory::HARMCATEGORYMEDICAL)
"HARM_CATEGORY_DANGEROUS" =>
Option::Some(SafetySettingCategory::HARMCATEGORYDANGEROUS)
"HARM_CATEGORY_HARASSMENT" =>
Option::Some(SafetySettingCategory::HARMCATEGORYHARASSMENT)
"HARM_CATEGORY_HATE_SPEECH" =>
Option::Some(SafetySettingCategory::HARMCATEGORYHATESPEECH)
"HARM_CATEGORY_SEXUALLY_EXPLICIT" =>
Option::Some(SafetySettingCategory::HARMCATEGORYSEXUALLYEXPLICIT)
"HARM_CATEGORY_DANGEROUS_CONTENT" =>
Option::Some(SafetySettingCategory::HARMCATEGORYDANGEROUSCONTENT)
"HARM_CATEGORY_CIVIC_INTEGRITY" =>
Option::Some(SafetySettingCategory::HARMCATEGORYCIVICINTEGRITY)
"HARM_CATEGORY_JAILBREAK" =>
Option::Some(SafetySettingCategory::HARMCATEGORYJAILBREAK)
_ => Option::None
}
},
raw => SafetySettingCategory::Custom(raw),
)
}
///|
///
/// Required. Controls the probability threshold at which harm is blocked. Enum values: HARM_BLOCK_THRESHOLD_UNSPECIFIED: Threshold is unspecified.; BLOCK_LOW_AND_ABOVE: Content with NEGLIGIBLE will be allowed.; BLOCK_MEDIUM_AND_ABOVE: Content with NEGLIGIBLE and LOW will be allowed.; BLOCK_ONLY_HIGH: Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.; BLOCK_NONE: All content will be allowed.; OFF: Turn off the safety filter.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SafetySettingThreshold {
HARMBLOCKTHRESHOLDUNSPECIFIED
BLOCKLOWANDABOVE
BLOCKMEDIUMANDABOVE
BLOCKONLYHIGH
BLOCKNONE
OFF
Custom(String)
}
///|
pub extend SafetySettingThreshold with Eq::{equal, not_equal}
///|
pub extend SafetySettingThreshold with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SafetySettingThreshold with ToJson::{to_json}
///|
pub impl ToJson for SafetySettingThreshold with fn to_json(self) {
let raw = match self {
SafetySettingThreshold::HARMBLOCKTHRESHOLDUNSPECIFIED =>
"HARM_BLOCK_THRESHOLD_UNSPECIFIED"
SafetySettingThreshold::BLOCKLOWANDABOVE => "BLOCK_LOW_AND_ABOVE"
SafetySettingThreshold::BLOCKMEDIUMANDABOVE => "BLOCK_MEDIUM_AND_ABOVE"
SafetySettingThreshold::BLOCKONLYHIGH => "BLOCK_ONLY_HIGH"
SafetySettingThreshold::BLOCKNONE => "BLOCK_NONE"
SafetySettingThreshold::OFF => "OFF"
SafetySettingThreshold::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SafetySettingThreshold with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetySettingThreshold with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"HARM_BLOCK_THRESHOLD_UNSPECIFIED" =>
Option::Some(SafetySettingThreshold::HARMBLOCKTHRESHOLDUNSPECIFIED)
"BLOCK_LOW_AND_ABOVE" =>
Option::Some(SafetySettingThreshold::BLOCKLOWANDABOVE)
"BLOCK_MEDIUM_AND_ABOVE" =>
Option::Some(SafetySettingThreshold::BLOCKMEDIUMANDABOVE)
"BLOCK_ONLY_HIGH" => Option::Some(SafetySettingThreshold::BLOCKONLYHIGH)
"BLOCK_NONE" => Option::Some(SafetySettingThreshold::BLOCKNONE)
"OFF" => Option::Some(SafetySettingThreshold::OFF)
_ => Option::None
}
},
raw => SafetySettingThreshold::Custom(raw),
)
}
///|
///
/// Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked.
#derive(Eq, @debug.Debug)
pub(all) struct SafetySetting {
category : SafetySettingCategory?
threshold : SafetySettingThreshold?
}
///|
pub extend SafetySetting with Eq::{equal, not_equal}
///|
pub extend SafetySetting with @debug.Debug::{to_repr}
///|
///
/// Creates a SafetySetting with omitted optional fields absent.
pub fn SafetySetting::new(
category? : SafetySettingCategory,
threshold? : SafetySettingThreshold,
) -> SafetySetting {
{ category, threshold, }
}
///|
///
/// Encodes this value as JSON.
pub extend SafetySetting with ToJson::{to_json}
///|
pub impl ToJson for SafetySetting with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("category", self.category)
.opt("threshold", self.threshold)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SafetySetting with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetySetting with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
category: @sdkjson.opt_field(obj, "category", path),
threshold: @sdkjson.opt_field(obj, "threshold", path),
}
}
///|
///
/// Optional. The service tier of the request. Enum values: unspecified: Default service tier, which is standard.; standard: Standard service tier.; flex: Flex service tier.; priority: Priority service tier.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum GenerateContentRequestServiceTier {
Unspecified
Standard
Flex
Priority
Custom(String)
}
///|
pub extend GenerateContentRequestServiceTier with Eq::{equal, not_equal}
///|
pub extend GenerateContentRequestServiceTier with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend GenerateContentRequestServiceTier with ToJson::{to_json}
///|
pub impl ToJson for GenerateContentRequestServiceTier with fn to_json(self) {
let raw = match self {
GenerateContentRequestServiceTier::Unspecified => "unspecified"
GenerateContentRequestServiceTier::Standard => "standard"
GenerateContentRequestServiceTier::Flex => "flex"
GenerateContentRequestServiceTier::Priority => "priority"
GenerateContentRequestServiceTier::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend GenerateContentRequestServiceTier with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GenerateContentRequestServiceTier with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"unspecified" =>
Option::Some(GenerateContentRequestServiceTier::Unspecified)
"standard" => Option::Some(GenerateContentRequestServiceTier::Standard)
"flex" => Option::Some(GenerateContentRequestServiceTier::Flex)
"priority" => Option::Some(GenerateContentRequestServiceTier::Priority)
_ => Option::None
}
},
raw => GenerateContentRequestServiceTier::Custom(raw),
)
}
///|
///
/// The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. Files are imported to Semantic Retrieval corpora using the ImportFile API.
#derive(Eq, @debug.Debug)
pub(all) struct FileSearch {
top_k : Int32?
metadata_filter : String?
file_search_store_names : Array[String]?
}
///|
pub extend FileSearch with Eq::{equal, not_equal}
///|
pub extend FileSearch with @debug.Debug::{to_repr}
///|
///
/// Creates a FileSearch with omitted optional fields absent.
pub fn FileSearch::new(
top_k? : Int32,
metadata_filter? : String,
file_search_store_names? : Array[String],
) -> FileSearch {
{ top_k, metadata_filter, file_search_store_names, }
}
///|
///
/// Encodes this value as JSON.
pub extend FileSearch with ToJson::{to_json}
///|
pub impl ToJson for FileSearch with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("topK", self.top_k)
.opt("metadataFilter", self.metadata_filter)
.opt("fileSearchStoreNames", self.file_search_store_names)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FileSearch with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FileSearch with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
top_k: @sdkjson.opt_field(obj, "topK", path),
metadata_filter: @sdkjson.opt_field(obj, "metadataFilter", path),
file_search_store_names: @sdkjson.opt_field(
obj, "fileSearchStoreNames", path,
),
}
}
///|
///
/// The GoogleMaps Tool that provides geospatial context for the user's query.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleMaps {
enable_widget : Bool?
}
///|
pub extend GoogleMaps with Eq::{equal, not_equal}
///|
pub extend GoogleMaps with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleMaps with omitted optional fields absent.
pub fn GoogleMaps::new(enable_widget? : Bool) -> GoogleMaps {
{ enable_widget, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleMaps with ToJson::{to_json}
///|
pub impl ToJson for GoogleMaps with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("enableWidget", self.enable_widget).build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleMaps with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GoogleMaps with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ enable_widget: @sdkjson.opt_field(obj, "enableWidget", path), }
}
///|
///
/// Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. Enum values: UNSPECIFIED: This value is unused.; BLOCKING: If set, the system will wait to receive the function response before continuing the conversation.; NON_BLOCKING: If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FunctionDeclarationBehavior {
UNSPECIFIED
BLOCKING
NONBLOCKING
Unknown(String)
}
///|
pub extend FunctionDeclarationBehavior with Eq::{equal, not_equal}
///|
pub extend FunctionDeclarationBehavior with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FunctionDeclarationBehavior with ToJson::{to_json}
///|
pub impl ToJson for FunctionDeclarationBehavior with fn to_json(self) {
let raw = match self {
FunctionDeclarationBehavior::UNSPECIFIED => "UNSPECIFIED"
FunctionDeclarationBehavior::BLOCKING => "BLOCKING"
FunctionDeclarationBehavior::NONBLOCKING => "NON_BLOCKING"
FunctionDeclarationBehavior::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FunctionDeclarationBehavior with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionDeclarationBehavior with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"UNSPECIFIED" => Option::Some(FunctionDeclarationBehavior::UNSPECIFIED)
"BLOCKING" => Option::Some(FunctionDeclarationBehavior::BLOCKING)
"NON_BLOCKING" => Option::Some(FunctionDeclarationBehavior::NONBLOCKING)
_ => Option::None
}
},
raw => FunctionDeclarationBehavior::Unknown(raw),
)
}
///|
///
/// Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client.
#derive(Eq, @debug.Debug)
pub(all) struct FunctionDeclaration {
behavior : FunctionDeclarationBehavior?
parameters : Schema?
description : String?
name : String?
response : Schema?
response_json_schema : Json?
parameters_json_schema : Json?
}
///|
pub extend FunctionDeclaration with Eq::{equal, not_equal}
///|
pub extend FunctionDeclaration with @debug.Debug::{to_repr}
///|
///
/// Creates a FunctionDeclaration with omitted optional fields absent.
pub fn FunctionDeclaration::new(
behavior? : FunctionDeclarationBehavior,
parameters? : Schema,
description? : String,
name? : String,
response? : Schema,
response_json_schema? : Json,
parameters_json_schema? : Json,
) -> FunctionDeclaration {
{
behavior,
parameters,
description,
name,
response,
response_json_schema,
parameters_json_schema,
}
}
///|
///
/// Encodes this value as JSON.
pub extend FunctionDeclaration with ToJson::{to_json}
///|
pub impl ToJson for FunctionDeclaration with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("behavior", self.behavior)
.opt("parameters", self.parameters)
.opt("description", self.description)
.opt("name", self.name)
.opt("response", self.response)
.opt("responseJsonSchema", self.response_json_schema)
.opt("parametersJsonSchema", self.parameters_json_schema)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend FunctionDeclaration with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FunctionDeclaration with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
behavior: @sdkjson.opt_field(obj, "behavior", path),
parameters: @sdkjson.opt_field(obj, "parameters", path),
description: @sdkjson.opt_field(obj, "description", path),
name: @sdkjson.opt_field(obj, "name", path),
response: @sdkjson.opt_field(obj, "response", path),
response_json_schema: @sdkjson.opt_field(obj, "responseJsonSchema", path),
parameters_json_schema: @sdkjson.opt_field(
obj, "parametersJsonSchema", path,
),
}
}
///|
///
/// A transport that can stream HTTP requests and responses.
#derive(Eq, @debug.Debug)
pub(all) struct StreamableHttpTransport {
terminate_on_close : Bool?
timeout : String?
headers : Map[String, String]?
url : String?
sse_read_timeout : String?
}
///|
pub extend StreamableHttpTransport with Eq::{equal, not_equal}
///|
pub extend StreamableHttpTransport with @debug.Debug::{to_repr}
///|
///
/// Creates a StreamableHttpTransport with omitted optional fields absent.
pub fn StreamableHttpTransport::new(
terminate_on_close? : Bool,
timeout? : String,
headers? : Map[String, String],
url? : String,
sse_read_timeout? : String,
) -> StreamableHttpTransport {
{ terminate_on_close, timeout, headers, url, sse_read_timeout, }
}
///|
///
/// Encodes this value as JSON.
pub extend StreamableHttpTransport with ToJson::{to_json}
///|
pub impl ToJson for StreamableHttpTransport with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("terminateOnClose", self.terminate_on_close)
.opt("timeout", self.timeout)
.opt("headers", self.headers.map(value => json_map_to_json(value)))
.opt("url", self.url)
.opt("sseReadTimeout", self.sse_read_timeout)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend StreamableHttpTransport with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for StreamableHttpTransport with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
terminate_on_close: @sdkjson.opt_field(obj, "terminateOnClose", path),
timeout: @sdkjson.opt_field(obj, "timeout", path),
headers: decode_optional_json_map(obj, "headers", path),
url: @sdkjson.opt_field(obj, "url", path),
sse_read_timeout: @sdkjson.opt_field(obj, "sseReadTimeout", path),
}
}
///|
///
/// A MCPServer is a server that can be called by the model to perform actions. It is a server that implements the MCP protocol.
#derive(Eq, @debug.Debug)
pub(all) struct McpServer {
name : String?
streamable_http_transport : StreamableHttpTransport?
}
///|
pub extend McpServer with Eq::{equal, not_equal}
///|
pub extend McpServer with @debug.Debug::{to_repr}
///|
///
/// Creates a McpServer with omitted optional fields absent.
pub fn McpServer::new(
name? : String,
streamable_http_transport? : StreamableHttpTransport,
) -> McpServer {
{ name, streamable_http_transport, }
}
///|
///
/// Encodes this value as JSON.
pub extend McpServer with ToJson::{to_json}
///|
pub impl ToJson for McpServer with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("name", self.name)
.opt("streamableHttpTransport", self.streamable_http_transport)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend McpServer with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for McpServer with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
name: @sdkjson.opt_field(obj, "name", path),
streamable_http_transport: @sdkjson.opt_field(
obj, "streamableHttpTransport", path,
),
}
}
///|
///
/// Required. The environment being operated. Enum values: ENVIRONMENT_UNSPECIFIED: Defaults to browser.; ENVIRONMENT_BROWSER: Operates in a web browser.; ENVIRONMENT_MOBILE: Operates in a mobile environment.; ENVIRONMENT_DESKTOP: Operates in a desktop environment.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ComputerUseEnvironment {
ENVIRONMENTUNSPECIFIED
ENVIRONMENTBROWSER
ENVIRONMENTMOBILE
ENVIRONMENTDESKTOP
Unknown(String)
}
///|
pub extend ComputerUseEnvironment with Eq::{equal, not_equal}
///|
pub extend ComputerUseEnvironment with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ComputerUseEnvironment with ToJson::{to_json}
///|
pub impl ToJson for ComputerUseEnvironment with fn to_json(self) {
let raw = match self {
ComputerUseEnvironment::ENVIRONMENTUNSPECIFIED => "ENVIRONMENT_UNSPECIFIED"
ComputerUseEnvironment::ENVIRONMENTBROWSER => "ENVIRONMENT_BROWSER"
ComputerUseEnvironment::ENVIRONMENTMOBILE => "ENVIRONMENT_MOBILE"
ComputerUseEnvironment::ENVIRONMENTDESKTOP => "ENVIRONMENT_DESKTOP"
ComputerUseEnvironment::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ComputerUseEnvironment with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ComputerUseEnvironment with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"ENVIRONMENT_UNSPECIFIED" =>
Option::Some(ComputerUseEnvironment::ENVIRONMENTUNSPECIFIED)
"ENVIRONMENT_BROWSER" =>
Option::Some(ComputerUseEnvironment::ENVIRONMENTBROWSER)
"ENVIRONMENT_MOBILE" =>
Option::Some(ComputerUseEnvironment::ENVIRONMENTMOBILE)
"ENVIRONMENT_DESKTOP" =>
Option::Some(ComputerUseEnvironment::ENVIRONMENTDESKTOP)
_ => Option::None
}
},
raw => ComputerUseEnvironment::Unknown(raw),
)
}
///|
///
/// Enum values: SAFETY_POLICY_UNSPECIFIED: Unspecified safety policy.; FINANCIAL_TRANSACTIONS: Safety policy for financial transactions.; SENSITIVE_DATA_MODIFICATION: Safety policy for sensitive data modification.; COMMUNICATION_TOOL: Safety policy for communication tools (e.g. Gmail, Chat, Meet).; ACCOUNT_CREATION: Safety policy for account creation.; DATA_MODIFICATION: Safety policy for data modification.; USER_CONSENT_MANAGEMENT: Safety policy for user consent management.; LEGAL_TERMS_AND_AGREEMENTS: Safety policy for legal terms and agreements.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ComputerUseDisabledSafetyPoliciesItem {
SAFETYPOLICYUNSPECIFIED
FINANCIALTRANSACTIONS
SENSITIVEDATAMODIFICATION
COMMUNICATIONTOOL
ACCOUNTCREATION
DATAMODIFICATION
USERCONSENTMANAGEMENT
LEGALTERMSANDAGREEMENTS
Unknown(String)
}
///|
pub extend ComputerUseDisabledSafetyPoliciesItem with Eq::{equal, not_equal}
///|
pub extend ComputerUseDisabledSafetyPoliciesItem with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ComputerUseDisabledSafetyPoliciesItem with ToJson::{to_json}
///|
pub impl ToJson for ComputerUseDisabledSafetyPoliciesItem with fn to_json(self) {
let raw = match self {
ComputerUseDisabledSafetyPoliciesItem::SAFETYPOLICYUNSPECIFIED =>
"SAFETY_POLICY_UNSPECIFIED"
ComputerUseDisabledSafetyPoliciesItem::FINANCIALTRANSACTIONS =>
"FINANCIAL_TRANSACTIONS"
ComputerUseDisabledSafetyPoliciesItem::SENSITIVEDATAMODIFICATION =>
"SENSITIVE_DATA_MODIFICATION"
ComputerUseDisabledSafetyPoliciesItem::COMMUNICATIONTOOL =>
"COMMUNICATION_TOOL"
ComputerUseDisabledSafetyPoliciesItem::ACCOUNTCREATION => "ACCOUNT_CREATION"
ComputerUseDisabledSafetyPoliciesItem::DATAMODIFICATION =>
"DATA_MODIFICATION"
ComputerUseDisabledSafetyPoliciesItem::USERCONSENTMANAGEMENT =>
"USER_CONSENT_MANAGEMENT"
ComputerUseDisabledSafetyPoliciesItem::LEGALTERMSANDAGREEMENTS =>
"LEGAL_TERMS_AND_AGREEMENTS"
ComputerUseDisabledSafetyPoliciesItem::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ComputerUseDisabledSafetyPoliciesItem with @json.FromJson::{
from_json,
}
///|
pub impl @json.FromJson for ComputerUseDisabledSafetyPoliciesItem with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"SAFETY_POLICY_UNSPECIFIED" =>
Option::Some(
ComputerUseDisabledSafetyPoliciesItem::SAFETYPOLICYUNSPECIFIED,
)
"FINANCIAL_TRANSACTIONS" =>
Option::Some(
ComputerUseDisabledSafetyPoliciesItem::FINANCIALTRANSACTIONS,
)
"SENSITIVE_DATA_MODIFICATION" =>
Option::Some(
ComputerUseDisabledSafetyPoliciesItem::SENSITIVEDATAMODIFICATION,
)
"COMMUNICATION_TOOL" =>
Option::Some(ComputerUseDisabledSafetyPoliciesItem::COMMUNICATIONTOOL)
"ACCOUNT_CREATION" =>
Option::Some(ComputerUseDisabledSafetyPoliciesItem::ACCOUNTCREATION)
"DATA_MODIFICATION" =>
Option::Some(ComputerUseDisabledSafetyPoliciesItem::DATAMODIFICATION)
"USER_CONSENT_MANAGEMENT" =>
Option::Some(
ComputerUseDisabledSafetyPoliciesItem::USERCONSENTMANAGEMENT,
)
"LEGAL_TERMS_AND_AGREEMENTS" =>
Option::Some(
ComputerUseDisabledSafetyPoliciesItem::LEGALTERMSANDAGREEMENTS,
)
_ => Option::None
}
},
raw => ComputerUseDisabledSafetyPoliciesItem::Unknown(raw),
)
}
///|
///
/// Computer Use tool type.
#derive(Eq, @debug.Debug)
pub(all) struct ComputerUse {
enable_prompt_injection_detection : Bool?
excluded_predefined_functions : Array[String]?
environment : ComputerUseEnvironment?
disabled_safety_policies : Array[ComputerUseDisabledSafetyPoliciesItem]?
}
///|
pub extend ComputerUse with Eq::{equal, not_equal}
///|
pub extend ComputerUse with @debug.Debug::{to_repr}
///|
///
/// Creates a ComputerUse with omitted optional fields absent.
pub fn ComputerUse::new(
enable_prompt_injection_detection? : Bool,
excluded_predefined_functions? : Array[String],
environment? : ComputerUseEnvironment,
disabled_safety_policies? : Array[ComputerUseDisabledSafetyPoliciesItem],
) -> ComputerUse {
{
enable_prompt_injection_detection,
excluded_predefined_functions,
environment,
disabled_safety_policies,
}
}
///|
///
/// Encodes this value as JSON.
pub extend ComputerUse with ToJson::{to_json}
///|
pub impl ToJson for ComputerUse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("enablePromptInjectionDetection", self.enable_prompt_injection_detection)
.opt("excludedPredefinedFunctions", self.excluded_predefined_functions)
.opt("environment", self.environment)
.opt("disabledSafetyPolicies", self.disabled_safety_policies)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ComputerUse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ComputerUse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
enable_prompt_injection_detection: @sdkjson.opt_field(
obj, "enablePromptInjectionDetection", path,
),
excluded_predefined_functions: @sdkjson.opt_field(
obj, "excludedPredefinedFunctions", path,
),
environment: @sdkjson.opt_field(obj, "environment", path),
disabled_safety_policies: @sdkjson.opt_field(
obj, "disabledSafetyPolicies", path,
),
}
}
///|
///
/// Tool to retrieve public web data for grounding, powered by Google.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleSearchRetrieval {
dynamic_retrieval_config : DynamicRetrievalConfig?
}
///|
pub extend GoogleSearchRetrieval with Eq::{equal, not_equal}
///|
pub extend GoogleSearchRetrieval with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleSearchRetrieval with omitted optional fields absent.
pub fn GoogleSearchRetrieval::new(
dynamic_retrieval_config? : DynamicRetrievalConfig,
) -> GoogleSearchRetrieval {
{ dynamic_retrieval_config, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleSearchRetrieval with ToJson::{to_json}
///|
pub impl ToJson for GoogleSearchRetrieval with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("dynamicRetrievalConfig", self.dynamic_retrieval_config)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleSearchRetrieval with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GoogleSearchRetrieval with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
dynamic_retrieval_config: @sdkjson.opt_field(
obj, "dynamicRetrievalConfig", path,
),
}
}
///|
///
/// Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
#derive(Eq, @debug.Debug)
pub(all) struct Tool {
file_search : FileSearch?
google_search : GoogleSearch?
google_maps : GoogleMaps?
code_execution : Json?
function_declarations : Array[FunctionDeclaration]?
url_context : Json?
mcp_servers : Array[McpServer]?
computer_use : ComputerUse?
google_search_retrieval : GoogleSearchRetrieval?
}
///|
pub extend Tool with Eq::{equal, not_equal}
///|
pub extend Tool with @debug.Debug::{to_repr}
///|
///
/// Creates a Tool with omitted optional fields absent.
pub fn Tool::new(
file_search? : FileSearch,
google_search? : GoogleSearch,
google_maps? : GoogleMaps,
code_execution? : Json,
function_declarations? : Array[FunctionDeclaration],
url_context? : Json,
mcp_servers? : Array[McpServer],
computer_use? : ComputerUse,
google_search_retrieval? : GoogleSearchRetrieval,
) -> Tool {
{
file_search,
google_search,
google_maps,
code_execution,
function_declarations,
url_context,
mcp_servers,
computer_use,
google_search_retrieval,
}
}
///|
///
/// Encodes this value as JSON.
pub extend Tool with ToJson::{to_json}
///|
pub impl ToJson for Tool with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("fileSearch", self.file_search)
.opt("googleSearch", self.google_search)
.opt("googleMaps", self.google_maps)
.opt("codeExecution", self.code_execution)
.opt("functionDeclarations", self.function_declarations)
.opt("urlContext", self.url_context)
.opt("mcpServers", self.mcp_servers)
.opt("computerUse", self.computer_use)
.opt("googleSearchRetrieval", self.google_search_retrieval)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Tool with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Tool with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
file_search: @sdkjson.opt_field(obj, "fileSearch", path),
google_search: @sdkjson.opt_field(obj, "googleSearch", path),
google_maps: @sdkjson.opt_field(obj, "googleMaps", path),
code_execution: @sdkjson.opt_field(obj, "codeExecution", path),
function_declarations: @sdkjson.opt_field(obj, "functionDeclarations", path),
url_context: @sdkjson.opt_field(obj, "urlContext", path),
mcp_servers: @sdkjson.opt_field(obj, "mcpServers", path),
computer_use: @sdkjson.opt_field(obj, "computerUse", path),
google_search_retrieval: @sdkjson.opt_field(
obj, "googleSearchRetrieval", path,
),
}
}
///|
///
/// Request to generate a completion from the model.
#derive(Eq, @debug.Debug)
pub(all) struct GenerateContentRequest {
tool_config : ToolConfig?
generation_config : GenerationConfig?
safety_settings : Array[SafetySetting]?
contents : Array[Content]?
continuation_token : String?
store : Bool?
cached_content : String?
service_tier : GenerateContentRequestServiceTier?
tools : Array[Tool]?
system_instruction : Content?
model : String?
labels : Map[String, String]?
}
///|
pub extend GenerateContentRequest with Eq::{equal, not_equal}
///|
pub extend GenerateContentRequest with @debug.Debug::{to_repr}
///|
///
/// Creates a GenerateContentRequest with omitted optional fields absent.
pub fn GenerateContentRequest::new(
tool_config? : ToolConfig,
generation_config? : GenerationConfig,
safety_settings? : Array[SafetySetting],
contents? : Array[Content],
continuation_token? : String,
store? : Bool,
cached_content? : String,
service_tier? : GenerateContentRequestServiceTier,
tools? : Array[Tool],
system_instruction? : Content,
model? : String,
labels? : Map[String, String],
) -> GenerateContentRequest {
{
tool_config,
generation_config,
safety_settings,
contents,
continuation_token,
store,
cached_content,
service_tier,
tools,
system_instruction,
model,
labels,
}
}
///|
///
/// Encodes this value as JSON.
pub extend GenerateContentRequest with ToJson::{to_json}
///|
pub impl ToJson for GenerateContentRequest with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("toolConfig", self.tool_config)
.opt("generationConfig", self.generation_config)
.opt("safetySettings", self.safety_settings)
.opt("contents", self.contents)
.opt("continuationToken", self.continuation_token)
.opt("store", self.store)
.opt("cachedContent", self.cached_content)
.opt("serviceTier", self.service_tier)
.opt("tools", self.tools)
.opt("systemInstruction", self.system_instruction)
.opt("model", self.model)
.opt("labels", self.labels.map(value => json_map_to_json(value)))
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GenerateContentRequest with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GenerateContentRequest with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
tool_config: @sdkjson.opt_field(obj, "toolConfig", path),
generation_config: @sdkjson.opt_field(obj, "generationConfig", path),
safety_settings: @sdkjson.opt_field(obj, "safetySettings", path),
contents: @sdkjson.opt_field(obj, "contents", path),
continuation_token: @sdkjson.opt_field(obj, "continuationToken", path),
store: @sdkjson.opt_field(obj, "store", path),
cached_content: @sdkjson.opt_field(obj, "cachedContent", path),
service_tier: @sdkjson.opt_field(obj, "serviceTier", path),
tools: @sdkjson.opt_field(obj, "tools", path),
system_instruction: @sdkjson.opt_field(obj, "systemInstruction", path),
model: @sdkjson.opt_field(obj, "model", path),
labels: decode_optional_json_map(obj, "labels", path),
}
}
///|
///
/// Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`.
#derive(Eq, @debug.Debug)
pub(all) struct CountTokensRequest {
contents : Array[Content]?
generate_content_request : GenerateContentRequest?
}
///|
pub extend CountTokensRequest with Eq::{equal, not_equal}
///|
pub extend CountTokensRequest with @debug.Debug::{to_repr}
///|
///
/// Creates a CountTokensRequest with omitted optional fields absent.
pub fn CountTokensRequest::new(
contents? : Array[Content],
generate_content_request? : GenerateContentRequest,
) -> CountTokensRequest {
{ contents, generate_content_request, }
}
///|
///
/// Encodes this value as JSON.
pub extend CountTokensRequest with ToJson::{to_json}
///|
pub impl ToJson for CountTokensRequest with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("contents", self.contents)
.opt("generateContentRequest", self.generate_content_request)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CountTokensRequest with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CountTokensRequest with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
contents: @sdkjson.opt_field(obj, "contents", path),
generate_content_request: @sdkjson.opt_field(
obj, "generateContentRequest", path,
),
}
}
///|
///
/// Optional. The task type of the embedding. Enum values: TASK_TYPE_UNSPECIFIED: Unset value, which will default to one of the other enum values.; RETRIEVAL_QUERY: Specifies the given text is a query in a search/retrieval setting.; RETRIEVAL_DOCUMENT: Specifies the given text is a document from the corpus being searched.; SEMANTIC_SIMILARITY: Specifies the given text will be used for STS.; CLASSIFICATION: Specifies that the given text will be classified.; CLUSTERING: Specifies that the embeddings will be used for clustering.; QUESTION_ANSWERING: Specifies that the given text will be used for question answering.; FACT_VERIFICATION: Specifies that the given text will be used for fact verification.; CODE_RETRIEVAL_QUERY: Specifies that the given text will be used for code retrieval.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum EmbedContentConfigTaskType {
TASKTYPEUNSPECIFIED
RETRIEVALQUERY
RETRIEVALDOCUMENT
SEMANTICSIMILARITY
CLASSIFICATION
CLUSTERING
QUESTIONANSWERING
FACTVERIFICATION
CODERETRIEVALQUERY
Custom(String)
}
///|
pub extend EmbedContentConfigTaskType with Eq::{equal, not_equal}
///|
pub extend EmbedContentConfigTaskType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend EmbedContentConfigTaskType with ToJson::{to_json}
///|
pub impl ToJson for EmbedContentConfigTaskType with fn to_json(self) {
let raw = match self {
EmbedContentConfigTaskType::TASKTYPEUNSPECIFIED => "TASK_TYPE_UNSPECIFIED"
EmbedContentConfigTaskType::RETRIEVALQUERY => "RETRIEVAL_QUERY"
EmbedContentConfigTaskType::RETRIEVALDOCUMENT => "RETRIEVAL_DOCUMENT"
EmbedContentConfigTaskType::SEMANTICSIMILARITY => "SEMANTIC_SIMILARITY"
EmbedContentConfigTaskType::CLASSIFICATION => "CLASSIFICATION"
EmbedContentConfigTaskType::CLUSTERING => "CLUSTERING"
EmbedContentConfigTaskType::QUESTIONANSWERING => "QUESTION_ANSWERING"
EmbedContentConfigTaskType::FACTVERIFICATION => "FACT_VERIFICATION"
EmbedContentConfigTaskType::CODERETRIEVALQUERY => "CODE_RETRIEVAL_QUERY"
EmbedContentConfigTaskType::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend EmbedContentConfigTaskType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbedContentConfigTaskType with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TASK_TYPE_UNSPECIFIED" =>
Option::Some(EmbedContentConfigTaskType::TASKTYPEUNSPECIFIED)
"RETRIEVAL_QUERY" =>
Option::Some(EmbedContentConfigTaskType::RETRIEVALQUERY)
"RETRIEVAL_DOCUMENT" =>
Option::Some(EmbedContentConfigTaskType::RETRIEVALDOCUMENT)
"SEMANTIC_SIMILARITY" =>
Option::Some(EmbedContentConfigTaskType::SEMANTICSIMILARITY)
"CLASSIFICATION" =>
Option::Some(EmbedContentConfigTaskType::CLASSIFICATION)
"CLUSTERING" => Option::Some(EmbedContentConfigTaskType::CLUSTERING)
"QUESTION_ANSWERING" =>
Option::Some(EmbedContentConfigTaskType::QUESTIONANSWERING)
"FACT_VERIFICATION" =>
Option::Some(EmbedContentConfigTaskType::FACTVERIFICATION)
"CODE_RETRIEVAL_QUERY" =>
Option::Some(EmbedContentConfigTaskType::CODERETRIEVALQUERY)
_ => Option::None
}
},
raw => EmbedContentConfigTaskType::Custom(raw),
)
}
///|
///
/// Configurations for the EmbedContent request.
#derive(Eq, @debug.Debug)
pub(all) struct EmbedContentConfig {
output_dimensionality : Int32?
audio_track_extraction : Bool?
auto_truncate : Bool?
title : String?
document_ocr : Bool?
task_type : EmbedContentConfigTaskType?
}
///|
pub extend EmbedContentConfig with Eq::{equal, not_equal}
///|
pub extend EmbedContentConfig with @debug.Debug::{to_repr}
///|
///
/// Creates a EmbedContentConfig with omitted optional fields absent.
pub fn EmbedContentConfig::new(
output_dimensionality? : Int32,
audio_track_extraction? : Bool,
auto_truncate? : Bool,
title? : String,
document_ocr? : Bool,
task_type? : EmbedContentConfigTaskType,
) -> EmbedContentConfig {
{
output_dimensionality,
audio_track_extraction,
auto_truncate,
title,
document_ocr,
task_type,
}
}
///|
///
/// Encodes this value as JSON.
pub extend EmbedContentConfig with ToJson::{to_json}
///|
pub impl ToJson for EmbedContentConfig with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("outputDimensionality", self.output_dimensionality)
.opt("audioTrackExtraction", self.audio_track_extraction)
.opt("autoTruncate", self.auto_truncate)
.opt("title", self.title)
.opt("documentOcr", self.document_ocr)
.opt("taskType", self.task_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend EmbedContentConfig with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbedContentConfig with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
output_dimensionality: @sdkjson.opt_field(obj, "outputDimensionality", path),
audio_track_extraction: @sdkjson.opt_field(
obj, "audioTrackExtraction", path,
),
auto_truncate: @sdkjson.opt_field(obj, "autoTruncate", path),
title: @sdkjson.opt_field(obj, "title", path),
document_ocr: @sdkjson.opt_field(obj, "documentOcr", path),
task_type: @sdkjson.opt_field(obj, "taskType", path),
}
}
///|
///
/// Optional. Deprecated: Please use EmbedContentConfig.task_type instead. Optional task type for which the embeddings will be used. Not supported on earlier models (`models/embedding-001`). Enum values: TASK_TYPE_UNSPECIFIED: Unset value, which will default to one of the other enum values.; RETRIEVAL_QUERY: Specifies the given text is a query in a search/retrieval setting.; RETRIEVAL_DOCUMENT: Specifies the given text is a document from the corpus being searched.; SEMANTIC_SIMILARITY: Specifies the given text will be used for STS.; CLASSIFICATION: Specifies that the given text will be classified.; CLUSTERING: Specifies that the embeddings will be used for clustering.; QUESTION_ANSWERING: Specifies that the given text will be used for question answering.; FACT_VERIFICATION: Specifies that the given text will be used for fact verification.; CODE_RETRIEVAL_QUERY: Specifies that the given text will be used for code retrieval.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum EmbedContentRequestTaskType {
TASKTYPEUNSPECIFIED
RETRIEVALQUERY
RETRIEVALDOCUMENT
SEMANTICSIMILARITY
CLASSIFICATION
CLUSTERING
QUESTIONANSWERING
FACTVERIFICATION
CODERETRIEVALQUERY
Custom(String)
}
///|
pub extend EmbedContentRequestTaskType with Eq::{equal, not_equal}
///|
pub extend EmbedContentRequestTaskType with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend EmbedContentRequestTaskType with ToJson::{to_json}
///|
pub impl ToJson for EmbedContentRequestTaskType with fn to_json(self) {
let raw = match self {
EmbedContentRequestTaskType::TASKTYPEUNSPECIFIED => "TASK_TYPE_UNSPECIFIED"
EmbedContentRequestTaskType::RETRIEVALQUERY => "RETRIEVAL_QUERY"
EmbedContentRequestTaskType::RETRIEVALDOCUMENT => "RETRIEVAL_DOCUMENT"
EmbedContentRequestTaskType::SEMANTICSIMILARITY => "SEMANTIC_SIMILARITY"
EmbedContentRequestTaskType::CLASSIFICATION => "CLASSIFICATION"
EmbedContentRequestTaskType::CLUSTERING => "CLUSTERING"
EmbedContentRequestTaskType::QUESTIONANSWERING => "QUESTION_ANSWERING"
EmbedContentRequestTaskType::FACTVERIFICATION => "FACT_VERIFICATION"
EmbedContentRequestTaskType::CODERETRIEVALQUERY => "CODE_RETRIEVAL_QUERY"
EmbedContentRequestTaskType::Custom(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend EmbedContentRequestTaskType with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbedContentRequestTaskType with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"TASK_TYPE_UNSPECIFIED" =>
Option::Some(EmbedContentRequestTaskType::TASKTYPEUNSPECIFIED)
"RETRIEVAL_QUERY" =>
Option::Some(EmbedContentRequestTaskType::RETRIEVALQUERY)
"RETRIEVAL_DOCUMENT" =>
Option::Some(EmbedContentRequestTaskType::RETRIEVALDOCUMENT)
"SEMANTIC_SIMILARITY" =>
Option::Some(EmbedContentRequestTaskType::SEMANTICSIMILARITY)
"CLASSIFICATION" =>
Option::Some(EmbedContentRequestTaskType::CLASSIFICATION)
"CLUSTERING" => Option::Some(EmbedContentRequestTaskType::CLUSTERING)
"QUESTION_ANSWERING" =>
Option::Some(EmbedContentRequestTaskType::QUESTIONANSWERING)
"FACT_VERIFICATION" =>
Option::Some(EmbedContentRequestTaskType::FACTVERIFICATION)
"CODE_RETRIEVAL_QUERY" =>
Option::Some(EmbedContentRequestTaskType::CODERETRIEVALQUERY)
_ => Option::None
}
},
raw => EmbedContentRequestTaskType::Custom(raw),
)
}
///|
///
/// Request containing the `Content` for the model to embed.
#derive(Eq, @debug.Debug)
pub(all) struct EmbedContentRequest {
embed_content_config : EmbedContentConfig?
model : String?
content : Content?
output_dimensionality : Int32?
title : String?
task_type : EmbedContentRequestTaskType?
}
///|
pub extend EmbedContentRequest with Eq::{equal, not_equal}
///|
pub extend EmbedContentRequest with @debug.Debug::{to_repr}
///|
///
/// Creates a EmbedContentRequest with omitted optional fields absent.
pub fn EmbedContentRequest::new(
embed_content_config? : EmbedContentConfig,
model? : String,
content? : Content,
output_dimensionality? : Int32,
title? : String,
task_type? : EmbedContentRequestTaskType,
) -> EmbedContentRequest {
{
embed_content_config,
model,
content,
output_dimensionality,
title,
task_type,
}
}
///|
///
/// Encodes this value as JSON.
pub extend EmbedContentRequest with ToJson::{to_json}
///|
pub impl ToJson for EmbedContentRequest with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("embedContentConfig", self.embed_content_config)
.opt("model", self.model)
.opt("content", self.content)
.opt("outputDimensionality", self.output_dimensionality)
.opt("title", self.title)
.opt("taskType", self.task_type)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend EmbedContentRequest with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbedContentRequest with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
embed_content_config: @sdkjson.opt_field(obj, "embedContentConfig", path),
model: @sdkjson.opt_field(obj, "model", path),
content: @sdkjson.opt_field(obj, "content", path),
output_dimensionality: @sdkjson.opt_field(obj, "outputDimensionality", path),
title: @sdkjson.opt_field(obj, "title", path),
task_type: @sdkjson.opt_field(obj, "taskType", path),
}
}
///|
///
/// Metadata related to retrieval in the grounding flow.
#derive(Eq, @debug.Debug)
pub(all) struct RetrievalMetadata {
google_search_dynamic_retrieval_score : Double?
}
///|
pub extend RetrievalMetadata with Eq::{equal, not_equal}
///|
pub extend RetrievalMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a RetrievalMetadata with omitted optional fields absent.
pub fn RetrievalMetadata::new(
google_search_dynamic_retrieval_score? : Double,
) -> RetrievalMetadata {
{ google_search_dynamic_retrieval_score, }
}
///|
///
/// Encodes this value as JSON.
pub extend RetrievalMetadata with ToJson::{to_json}
///|
pub impl ToJson for RetrievalMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt(
"googleSearchDynamicRetrievalScore",
self.google_search_dynamic_retrieval_score,
)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend RetrievalMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for RetrievalMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
google_search_dynamic_retrieval_score: @sdkjson.opt_field(
obj, "googleSearchDynamicRetrievalScore", path,
),
}
}
///|
///
/// A citation to a source for a portion of a specific response.
#derive(Eq, @debug.Debug)
pub(all) struct CitationSource {
uri : String?
license : String?
end_index : Int32?
start_index : Int32?
}
///|
pub extend CitationSource with Eq::{equal, not_equal}
///|
pub extend CitationSource with @debug.Debug::{to_repr}
///|
///
/// Creates a CitationSource with omitted optional fields absent.
pub fn CitationSource::new(
uri? : String,
license? : String,
end_index? : Int32,
start_index? : Int32,
) -> CitationSource {
{ uri, license, end_index, start_index, }
}
///|
///
/// Encodes this value as JSON.
pub extend CitationSource with ToJson::{to_json}
///|
pub impl ToJson for CitationSource with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("uri", self.uri)
.opt("license", self.license)
.opt("endIndex", self.end_index)
.opt("startIndex", self.start_index)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CitationSource with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CitationSource with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
uri: @sdkjson.opt_field(obj, "uri", path),
license: @sdkjson.opt_field(obj, "license", path),
end_index: @sdkjson.opt_field(obj, "endIndex", path),
start_index: @sdkjson.opt_field(obj, "startIndex", path),
}
}
///|
///
/// A collection of source attributions for a piece of content.
#derive(Eq, @debug.Debug)
pub(all) struct CitationMetadata {
citation_sources : Array[CitationSource]?
}
///|
pub extend CitationMetadata with Eq::{equal, not_equal}
///|
pub extend CitationMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a CitationMetadata with omitted optional fields absent.
pub fn CitationMetadata::new(
citation_sources? : Array[CitationSource],
) -> CitationMetadata {
{ citation_sources, }
}
///|
///
/// Encodes this value as JSON.
pub extend CitationMetadata with ToJson::{to_json}
///|
pub impl ToJson for CitationMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("citationSources", self.citation_sources)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CitationMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CitationMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ citation_sources: @sdkjson.opt_field(obj, "citationSources", path), }
}
///|
///
/// Segment of the content.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleAiGenerativelanguageV1betaSegment {
part_index : Int32?
start_index : Int32?
end_index : Int32?
text : String?
}
///|
pub extend GoogleAiGenerativelanguageV1betaSegment with Eq::{equal, not_equal}
///|
pub extend GoogleAiGenerativelanguageV1betaSegment with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleAiGenerativelanguageV1betaSegment with omitted optional fields absent.
pub fn GoogleAiGenerativelanguageV1betaSegment::new(
part_index? : Int32,
start_index? : Int32,
end_index? : Int32,
text? : String,
) -> GoogleAiGenerativelanguageV1betaSegment {
{ part_index, start_index, end_index, text, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleAiGenerativelanguageV1betaSegment with ToJson::{to_json}
///|
pub impl ToJson for GoogleAiGenerativelanguageV1betaSegment with fn to_json(
self,
) {
@sdkjson.ObjBuilder::new()
.opt("partIndex", self.part_index)
.opt("startIndex", self.start_index)
.opt("endIndex", self.end_index)
.opt("text", self.text)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleAiGenerativelanguageV1betaSegment with @json.FromJson::{
from_json,
}
///|
pub impl @json.FromJson for GoogleAiGenerativelanguageV1betaSegment with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
part_index: @sdkjson.opt_field(obj, "partIndex", path),
start_index: @sdkjson.opt_field(obj, "startIndex", path),
end_index: @sdkjson.opt_field(obj, "endIndex", path),
text: @sdkjson.opt_field(obj, "text", path),
}
}
///|
///
/// Grounding support.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleAiGenerativelanguageV1betaGroundingSupport {
segment : GoogleAiGenerativelanguageV1betaSegment?
grounding_chunk_indices : Array[Int32]?
rendered_parts : Array[Int32]?
confidence_scores : Array[Double]?
}
///|
pub extend GoogleAiGenerativelanguageV1betaGroundingSupport with Eq::{
equal,
not_equal,
}
///|
pub extend GoogleAiGenerativelanguageV1betaGroundingSupport with @debug.Debug::{
to_repr,
}
///|
///
/// Creates a GoogleAiGenerativelanguageV1betaGroundingSupport with omitted optional fields absent.
pub fn GoogleAiGenerativelanguageV1betaGroundingSupport::new(
segment? : GoogleAiGenerativelanguageV1betaSegment,
grounding_chunk_indices? : Array[Int32],
rendered_parts? : Array[Int32],
confidence_scores? : Array[Double],
) -> GoogleAiGenerativelanguageV1betaGroundingSupport {
{ segment, grounding_chunk_indices, rendered_parts, confidence_scores, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleAiGenerativelanguageV1betaGroundingSupport with ToJson::{
to_json,
}
///|
pub impl ToJson for GoogleAiGenerativelanguageV1betaGroundingSupport with fn to_json(
self,
) {
@sdkjson.ObjBuilder::new()
.opt("segment", self.segment)
.opt("groundingChunkIndices", self.grounding_chunk_indices)
.opt("renderedParts", self.rendered_parts)
.opt("confidenceScores", self.confidence_scores)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleAiGenerativelanguageV1betaGroundingSupport with @json.FromJson::{
from_json,
}
///|
pub impl @json.FromJson for GoogleAiGenerativelanguageV1betaGroundingSupport with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
segment: @sdkjson.opt_field(obj, "segment", path),
grounding_chunk_indices: @sdkjson.opt_field(
obj, "groundingChunkIndices", path,
),
rendered_parts: @sdkjson.opt_field(obj, "renderedParts", path),
confidence_scores: @sdkjson.opt_field(obj, "confidenceScores", path),
}
}
///|
///
/// Google search entry point.
#derive(Eq, @debug.Debug)
pub(all) struct SearchEntryPoint {
sdk_blob : String?
rendered_content : String?
}
///|
pub extend SearchEntryPoint with Eq::{equal, not_equal}
///|
pub extend SearchEntryPoint with @debug.Debug::{to_repr}
///|
///
/// Creates a SearchEntryPoint with omitted optional fields absent.
pub fn SearchEntryPoint::new(
sdk_blob? : String,
rendered_content? : String,
) -> SearchEntryPoint {
{ sdk_blob, rendered_content, }
}
///|
///
/// Encodes this value as JSON.
pub extend SearchEntryPoint with ToJson::{to_json}
///|
pub impl ToJson for SearchEntryPoint with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("sdkBlob", self.sdk_blob)
.opt("renderedContent", self.rendered_content)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SearchEntryPoint with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SearchEntryPoint with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
sdk_blob: @sdkjson.opt_field(obj, "sdkBlob", path),
rendered_content: @sdkjson.opt_field(obj, "renderedContent", path),
}
}
///|
///
/// Chunk from image search.
#derive(Eq, @debug.Debug)
pub(all) struct Image {
domain : String?
image_uri : String?
title : String?
source_uri : String?
}
///|
pub extend Image with Eq::{equal, not_equal}
///|
pub extend Image with @debug.Debug::{to_repr}
///|
///
/// Creates a Image with omitted optional fields absent.
pub fn Image::new(
domain? : String,
image_uri? : String,
title? : String,
source_uri? : String,
) -> Image {
{ domain, image_uri, title, source_uri, }
}
///|
///
/// Encodes this value as JSON.
pub extend Image with ToJson::{to_json}
///|
pub impl ToJson for Image with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("domain", self.domain)
.opt("imageUri", self.image_uri)
.opt("title", self.title)
.opt("sourceUri", self.source_uri)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Image with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Image with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
domain: @sdkjson.opt_field(obj, "domain", path),
image_uri: @sdkjson.opt_field(obj, "imageUri", path),
title: @sdkjson.opt_field(obj, "title", path),
source_uri: @sdkjson.opt_field(obj, "sourceUri", path),
}
}
///|
///
/// Chunk from the web.
#derive(Eq, @debug.Debug)
pub(all) struct Web {
title : String?
uri : String?
}
///|
pub extend Web with Eq::{equal, not_equal}
///|
pub extend Web with @debug.Debug::{to_repr}
///|
///
/// Creates a Web with omitted optional fields absent.
pub fn Web::new(title? : String, uri? : String) -> Web {
{ title, uri, }
}
///|
///
/// Encodes this value as JSON.
pub extend Web with ToJson::{to_json}
///|
pub impl ToJson for Web with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("title", self.title)
.opt("uri", self.uri)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Web with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Web with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
title: @sdkjson.opt_field(obj, "title", path),
uri: @sdkjson.opt_field(obj, "uri", path),
}
}
///|
///
/// Chunk from context retrieved by the file search tool.
#derive(Eq, @debug.Debug)
pub(all) struct RetrievedContext {
file_search_store : String?
text : String?
media_id : String?
uri : String?
custom_metadata : Array[GroundingChunkCustomMetadata]?
title : String?
page_number : Int32?
}
///|
pub extend RetrievedContext with Eq::{equal, not_equal}
///|
pub extend RetrievedContext with @debug.Debug::{to_repr}
///|
///
/// Creates a RetrievedContext with omitted optional fields absent.
pub fn RetrievedContext::new(
file_search_store? : String,
text? : String,
media_id? : String,
uri? : String,
custom_metadata? : Array[GroundingChunkCustomMetadata],
title? : String,
page_number? : Int32,
) -> RetrievedContext {
{
file_search_store,
text,
media_id,
uri,
custom_metadata,
title,
page_number,
}
}
///|
///
/// Encodes this value as JSON.
pub extend RetrievedContext with ToJson::{to_json}
///|
pub impl ToJson for RetrievedContext with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("fileSearchStore", self.file_search_store)
.opt("text", self.text)
.opt("mediaId", self.media_id)
.opt("uri", self.uri)
.opt("customMetadata", self.custom_metadata)
.opt("title", self.title)
.opt("pageNumber", self.page_number)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend RetrievedContext with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for RetrievedContext with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
file_search_store: @sdkjson.opt_field(obj, "fileSearchStore", path),
text: @sdkjson.opt_field(obj, "text", path),
media_id: @sdkjson.opt_field(obj, "mediaId", path),
uri: @sdkjson.opt_field(obj, "uri", path),
custom_metadata: @sdkjson.opt_field(obj, "customMetadata", path),
title: @sdkjson.opt_field(obj, "title", path),
page_number: @sdkjson.opt_field(obj, "pageNumber", path),
}
}
///|
///
/// A `GroundingChunk` represents a segment of supporting evidence that grounds the model's response. It can be a chunk from the web, a retrieved context from a file, or information from Google Maps.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingChunk {
image : Image?
web : Web?
maps : Maps?
retrieved_context : RetrievedContext?
}
///|
pub extend GroundingChunk with Eq::{equal, not_equal}
///|
pub extend GroundingChunk with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingChunk with omitted optional fields absent.
pub fn GroundingChunk::new(
image? : Image,
web? : Web,
maps? : Maps,
retrieved_context? : RetrievedContext,
) -> GroundingChunk {
{ image, web, maps, retrieved_context, }
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingChunk with ToJson::{to_json}
///|
pub impl ToJson for GroundingChunk with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("image", self.image)
.opt("web", self.web)
.opt("maps", self.maps)
.opt("retrievedContext", self.retrieved_context)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingChunk with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingChunk with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
image: @sdkjson.opt_field(obj, "image", path),
web: @sdkjson.opt_field(obj, "web", path),
maps: @sdkjson.opt_field(obj, "maps", path),
retrieved_context: @sdkjson.opt_field(obj, "retrievedContext", path),
}
}
///|
///
/// Metadata returned to client when grounding is enabled.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingMetadata {
grounding_supports : Array[GoogleAiGenerativelanguageV1betaGroundingSupport]?
search_entry_point : SearchEntryPoint?
google_maps_widget_context_token : String?
image_search_queries : Array[String]?
retrieval_metadata : RetrievalMetadata?
grounding_chunks : Array[GroundingChunk]?
web_search_queries : Array[String]?
}
///|
pub extend GroundingMetadata with Eq::{equal, not_equal}
///|
pub extend GroundingMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingMetadata with omitted optional fields absent.
pub fn GroundingMetadata::new(
grounding_supports? : Array[GoogleAiGenerativelanguageV1betaGroundingSupport],
search_entry_point? : SearchEntryPoint,
google_maps_widget_context_token? : String,
image_search_queries? : Array[String],
retrieval_metadata? : RetrievalMetadata,
grounding_chunks? : Array[GroundingChunk],
web_search_queries? : Array[String],
) -> GroundingMetadata {
{
grounding_supports,
search_entry_point,
google_maps_widget_context_token,
image_search_queries,
retrieval_metadata,
grounding_chunks,
web_search_queries,
}
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingMetadata with ToJson::{to_json}
///|
pub impl ToJson for GroundingMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("groundingSupports", self.grounding_supports)
.opt("searchEntryPoint", self.search_entry_point)
.opt("googleMapsWidgetContextToken", self.google_maps_widget_context_token)
.opt("imageSearchQueries", self.image_search_queries)
.opt("retrievalMetadata", self.retrieval_metadata)
.opt("groundingChunks", self.grounding_chunks)
.opt("webSearchQueries", self.web_search_queries)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
grounding_supports: @sdkjson.opt_field(obj, "groundingSupports", path),
search_entry_point: @sdkjson.opt_field(obj, "searchEntryPoint", path),
google_maps_widget_context_token: @sdkjson.opt_field(
obj, "googleMapsWidgetContextToken", path,
),
image_search_queries: @sdkjson.opt_field(obj, "imageSearchQueries", path),
retrieval_metadata: @sdkjson.opt_field(obj, "retrievalMetadata", path),
grounding_chunks: @sdkjson.opt_field(obj, "groundingChunks", path),
web_search_queries: @sdkjson.opt_field(obj, "webSearchQueries", path),
}
}
///|
///
/// Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating tokens. Enum values: FINISH_REASON_UNSPECIFIED: Default value. This value is unused.; STOP: Natural stop point of the model or provided stop sequence.; MAX_TOKENS: The maximum number of tokens as specified in the request was reached.; SAFETY: The response candidate content was flagged for safety reasons.; RECITATION: The response candidate content was flagged for recitation reasons.; LANGUAGE: The response candidate content was flagged for using an unsupported language.; OTHER: Unknown reason.; BLOCKLIST: Token generation stopped because the content contains forbidden terms.; PROHIBITED_CONTENT: Token generation stopped for potentially containing prohibited content.; SPII: Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII).; MALFORMED_FUNCTION_CALL: The function call generated by the model is invalid.; IMAGE_SAFETY: Token generation stopped because generated images contain safety violations.; IMAGE_PROHIBITED_CONTENT: Image generation stopped because generated images has other prohibited content.; IMAGE_OTHER: Image generation stopped because of other miscellaneous issue.; NO_IMAGE: The model was expected to generate an image, but none was generated.; IMAGE_RECITATION: Image generation stopped due to recitation.; UNEXPECTED_TOOL_CALL: Model generated a tool call but no tools were enabled in the request.; TOO_MANY_TOOL_CALLS: Model called too many tools consecutively, thus the system exited execution.; MISSING_THOUGHT_SIGNATURE: Request has at least one thought signature missing.; MALFORMED_RESPONSE: Finished due to malformed response.; ESCALATION: Request was filtered by an escalation rule.; PUP_LIMITED_DISABLED: Indicates that token generation stopped because the user account is limited or disabled due to Prohibited Use Policy (PUP) violations.; CONTINUATION: Token generation was stopped because the response reached the per-request token limit, but generation is not yet complete. The model response can be continued via a subsequent request using the returned `continuation_token`. Note, the `max_output_tokens` is cumulative across continuation hops and must be monotonically increased or omitted.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum CandidateFinishReason {
FINISHREASONUNSPECIFIED
STOP
MAXTOKENS
SAFETY
RECITATION
LANGUAGE
OTHER
BLOCKLIST
PROHIBITEDCONTENT
SPII
MALFORMEDFUNCTIONCALL
IMAGESAFETY
IMAGEPROHIBITEDCONTENT
IMAGEOTHER
NOIMAGE
IMAGERECITATION
UNEXPECTEDTOOLCALL
TOOMANYTOOLCALLS
MISSINGTHOUGHTSIGNATURE
MALFORMEDRESPONSE
ESCALATION
PUPLIMITEDDISABLED
CONTINUATION
Unknown(String)
}
///|
pub extend CandidateFinishReason with Eq::{equal, not_equal}
///|
pub extend CandidateFinishReason with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend CandidateFinishReason with ToJson::{to_json}
///|
pub impl ToJson for CandidateFinishReason with fn to_json(self) {
let raw = match self {
CandidateFinishReason::FINISHREASONUNSPECIFIED =>
"FINISH_REASON_UNSPECIFIED"
CandidateFinishReason::STOP => "STOP"
CandidateFinishReason::MAXTOKENS => "MAX_TOKENS"
CandidateFinishReason::SAFETY => "SAFETY"
CandidateFinishReason::RECITATION => "RECITATION"
CandidateFinishReason::LANGUAGE => "LANGUAGE"
CandidateFinishReason::OTHER => "OTHER"
CandidateFinishReason::BLOCKLIST => "BLOCKLIST"
CandidateFinishReason::PROHIBITEDCONTENT => "PROHIBITED_CONTENT"
CandidateFinishReason::SPII => "SPII"
CandidateFinishReason::MALFORMEDFUNCTIONCALL => "MALFORMED_FUNCTION_CALL"
CandidateFinishReason::IMAGESAFETY => "IMAGE_SAFETY"
CandidateFinishReason::IMAGEPROHIBITEDCONTENT => "IMAGE_PROHIBITED_CONTENT"
CandidateFinishReason::IMAGEOTHER => "IMAGE_OTHER"
CandidateFinishReason::NOIMAGE => "NO_IMAGE"
CandidateFinishReason::IMAGERECITATION => "IMAGE_RECITATION"
CandidateFinishReason::UNEXPECTEDTOOLCALL => "UNEXPECTED_TOOL_CALL"
CandidateFinishReason::TOOMANYTOOLCALLS => "TOO_MANY_TOOL_CALLS"
CandidateFinishReason::MISSINGTHOUGHTSIGNATURE =>
"MISSING_THOUGHT_SIGNATURE"
CandidateFinishReason::MALFORMEDRESPONSE => "MALFORMED_RESPONSE"
CandidateFinishReason::ESCALATION => "ESCALATION"
CandidateFinishReason::PUPLIMITEDDISABLED => "PUP_LIMITED_DISABLED"
CandidateFinishReason::CONTINUATION => "CONTINUATION"
CandidateFinishReason::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend CandidateFinishReason with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CandidateFinishReason with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"FINISH_REASON_UNSPECIFIED" =>
Option::Some(CandidateFinishReason::FINISHREASONUNSPECIFIED)
"STOP" => Option::Some(CandidateFinishReason::STOP)
"MAX_TOKENS" => Option::Some(CandidateFinishReason::MAXTOKENS)
"SAFETY" => Option::Some(CandidateFinishReason::SAFETY)
"RECITATION" => Option::Some(CandidateFinishReason::RECITATION)
"LANGUAGE" => Option::Some(CandidateFinishReason::LANGUAGE)
"OTHER" => Option::Some(CandidateFinishReason::OTHER)
"BLOCKLIST" => Option::Some(CandidateFinishReason::BLOCKLIST)
"PROHIBITED_CONTENT" =>
Option::Some(CandidateFinishReason::PROHIBITEDCONTENT)
"SPII" => Option::Some(CandidateFinishReason::SPII)
"MALFORMED_FUNCTION_CALL" =>
Option::Some(CandidateFinishReason::MALFORMEDFUNCTIONCALL)
"IMAGE_SAFETY" => Option::Some(CandidateFinishReason::IMAGESAFETY)
"IMAGE_PROHIBITED_CONTENT" =>
Option::Some(CandidateFinishReason::IMAGEPROHIBITEDCONTENT)
"IMAGE_OTHER" => Option::Some(CandidateFinishReason::IMAGEOTHER)
"NO_IMAGE" => Option::Some(CandidateFinishReason::NOIMAGE)
"IMAGE_RECITATION" =>
Option::Some(CandidateFinishReason::IMAGERECITATION)
"UNEXPECTED_TOOL_CALL" =>
Option::Some(CandidateFinishReason::UNEXPECTEDTOOLCALL)
"TOO_MANY_TOOL_CALLS" =>
Option::Some(CandidateFinishReason::TOOMANYTOOLCALLS)
"MISSING_THOUGHT_SIGNATURE" =>
Option::Some(CandidateFinishReason::MISSINGTHOUGHTSIGNATURE)
"MALFORMED_RESPONSE" =>
Option::Some(CandidateFinishReason::MALFORMEDRESPONSE)
"ESCALATION" => Option::Some(CandidateFinishReason::ESCALATION)
"PUP_LIMITED_DISABLED" =>
Option::Some(CandidateFinishReason::PUPLIMITEDDISABLED)
"CONTINUATION" => Option::Some(CandidateFinishReason::CONTINUATION)
_ => Option::None
}
},
raw => CandidateFinishReason::Unknown(raw),
)
}
///|
///
/// Required. The category for this rating. Enum values: HARM_CATEGORY_UNSPECIFIED: Category is unspecified.; HARM_CATEGORY_DEROGATORY: **PaLM** - Negative or harmful comments targeting identity and/or protected attribute. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_TOXICITY: **PaLM** - Content that is rude, disrespectful, or profane. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_VIOLENCE: **PaLM** - Describes scenarios depicting violence against an individual or group, or general descriptions of gore. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_SEXUAL: **PaLM** - Contains references to sexual acts or other lewd content. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_MEDICAL: **PaLM** - Promotes unchecked medical advice. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_DANGEROUS: **PaLM** - Dangerous content that promotes, facilitates, or encourages harmful acts. DEPRECATED: PaLM-only category, not supported by Gemini models.; HARM_CATEGORY_HARASSMENT: **Gemini** - Harassment content.; HARM_CATEGORY_HATE_SPEECH: **Gemini** - Hate speech and content.; HARM_CATEGORY_SEXUALLY_EXPLICIT: **Gemini** - Sexually explicit content.; HARM_CATEGORY_DANGEROUS_CONTENT: **Gemini** - Dangerous content.; HARM_CATEGORY_CIVIC_INTEGRITY: **Gemini** - Content that may be used to harm civic integrity. DEPRECATED: use enable_enhanced_civic_answers instead.; HARM_CATEGORY_JAILBREAK: **Gemini** - Prompts attempting to bypass or subvert the model's safety guidelines (jailbreak attempts).
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SafetyRatingCategory {
HARMCATEGORYUNSPECIFIED
HARMCATEGORYDEROGATORY
HARMCATEGORYTOXICITY
HARMCATEGORYVIOLENCE
HARMCATEGORYSEXUAL
HARMCATEGORYMEDICAL
HARMCATEGORYDANGEROUS
HARMCATEGORYHARASSMENT
HARMCATEGORYHATESPEECH
HARMCATEGORYSEXUALLYEXPLICIT
HARMCATEGORYDANGEROUSCONTENT
HARMCATEGORYCIVICINTEGRITY
HARMCATEGORYJAILBREAK
Unknown(String)
}
///|
pub extend SafetyRatingCategory with Eq::{equal, not_equal}
///|
pub extend SafetyRatingCategory with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SafetyRatingCategory with ToJson::{to_json}
///|
pub impl ToJson for SafetyRatingCategory with fn to_json(self) {
let raw = match self {
SafetyRatingCategory::HARMCATEGORYUNSPECIFIED => "HARM_CATEGORY_UNSPECIFIED"
SafetyRatingCategory::HARMCATEGORYDEROGATORY => "HARM_CATEGORY_DEROGATORY"
SafetyRatingCategory::HARMCATEGORYTOXICITY => "HARM_CATEGORY_TOXICITY"
SafetyRatingCategory::HARMCATEGORYVIOLENCE => "HARM_CATEGORY_VIOLENCE"
SafetyRatingCategory::HARMCATEGORYSEXUAL => "HARM_CATEGORY_SEXUAL"
SafetyRatingCategory::HARMCATEGORYMEDICAL => "HARM_CATEGORY_MEDICAL"
SafetyRatingCategory::HARMCATEGORYDANGEROUS => "HARM_CATEGORY_DANGEROUS"
SafetyRatingCategory::HARMCATEGORYHARASSMENT => "HARM_CATEGORY_HARASSMENT"
SafetyRatingCategory::HARMCATEGORYHATESPEECH => "HARM_CATEGORY_HATE_SPEECH"
SafetyRatingCategory::HARMCATEGORYSEXUALLYEXPLICIT =>
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
SafetyRatingCategory::HARMCATEGORYDANGEROUSCONTENT =>
"HARM_CATEGORY_DANGEROUS_CONTENT"
SafetyRatingCategory::HARMCATEGORYCIVICINTEGRITY =>
"HARM_CATEGORY_CIVIC_INTEGRITY"
SafetyRatingCategory::HARMCATEGORYJAILBREAK => "HARM_CATEGORY_JAILBREAK"
SafetyRatingCategory::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SafetyRatingCategory with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetyRatingCategory with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"HARM_CATEGORY_UNSPECIFIED" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYUNSPECIFIED)
"HARM_CATEGORY_DEROGATORY" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYDEROGATORY)
"HARM_CATEGORY_TOXICITY" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYTOXICITY)
"HARM_CATEGORY_VIOLENCE" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYVIOLENCE)
"HARM_CATEGORY_SEXUAL" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYSEXUAL)
"HARM_CATEGORY_MEDICAL" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYMEDICAL)
"HARM_CATEGORY_DANGEROUS" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYDANGEROUS)
"HARM_CATEGORY_HARASSMENT" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYHARASSMENT)
"HARM_CATEGORY_HATE_SPEECH" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYHATESPEECH)
"HARM_CATEGORY_SEXUALLY_EXPLICIT" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYSEXUALLYEXPLICIT)
"HARM_CATEGORY_DANGEROUS_CONTENT" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYDANGEROUSCONTENT)
"HARM_CATEGORY_CIVIC_INTEGRITY" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYCIVICINTEGRITY)
"HARM_CATEGORY_JAILBREAK" =>
Option::Some(SafetyRatingCategory::HARMCATEGORYJAILBREAK)
_ => Option::None
}
},
raw => SafetyRatingCategory::Unknown(raw),
)
}
///|
///
/// Required. The probability of harm for this content. Enum values: HARM_PROBABILITY_UNSPECIFIED: Probability is unspecified.; NEGLIGIBLE: Content has a negligible chance of being unsafe.; LOW: Content has a low chance of being unsafe.; MEDIUM: Content has a medium chance of being unsafe.; HIGH: Content has a high chance of being unsafe.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum SafetyRatingProbability {
HARMPROBABILITYUNSPECIFIED
NEGLIGIBLE
LOW
MEDIUM
HIGH
Unknown(String)
}
///|
pub extend SafetyRatingProbability with Eq::{equal, not_equal}
///|
pub extend SafetyRatingProbability with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend SafetyRatingProbability with ToJson::{to_json}
///|
pub impl ToJson for SafetyRatingProbability with fn to_json(self) {
let raw = match self {
SafetyRatingProbability::HARMPROBABILITYUNSPECIFIED =>
"HARM_PROBABILITY_UNSPECIFIED"
SafetyRatingProbability::NEGLIGIBLE => "NEGLIGIBLE"
SafetyRatingProbability::LOW => "LOW"
SafetyRatingProbability::MEDIUM => "MEDIUM"
SafetyRatingProbability::HIGH => "HIGH"
SafetyRatingProbability::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend SafetyRatingProbability with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetyRatingProbability with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"HARM_PROBABILITY_UNSPECIFIED" =>
Option::Some(SafetyRatingProbability::HARMPROBABILITYUNSPECIFIED)
"NEGLIGIBLE" => Option::Some(SafetyRatingProbability::NEGLIGIBLE)
"LOW" => Option::Some(SafetyRatingProbability::LOW)
"MEDIUM" => Option::Some(SafetyRatingProbability::MEDIUM)
"HIGH" => Option::Some(SafetyRatingProbability::HIGH)
_ => Option::None
}
},
raw => SafetyRatingProbability::Unknown(raw),
)
}
///|
///
/// Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here.
#derive(Eq, @debug.Debug)
pub(all) struct SafetyRating {
category : SafetyRatingCategory?
probability : SafetyRatingProbability?
blocked : Bool?
}
///|
pub extend SafetyRating with Eq::{equal, not_equal}
///|
pub extend SafetyRating with @debug.Debug::{to_repr}
///|
///
/// Creates a SafetyRating with omitted optional fields absent.
pub fn SafetyRating::new(
category? : SafetyRatingCategory,
probability? : SafetyRatingProbability,
blocked? : Bool,
) -> SafetyRating {
{ category, probability, blocked, }
}
///|
///
/// Encodes this value as JSON.
pub extend SafetyRating with ToJson::{to_json}
///|
pub impl ToJson for SafetyRating with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("category", self.category)
.opt("probability", self.probability)
.opt("blocked", self.blocked)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SafetyRating with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SafetyRating with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
category: @sdkjson.opt_field(obj, "category", path),
probability: @sdkjson.opt_field(obj, "probability", path),
blocked: @sdkjson.opt_field(obj, "blocked", path),
}
}
///|
///
/// Status of the url retrieval. Enum values: URL_RETRIEVAL_STATUS_UNSPECIFIED: Default value. This value is unused.; URL_RETRIEVAL_STATUS_SUCCESS: Url retrieval is successful.; URL_RETRIEVAL_STATUS_ERROR: Url retrieval is failed due to error.; URL_RETRIEVAL_STATUS_PAYWALL: Url retrieval is failed because the content is behind paywall.; URL_RETRIEVAL_STATUS_UNSAFE: Url retrieval is failed because the content is unsafe.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum UrlMetadataUrlRetrievalStatus {
URLRETRIEVALSTATUSUNSPECIFIED
URLRETRIEVALSTATUSSUCCESS
URLRETRIEVALSTATUSERROR
URLRETRIEVALSTATUSPAYWALL
URLRETRIEVALSTATUSUNSAFE
Unknown(String)
}
///|
pub extend UrlMetadataUrlRetrievalStatus with Eq::{equal, not_equal}
///|
pub extend UrlMetadataUrlRetrievalStatus with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend UrlMetadataUrlRetrievalStatus with ToJson::{to_json}
///|
pub impl ToJson for UrlMetadataUrlRetrievalStatus with fn to_json(self) {
let raw = match self {
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSUNSPECIFIED =>
"URL_RETRIEVAL_STATUS_UNSPECIFIED"
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSSUCCESS =>
"URL_RETRIEVAL_STATUS_SUCCESS"
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSERROR =>
"URL_RETRIEVAL_STATUS_ERROR"
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSPAYWALL =>
"URL_RETRIEVAL_STATUS_PAYWALL"
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSUNSAFE =>
"URL_RETRIEVAL_STATUS_UNSAFE"
UrlMetadataUrlRetrievalStatus::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend UrlMetadataUrlRetrievalStatus with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for UrlMetadataUrlRetrievalStatus with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"URL_RETRIEVAL_STATUS_UNSPECIFIED" =>
Option::Some(
UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSUNSPECIFIED,
)
"URL_RETRIEVAL_STATUS_SUCCESS" =>
Option::Some(UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSSUCCESS)
"URL_RETRIEVAL_STATUS_ERROR" =>
Option::Some(UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSERROR)
"URL_RETRIEVAL_STATUS_PAYWALL" =>
Option::Some(UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSPAYWALL)
"URL_RETRIEVAL_STATUS_UNSAFE" =>
Option::Some(UrlMetadataUrlRetrievalStatus::URLRETRIEVALSTATUSUNSAFE)
_ => Option::None
}
},
raw => UrlMetadataUrlRetrievalStatus::Unknown(raw),
)
}
///|
///
/// Context of the a single url retrieval.
#derive(Eq, @debug.Debug)
pub(all) struct UrlMetadata {
retrieved_url : String?
url_retrieval_status : UrlMetadataUrlRetrievalStatus?
}
///|
pub extend UrlMetadata with Eq::{equal, not_equal}
///|
pub extend UrlMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a UrlMetadata with omitted optional fields absent.
pub fn UrlMetadata::new(
retrieved_url? : String,
url_retrieval_status? : UrlMetadataUrlRetrievalStatus,
) -> UrlMetadata {
{ retrieved_url, url_retrieval_status, }
}
///|
///
/// Encodes this value as JSON.
pub extend UrlMetadata with ToJson::{to_json}
///|
pub impl ToJson for UrlMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("retrievedUrl", self.retrieved_url)
.opt("urlRetrievalStatus", self.url_retrieval_status)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend UrlMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for UrlMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
retrieved_url: @sdkjson.opt_field(obj, "retrievedUrl", path),
url_retrieval_status: @sdkjson.opt_field(obj, "urlRetrievalStatus", path),
}
}
///|
///
/// Metadata related to url context retrieval tool.
#derive(Eq, @debug.Debug)
pub(all) struct UrlContextMetadata {
url_metadata : Array[UrlMetadata]?
}
///|
pub extend UrlContextMetadata with Eq::{equal, not_equal}
///|
pub extend UrlContextMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a UrlContextMetadata with omitted optional fields absent.
pub fn UrlContextMetadata::new(
url_metadata? : Array[UrlMetadata],
) -> UrlContextMetadata {
{ url_metadata, }
}
///|
///
/// Encodes this value as JSON.
pub extend UrlContextMetadata with ToJson::{to_json}
///|
pub impl ToJson for UrlContextMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("urlMetadata", self.url_metadata).build()
}
///|
///
/// Decodes this value from JSON.
pub extend UrlContextMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for UrlContextMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ url_metadata: @sdkjson.opt_field(obj, "urlMetadata", path), }
}
///|
///
/// Identifier for a part within a `GroundingPassage`.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingPassageId {
passage_id : String?
part_index : Int32?
}
///|
pub extend GroundingPassageId with Eq::{equal, not_equal}
///|
pub extend GroundingPassageId with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingPassageId with omitted optional fields absent.
pub fn GroundingPassageId::new(
passage_id? : String,
part_index? : Int32,
) -> GroundingPassageId {
{ passage_id, part_index, }
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingPassageId with ToJson::{to_json}
///|
pub impl ToJson for GroundingPassageId with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("passageId", self.passage_id)
.opt("partIndex", self.part_index)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingPassageId with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingPassageId with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
passage_id: @sdkjson.opt_field(obj, "passageId", path),
part_index: @sdkjson.opt_field(obj, "partIndex", path),
}
}
///|
///
/// Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`.
#derive(Eq, @debug.Debug)
pub(all) struct SemanticRetrieverChunk {
chunk : String?
source : String?
}
///|
pub extend SemanticRetrieverChunk with Eq::{equal, not_equal}
///|
pub extend SemanticRetrieverChunk with @debug.Debug::{to_repr}
///|
///
/// Creates a SemanticRetrieverChunk with omitted optional fields absent.
pub fn SemanticRetrieverChunk::new(
chunk? : String,
source? : String,
) -> SemanticRetrieverChunk {
{ chunk, source, }
}
///|
///
/// Encodes this value as JSON.
pub extend SemanticRetrieverChunk with ToJson::{to_json}
///|
pub impl ToJson for SemanticRetrieverChunk with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("chunk", self.chunk)
.opt("source", self.source)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend SemanticRetrieverChunk with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for SemanticRetrieverChunk with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
chunk: @sdkjson.opt_field(obj, "chunk", path),
source: @sdkjson.opt_field(obj, "source", path),
}
}
///|
///
/// Identifier for the source contributing to this attribution.
#derive(Eq, @debug.Debug)
pub(all) struct AttributionSourceId {
grounding_passage : GroundingPassageId?
semantic_retriever_chunk : SemanticRetrieverChunk?
}
///|
pub extend AttributionSourceId with Eq::{equal, not_equal}
///|
pub extend AttributionSourceId with @debug.Debug::{to_repr}
///|
///
/// Creates a AttributionSourceId with omitted optional fields absent.
pub fn AttributionSourceId::new(
grounding_passage? : GroundingPassageId,
semantic_retriever_chunk? : SemanticRetrieverChunk,
) -> AttributionSourceId {
{ grounding_passage, semantic_retriever_chunk, }
}
///|
///
/// Encodes this value as JSON.
pub extend AttributionSourceId with ToJson::{to_json}
///|
pub impl ToJson for AttributionSourceId with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("groundingPassage", self.grounding_passage)
.opt("semanticRetrieverChunk", self.semantic_retriever_chunk)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend AttributionSourceId with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for AttributionSourceId with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
grounding_passage: @sdkjson.opt_field(obj, "groundingPassage", path),
semantic_retriever_chunk: @sdkjson.opt_field(
obj, "semanticRetrieverChunk", path,
),
}
}
///|
///
/// Attribution for a source that contributed to an answer.
#derive(Eq, @debug.Debug)
pub(all) struct GroundingAttribution {
source_id : AttributionSourceId?
content : Content?
}
///|
pub extend GroundingAttribution with Eq::{equal, not_equal}
///|
pub extend GroundingAttribution with @debug.Debug::{to_repr}
///|
///
/// Creates a GroundingAttribution with omitted optional fields absent.
pub fn GroundingAttribution::new(
source_id? : AttributionSourceId,
content? : Content,
) -> GroundingAttribution {
{ source_id, content, }
}
///|
///
/// Encodes this value as JSON.
pub extend GroundingAttribution with ToJson::{to_json}
///|
pub impl ToJson for GroundingAttribution with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("sourceId", self.source_id)
.opt("content", self.content)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GroundingAttribution with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GroundingAttribution with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
source_id: @sdkjson.opt_field(obj, "sourceId", path),
content: @sdkjson.opt_field(obj, "content", path),
}
}
///|
///
/// Candidates with top log probabilities at each decoding step.
#derive(Eq, @debug.Debug)
pub(all) struct TopCandidates {
candidates : Array[LogprobsResultCandidate]?
}
///|
pub extend TopCandidates with Eq::{equal, not_equal}
///|
pub extend TopCandidates with @debug.Debug::{to_repr}
///|
///
/// Creates a TopCandidates with omitted optional fields absent.
pub fn TopCandidates::new(
candidates? : Array[LogprobsResultCandidate],
) -> TopCandidates {
{ candidates, }
}
///|
///
/// Encodes this value as JSON.
pub extend TopCandidates with ToJson::{to_json}
///|
pub impl ToJson for TopCandidates with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("candidates", self.candidates).build()
}
///|
///
/// Decodes this value from JSON.
pub extend TopCandidates with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for TopCandidates with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ candidates: @sdkjson.opt_field(obj, "candidates", path), }
}
///|
///
/// Logprobs Result
#derive(Eq, @debug.Debug)
pub(all) struct LogprobsResult {
log_probability_sum : Double?
chosen_candidates : Array[LogprobsResultCandidate]?
top_candidates : Array[TopCandidates]?
}
///|
pub extend LogprobsResult with Eq::{equal, not_equal}
///|
pub extend LogprobsResult with @debug.Debug::{to_repr}
///|
///
/// Creates a LogprobsResult with omitted optional fields absent.
pub fn LogprobsResult::new(
log_probability_sum? : Double,
chosen_candidates? : Array[LogprobsResultCandidate],
top_candidates? : Array[TopCandidates],
) -> LogprobsResult {
{ log_probability_sum, chosen_candidates, top_candidates, }
}
///|
///
/// Encodes this value as JSON.
pub extend LogprobsResult with ToJson::{to_json}
///|
pub impl ToJson for LogprobsResult with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("logProbabilitySum", self.log_probability_sum)
.opt("chosenCandidates", self.chosen_candidates)
.opt("topCandidates", self.top_candidates)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend LogprobsResult with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for LogprobsResult with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
log_probability_sum: @sdkjson.opt_field(obj, "logProbabilitySum", path),
chosen_candidates: @sdkjson.opt_field(obj, "chosenCandidates", path),
top_candidates: @sdkjson.opt_field(obj, "topCandidates", path),
}
}
///|
///
/// A response candidate generated from the model.
#derive(Eq, @debug.Debug)
pub(all) struct Candidate {
continuation_token : String?
content : Content?
grounding_metadata : GroundingMetadata?
finish_reason : CandidateFinishReason?
index : Int32?
safety_ratings : Array[SafetyRating]?
finish_message : String?
url_context_metadata : UrlContextMetadata?
grounding_attributions : Array[GroundingAttribution]?
avg_logprobs : Double?
token_count : Int32?
logprobs_result : LogprobsResult?
citation_metadata : CitationMetadata?
}
///|
pub extend Candidate with Eq::{equal, not_equal}
///|
pub extend Candidate with @debug.Debug::{to_repr}
///|
///
/// Creates a Candidate with omitted optional fields absent.
pub fn Candidate::new(
continuation_token? : String,
content? : Content,
grounding_metadata? : GroundingMetadata,
finish_reason? : CandidateFinishReason,
index? : Int32,
safety_ratings? : Array[SafetyRating],
finish_message? : String,
url_context_metadata? : UrlContextMetadata,
grounding_attributions? : Array[GroundingAttribution],
avg_logprobs? : Double,
token_count? : Int32,
logprobs_result? : LogprobsResult,
citation_metadata? : CitationMetadata,
) -> Candidate {
{
continuation_token,
content,
grounding_metadata,
finish_reason,
index,
safety_ratings,
finish_message,
url_context_metadata,
grounding_attributions,
avg_logprobs,
token_count,
logprobs_result,
citation_metadata,
}
}
///|
///
/// Encodes this value as JSON.
pub extend Candidate with ToJson::{to_json}
///|
pub impl ToJson for Candidate with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("continuationToken", self.continuation_token)
.opt("content", self.content)
.opt("groundingMetadata", self.grounding_metadata)
.opt("finishReason", self.finish_reason)
.opt("index", self.index)
.opt("safetyRatings", self.safety_ratings)
.opt("finishMessage", self.finish_message)
.opt("urlContextMetadata", self.url_context_metadata)
.opt("groundingAttributions", self.grounding_attributions)
.opt("avgLogprobs", self.avg_logprobs)
.opt("tokenCount", self.token_count)
.opt("logprobsResult", self.logprobs_result)
.opt("citationMetadata", self.citation_metadata)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Candidate with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Candidate with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
continuation_token: @sdkjson.opt_field(obj, "continuationToken", path),
content: @sdkjson.opt_field(obj, "content", path),
grounding_metadata: @sdkjson.opt_field(obj, "groundingMetadata", path),
finish_reason: @sdkjson.opt_field(obj, "finishReason", path),
index: @sdkjson.opt_field(obj, "index", path),
safety_ratings: @sdkjson.opt_field(obj, "safetyRatings", path),
finish_message: @sdkjson.opt_field(obj, "finishMessage", path),
url_context_metadata: @sdkjson.opt_field(obj, "urlContextMetadata", path),
grounding_attributions: @sdkjson.opt_field(
obj, "groundingAttributions", path,
),
avg_logprobs: @sdkjson.opt_field(obj, "avgLogprobs", path),
token_count: @sdkjson.opt_field(obj, "tokenCount", path),
logprobs_result: @sdkjson.opt_field(obj, "logprobsResult", path),
citation_metadata: @sdkjson.opt_field(obj, "citationMetadata", path),
}
}
///|
///
/// Metadata for a video `File`.
#derive(Eq, @debug.Debug)
pub(all) struct VideoFileMetadata {
video_duration : String?
}
///|
pub extend VideoFileMetadata with Eq::{equal, not_equal}
///|
pub extend VideoFileMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a VideoFileMetadata with omitted optional fields absent.
pub fn VideoFileMetadata::new(video_duration? : String) -> VideoFileMetadata {
{ video_duration, }
}
///|
///
/// Encodes this value as JSON.
pub extend VideoFileMetadata with ToJson::{to_json}
///|
pub impl ToJson for VideoFileMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("videoDuration", self.video_duration).build()
}
///|
///
/// Decodes this value from JSON.
pub extend VideoFileMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for VideoFileMetadata with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ video_duration: @sdkjson.opt_field(obj, "videoDuration", path), }
}
///|
///
/// Output only. Processing state of the File. Enum values: STATE_UNSPECIFIED: The default value. This value is used if the state is omitted.; PROCESSING: File is being processed and cannot be used for inference yet.; ACTIVE: File is processed and available for inference.; FAILED: File failed processing.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FileState {
STATEUNSPECIFIED
PROCESSING
ACTIVE
FAILED
Unknown(String)
}
///|
pub extend FileState with Eq::{equal, not_equal}
///|
pub extend FileState with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FileState with ToJson::{to_json}
///|
pub impl ToJson for FileState with fn to_json(self) {
let raw = match self {
FileState::STATEUNSPECIFIED => "STATE_UNSPECIFIED"
FileState::PROCESSING => "PROCESSING"
FileState::ACTIVE => "ACTIVE"
FileState::FAILED => "FAILED"
FileState::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FileState with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FileState with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"STATE_UNSPECIFIED" => Option::Some(FileState::STATEUNSPECIFIED)
"PROCESSING" => Option::Some(FileState::PROCESSING)
"ACTIVE" => Option::Some(FileState::ACTIVE)
"FAILED" => Option::Some(FileState::FAILED)
_ => Option::None
}
},
raw => FileState::Unknown(raw),
)
}
///|
///
/// Source of the File. Enum values: SOURCE_UNSPECIFIED: Used if source is not specified.; UPLOADED: Indicates the file is uploaded by the user.; GENERATED: Indicates the file is generated by Google.; REGISTERED: Indicates the file is a registered, i.e. a Google Cloud Storage file.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum FileSource {
SOURCEUNSPECIFIED
UPLOADED
GENERATED
REGISTERED
Unknown(String)
}
///|
pub extend FileSource with Eq::{equal, not_equal}
///|
pub extend FileSource with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend FileSource with ToJson::{to_json}
///|
pub impl ToJson for FileSource with fn to_json(self) {
let raw = match self {
FileSource::SOURCEUNSPECIFIED => "SOURCE_UNSPECIFIED"
FileSource::UPLOADED => "UPLOADED"
FileSource::GENERATED => "GENERATED"
FileSource::REGISTERED => "REGISTERED"
FileSource::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend FileSource with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for FileSource with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"SOURCE_UNSPECIFIED" => Option::Some(FileSource::SOURCEUNSPECIFIED)
"UPLOADED" => Option::Some(FileSource::UPLOADED)
"GENERATED" => Option::Some(FileSource::GENERATED)
"REGISTERED" => Option::Some(FileSource::REGISTERED)
_ => Option::None
}
},
raw => FileSource::Unknown(raw),
)
}
///|
///
/// A file uploaded to the API.
#derive(Eq, @debug.Debug)
pub(all) struct File {
video_metadata : VideoFileMetadata?
download_uri : String?
state : FileState?
error : Status?
uri : String?
expiration_time : String?
size_bytes : Int64?
mime_type : String?
source : FileSource?
sha256_hash : String?
create_time : String?
display_name : String?
name : String?
update_time : String?
}
///|
pub extend File with Eq::{equal, not_equal}
///|
pub extend File with @debug.Debug::{to_repr}
///|
///
/// Creates a File with omitted optional fields absent.
pub fn File::new(
video_metadata? : VideoFileMetadata,
download_uri? : String,
state? : FileState,
error? : Status,
uri? : String,
expiration_time? : String,
size_bytes? : Int64,
mime_type? : String,
source? : FileSource,
sha256_hash? : String,
create_time? : String,
display_name? : String,
name? : String,
update_time? : String,
) -> File {
{
video_metadata,
download_uri,
state,
error,
uri,
expiration_time,
size_bytes,
mime_type,
source,
sha256_hash,
create_time,
display_name,
name,
update_time,
}
}
///|
///
/// Encodes this value as JSON.
pub extend File with ToJson::{to_json}
///|
pub impl ToJson for File with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("videoMetadata", self.video_metadata)
.opt("downloadUri", self.download_uri)
.opt("state", self.state)
.opt("error", self.error)
.opt("uri", self.uri)
.opt("expirationTime", self.expiration_time)
.opt(
"sizeBytes",
self.size_bytes.map(value => json_string_int64_to_json(value)),
)
.opt("mimeType", self.mime_type)
.opt("source", self.source)
.opt("sha256Hash", self.sha256_hash)
.opt("createTime", self.create_time)
.opt("displayName", self.display_name)
.opt("name", self.name)
.opt("updateTime", self.update_time)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend File with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for File with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
video_metadata: @sdkjson.opt_field(obj, "videoMetadata", path),
download_uri: @sdkjson.opt_field(obj, "downloadUri", path),
state: @sdkjson.opt_field(obj, "state", path),
error: @sdkjson.opt_field(obj, "error", path),
uri: @sdkjson.opt_field(obj, "uri", path),
expiration_time: @sdkjson.opt_field(obj, "expirationTime", path),
size_bytes: decode_optional_custom(obj, "sizeBytes", path, (
value,
value_path,
) => json_string_int64(value, value_path)),
mime_type: @sdkjson.opt_field(obj, "mimeType", path),
source: @sdkjson.opt_field(obj, "source", path),
sha256_hash: @sdkjson.opt_field(obj, "sha256Hash", path),
create_time: @sdkjson.opt_field(obj, "createTime", path),
display_name: @sdkjson.opt_field(obj, "displayName", path),
name: @sdkjson.opt_field(obj, "name", path),
update_time: @sdkjson.opt_field(obj, "updateTime", path),
}
}
///|
///
/// Request for `CreateFile`.
#derive(Eq, @debug.Debug)
pub(all) struct CreateFileRequest {
file : File?
}
///|
pub extend CreateFileRequest with Eq::{equal, not_equal}
///|
pub extend CreateFileRequest with @debug.Debug::{to_repr}
///|
///
/// Creates a CreateFileRequest with omitted optional fields absent.
pub fn CreateFileRequest::new(file? : File) -> CreateFileRequest {
{ file, }
}
///|
///
/// Encodes this value as JSON.
pub extend CreateFileRequest with ToJson::{to_json}
///|
pub impl ToJson for CreateFileRequest with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("file", self.file).build()
}
///|
///
/// Decodes this value from JSON.
pub extend CreateFileRequest with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CreateFileRequest with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ file: @sdkjson.opt_field(obj, "file", path), }
}
///|
///
/// Information about a Generative Language Model.
#derive(Eq, @debug.Debug)
pub(all) struct Model {
name : String?
top_p : Double?
thinking : Bool?
output_token_limit : Int32?
description : String?
top_k : Int32?
max_temperature : Double?
version : String?
base_model_id : String?
input_token_limit : Int32?
supported_generation_methods : Array[String]?
temperature : Double?
display_name : String?
}
///|
pub extend Model with Eq::{equal, not_equal}
///|
pub extend Model with @debug.Debug::{to_repr}
///|
///
/// Creates a Model with omitted optional fields absent.
pub fn Model::new(
name? : String,
top_p? : Double,
thinking? : Bool,
output_token_limit? : Int32,
description? : String,
top_k? : Int32,
max_temperature? : Double,
version? : String,
base_model_id? : String,
input_token_limit? : Int32,
supported_generation_methods? : Array[String],
temperature? : Double,
display_name? : String,
) -> Model {
{
name,
top_p,
thinking,
output_token_limit,
description,
top_k,
max_temperature,
version,
base_model_id,
input_token_limit,
supported_generation_methods,
temperature,
display_name,
}
}
///|
///
/// Encodes this value as JSON.
pub extend Model with ToJson::{to_json}
///|
pub impl ToJson for Model with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("name", self.name)
.opt("topP", self.top_p)
.opt("thinking", self.thinking)
.opt("outputTokenLimit", self.output_token_limit)
.opt("description", self.description)
.opt("topK", self.top_k)
.opt("maxTemperature", self.max_temperature)
.opt("version", self.version)
.opt("baseModelId", self.base_model_id)
.opt("inputTokenLimit", self.input_token_limit)
.opt("supportedGenerationMethods", self.supported_generation_methods)
.opt("temperature", self.temperature)
.opt("displayName", self.display_name)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend Model with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for Model with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
name: @sdkjson.opt_field(obj, "name", path),
top_p: @sdkjson.opt_field(obj, "topP", path),
thinking: @sdkjson.opt_field(obj, "thinking", path),
output_token_limit: @sdkjson.opt_field(obj, "outputTokenLimit", path),
description: @sdkjson.opt_field(obj, "description", path),
top_k: @sdkjson.opt_field(obj, "topK", path),
max_temperature: @sdkjson.opt_field(obj, "maxTemperature", path),
version: @sdkjson.opt_field(obj, "version", path),
base_model_id: @sdkjson.opt_field(obj, "baseModelId", path),
input_token_limit: @sdkjson.opt_field(obj, "inputTokenLimit", path),
supported_generation_methods: @sdkjson.opt_field(
obj, "supportedGenerationMethods", path,
),
temperature: @sdkjson.opt_field(obj, "temperature", path),
display_name: @sdkjson.opt_field(obj, "displayName", path),
}
}
///|
///
/// Optional. If set, the prompt was blocked and no candidates are returned. Rephrase the prompt. Enum values: BLOCK_REASON_UNSPECIFIED: Default value. This value is unused.; SAFETY: Prompt was blocked due to safety reasons. Inspect `safety_ratings` to understand which safety category blocked it.; OTHER: Prompt was blocked due to unknown reasons.; BLOCKLIST: Prompt was blocked due to the terms which are included from the terminology blocklist.; PROHIBITED_CONTENT: Prompt was blocked due to prohibited content.; IMAGE_SAFETY: Candidates blocked due to unsafe image generation content.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum PromptFeedbackBlockReason {
BLOCKREASONUNSPECIFIED
SAFETY
OTHER
BLOCKLIST
PROHIBITEDCONTENT
IMAGESAFETY
Unknown(String)
}
///|
pub extend PromptFeedbackBlockReason with Eq::{equal, not_equal}
///|
pub extend PromptFeedbackBlockReason with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend PromptFeedbackBlockReason with ToJson::{to_json}
///|
pub impl ToJson for PromptFeedbackBlockReason with fn to_json(self) {
let raw = match self {
PromptFeedbackBlockReason::BLOCKREASONUNSPECIFIED =>
"BLOCK_REASON_UNSPECIFIED"
PromptFeedbackBlockReason::SAFETY => "SAFETY"
PromptFeedbackBlockReason::OTHER => "OTHER"
PromptFeedbackBlockReason::BLOCKLIST => "BLOCKLIST"
PromptFeedbackBlockReason::PROHIBITEDCONTENT => "PROHIBITED_CONTENT"
PromptFeedbackBlockReason::IMAGESAFETY => "IMAGE_SAFETY"
PromptFeedbackBlockReason::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend PromptFeedbackBlockReason with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PromptFeedbackBlockReason with fn from_json(
value,
path,
) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"BLOCK_REASON_UNSPECIFIED" =>
Option::Some(PromptFeedbackBlockReason::BLOCKREASONUNSPECIFIED)
"SAFETY" => Option::Some(PromptFeedbackBlockReason::SAFETY)
"OTHER" => Option::Some(PromptFeedbackBlockReason::OTHER)
"BLOCKLIST" => Option::Some(PromptFeedbackBlockReason::BLOCKLIST)
"PROHIBITED_CONTENT" =>
Option::Some(PromptFeedbackBlockReason::PROHIBITEDCONTENT)
"IMAGE_SAFETY" => Option::Some(PromptFeedbackBlockReason::IMAGESAFETY)
_ => Option::None
}
},
raw => PromptFeedbackBlockReason::Unknown(raw),
)
}
///|
///
/// A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`.
#derive(Eq, @debug.Debug)
pub(all) struct PromptFeedback {
block_reason : PromptFeedbackBlockReason?
safety_ratings : Array[SafetyRating]?
}
///|
pub extend PromptFeedback with Eq::{equal, not_equal}
///|
pub extend PromptFeedback with @debug.Debug::{to_repr}
///|
///
/// Creates a PromptFeedback with omitted optional fields absent.
pub fn PromptFeedback::new(
block_reason? : PromptFeedbackBlockReason,
safety_ratings? : Array[SafetyRating],
) -> PromptFeedback {
{ block_reason, safety_ratings, }
}
///|
///
/// Encodes this value as JSON.
pub extend PromptFeedback with ToJson::{to_json}
///|
pub impl ToJson for PromptFeedback with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("blockReason", self.block_reason)
.opt("safetyRatings", self.safety_ratings)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend PromptFeedback with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for PromptFeedback with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
block_reason: @sdkjson.opt_field(obj, "blockReason", path),
safety_ratings: @sdkjson.opt_field(obj, "safetyRatings", path),
}
}
///|
///
/// Response from `ListModel` containing a paginated list of Models.
#derive(Eq, @debug.Debug)
pub(all) struct ListModelsResponse {
next_page_token : String?
models : Array[Model]?
}
///|
pub extend ListModelsResponse with Eq::{equal, not_equal}
///|
pub extend ListModelsResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a ListModelsResponse with omitted optional fields absent.
pub fn ListModelsResponse::new(
next_page_token? : String,
models? : Array[Model],
) -> ListModelsResponse {
{ next_page_token, models, }
}
///|
///
/// Encodes this value as JSON.
pub extend ListModelsResponse with ToJson::{to_json}
///|
pub impl ToJson for ListModelsResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("nextPageToken", self.next_page_token)
.opt("models", self.models)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ListModelsResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ListModelsResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
next_page_token: @sdkjson.opt_field(obj, "nextPageToken", path),
models: @sdkjson.opt_field(obj, "models", path),
}
}
///|
///
/// Batch request to get embeddings from the model for a list of prompts.
#derive(Eq, @debug.Debug)
pub(all) struct BatchEmbedContentsRequest {
requests : Array[EmbedContentRequest]?
}
///|
pub extend BatchEmbedContentsRequest with Eq::{equal, not_equal}
///|
pub extend BatchEmbedContentsRequest with @debug.Debug::{to_repr}
///|
///
/// Creates a BatchEmbedContentsRequest with omitted optional fields absent.
pub fn BatchEmbedContentsRequest::new(
requests? : Array[EmbedContentRequest],
) -> BatchEmbedContentsRequest {
{ requests, }
}
///|
///
/// Encodes this value as JSON.
pub extend BatchEmbedContentsRequest with ToJson::{to_json}
///|
pub impl ToJson for BatchEmbedContentsRequest with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("requests", self.requests).build()
}
///|
///
/// Decodes this value from JSON.
pub extend BatchEmbedContentsRequest with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for BatchEmbedContentsRequest with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{ requests: @sdkjson.opt_field(obj, "requests", path), }
}
///|
///
/// Metadata on the usage of the cached content.
#derive(Eq, @debug.Debug)
pub(all) struct CachedContentUsageMetadata {
total_token_count : Int32?
}
///|
pub extend CachedContentUsageMetadata with Eq::{equal, not_equal}
///|
pub extend CachedContentUsageMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a CachedContentUsageMetadata with omitted optional fields absent.
pub fn CachedContentUsageMetadata::new(
total_token_count? : Int32,
) -> CachedContentUsageMetadata {
{ total_token_count, }
}
///|
///
/// Encodes this value as JSON.
pub extend CachedContentUsageMetadata with ToJson::{to_json}
///|
pub impl ToJson for CachedContentUsageMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("totalTokenCount", self.total_token_count)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CachedContentUsageMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CachedContentUsageMetadata with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{ total_token_count: @sdkjson.opt_field(obj, "totalTokenCount", path), }
}
///|
///
/// Content that has been preprocessed and can be used in subsequent request to GenerativeService. Cached content can be only used with model it was created for.
#derive(Eq, @debug.Debug)
pub(all) struct CachedContent {
expire_time : String?
update_time : String?
display_name : String?
create_time : String?
contents : Array[Content]?
name : String?
tools : Array[Tool]?
model : String?
system_instruction : Content?
usage_metadata : CachedContentUsageMetadata?
tool_config : ToolConfig?
ttl : String?
}
///|
pub extend CachedContent with Eq::{equal, not_equal}
///|
pub extend CachedContent with @debug.Debug::{to_repr}
///|
///
/// Creates a CachedContent with omitted optional fields absent.
pub fn CachedContent::new(
expire_time? : String,
update_time? : String,
display_name? : String,
create_time? : String,
contents? : Array[Content],
name? : String,
tools? : Array[Tool],
model? : String,
system_instruction? : Content,
usage_metadata? : CachedContentUsageMetadata,
tool_config? : ToolConfig,
ttl? : String,
) -> CachedContent {
{
expire_time,
update_time,
display_name,
create_time,
contents,
name,
tools,
model,
system_instruction,
usage_metadata,
tool_config,
ttl,
}
}
///|
///
/// Encodes this value as JSON.
pub extend CachedContent with ToJson::{to_json}
///|
pub impl ToJson for CachedContent with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("expireTime", self.expire_time)
.opt("updateTime", self.update_time)
.opt("displayName", self.display_name)
.opt("createTime", self.create_time)
.opt("contents", self.contents)
.opt("name", self.name)
.opt("tools", self.tools)
.opt("model", self.model)
.opt("systemInstruction", self.system_instruction)
.opt("usageMetadata", self.usage_metadata)
.opt("toolConfig", self.tool_config)
.opt("ttl", self.ttl)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend CachedContent with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CachedContent with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
expire_time: @sdkjson.opt_field(obj, "expireTime", path),
update_time: @sdkjson.opt_field(obj, "updateTime", path),
display_name: @sdkjson.opt_field(obj, "displayName", path),
create_time: @sdkjson.opt_field(obj, "createTime", path),
contents: @sdkjson.opt_field(obj, "contents", path),
name: @sdkjson.opt_field(obj, "name", path),
tools: @sdkjson.opt_field(obj, "tools", path),
model: @sdkjson.opt_field(obj, "model", path),
system_instruction: @sdkjson.opt_field(obj, "systemInstruction", path),
usage_metadata: @sdkjson.opt_field(obj, "usageMetadata", path),
tool_config: @sdkjson.opt_field(obj, "toolConfig", path),
ttl: @sdkjson.opt_field(obj, "ttl", path),
}
}
///|
///
/// Metadata on the usage of the embedding request.
#derive(Eq, @debug.Debug)
pub(all) struct EmbeddingUsageMetadata {
prompt_token_count : Int32?
prompt_token_details : Array[ModalityTokenCount]?
}
///|
pub extend EmbeddingUsageMetadata with Eq::{equal, not_equal}
///|
pub extend EmbeddingUsageMetadata with @debug.Debug::{to_repr}
///|
///
/// Creates a EmbeddingUsageMetadata with omitted optional fields absent.
pub fn EmbeddingUsageMetadata::new(
prompt_token_count? : Int32,
prompt_token_details? : Array[ModalityTokenCount],
) -> EmbeddingUsageMetadata {
{ prompt_token_count, prompt_token_details, }
}
///|
///
/// Encodes this value as JSON.
pub extend EmbeddingUsageMetadata with ToJson::{to_json}
///|
pub impl ToJson for EmbeddingUsageMetadata with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("promptTokenCount", self.prompt_token_count)
.opt("promptTokenDetails", self.prompt_token_details)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend EmbeddingUsageMetadata with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbeddingUsageMetadata with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
prompt_token_count: @sdkjson.opt_field(obj, "promptTokenCount", path),
prompt_token_details: @sdkjson.opt_field(obj, "promptTokenDetails", path),
}
}
///|
///
/// A list of floats representing an embedding.
#derive(Eq, @debug.Debug)
pub(all) struct ContentEmbedding {
shape : Array[Int32]?
values : Array[Double]?
}
///|
pub extend ContentEmbedding with Eq::{equal, not_equal}
///|
pub extend ContentEmbedding with @debug.Debug::{to_repr}
///|
///
/// Creates a ContentEmbedding with omitted optional fields absent.
pub fn ContentEmbedding::new(
shape? : Array[Int32],
values? : Array[Double],
) -> ContentEmbedding {
{ shape, values, }
}
///|
///
/// Encodes this value as JSON.
pub extend ContentEmbedding with ToJson::{to_json}
///|
pub impl ToJson for ContentEmbedding with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("shape", self.shape)
.opt("values", self.values)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ContentEmbedding with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ContentEmbedding with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
shape: @sdkjson.opt_field(obj, "shape", path),
values: @sdkjson.opt_field(obj, "values", path),
}
}
///|
///
/// The response to an `EmbedContentRequest`.
#derive(Eq, @debug.Debug)
pub(all) struct EmbedContentResponse {
usage_metadata : EmbeddingUsageMetadata?
embedding : ContentEmbedding?
}
///|
pub extend EmbedContentResponse with Eq::{equal, not_equal}
///|
pub extend EmbedContentResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a EmbedContentResponse with omitted optional fields absent.
pub fn EmbedContentResponse::new(
usage_metadata? : EmbeddingUsageMetadata,
embedding? : ContentEmbedding,
) -> EmbedContentResponse {
{ usage_metadata, embedding, }
}
///|
///
/// Encodes this value as JSON.
pub extend EmbedContentResponse with ToJson::{to_json}
///|
pub impl ToJson for EmbedContentResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("usageMetadata", self.usage_metadata)
.opt("embedding", self.embedding)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend EmbedContentResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for EmbedContentResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
usage_metadata: @sdkjson.opt_field(obj, "usageMetadata", path),
embedding: @sdkjson.opt_field(obj, "embedding", path),
}
}
///|
///
/// Response for `CreateFile`.
#derive(Eq, @debug.Debug)
pub(all) struct CreateFileResponse {
file : File?
}
///|
pub extend CreateFileResponse with Eq::{equal, not_equal}
///|
pub extend CreateFileResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a CreateFileResponse with omitted optional fields absent.
pub fn CreateFileResponse::new(file? : File) -> CreateFileResponse {
{ file, }
}
///|
///
/// Encodes this value as JSON.
pub extend CreateFileResponse with ToJson::{to_json}
///|
pub impl ToJson for CreateFileResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new().opt("file", self.file).build()
}
///|
///
/// Decodes this value from JSON.
pub extend CreateFileResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for CreateFileResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ file: @sdkjson.opt_field(obj, "file", path), }
}
///|
///
/// The stage of the underlying model. Enum values: MODEL_STAGE_UNSPECIFIED: Unspecified model stage.; UNSTABLE_EXPERIMENTAL: The underlying model is subject to lots of tunings.; EXPERIMENTAL: Models in this stage are for experimental purposes only.; PREVIEW: Models in this stage are more mature than experimental models.; STABLE: Models in this stage are considered stable and ready for production use.; LEGACY: If the model is on this stage, it means that this model is on the path to deprecation in near future. Only existing customers can use this model.; DEPRECATED: Models in this stage are deprecated. These models cannot be used.; RETIRED: Models in this stage are retired. These models cannot be used.
#derive(Eq, @debug.Debug)
#non_exhaustive
pub(all) enum ModelStatusModelStage {
MODELSTAGEUNSPECIFIED
UNSTABLEEXPERIMENTAL
EXPERIMENTAL
PREVIEW
STABLE
LEGACY
DEPRECATED
RETIRED
Unknown(String)
}
///|
pub extend ModelStatusModelStage with Eq::{equal, not_equal}
///|
pub extend ModelStatusModelStage with @debug.Debug::{to_repr}
///|
///
/// Encodes this string enum as JSON.
pub extend ModelStatusModelStage with ToJson::{to_json}
///|
pub impl ToJson for ModelStatusModelStage with fn to_json(self) {
let raw = match self {
ModelStatusModelStage::MODELSTAGEUNSPECIFIED => "MODEL_STAGE_UNSPECIFIED"
ModelStatusModelStage::UNSTABLEEXPERIMENTAL => "UNSTABLE_EXPERIMENTAL"
ModelStatusModelStage::EXPERIMENTAL => "EXPERIMENTAL"
ModelStatusModelStage::PREVIEW => "PREVIEW"
ModelStatusModelStage::STABLE => "STABLE"
ModelStatusModelStage::LEGACY => "LEGACY"
ModelStatusModelStage::DEPRECATED => "DEPRECATED"
ModelStatusModelStage::RETIRED => "RETIRED"
ModelStatusModelStage::Unknown(raw) => raw
}
@json.Json::Json(raw)
}
///|
///
/// Decodes this string enum from JSON.
pub extend ModelStatusModelStage with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ModelStatusModelStage with fn from_json(value, path) {
@sdkjson.open_string(
value,
path,
raw => {
match raw {
"MODEL_STAGE_UNSPECIFIED" =>
Option::Some(ModelStatusModelStage::MODELSTAGEUNSPECIFIED)
"UNSTABLE_EXPERIMENTAL" =>
Option::Some(ModelStatusModelStage::UNSTABLEEXPERIMENTAL)
"EXPERIMENTAL" => Option::Some(ModelStatusModelStage::EXPERIMENTAL)
"PREVIEW" => Option::Some(ModelStatusModelStage::PREVIEW)
"STABLE" => Option::Some(ModelStatusModelStage::STABLE)
"LEGACY" => Option::Some(ModelStatusModelStage::LEGACY)
"DEPRECATED" => Option::Some(ModelStatusModelStage::DEPRECATED)
"RETIRED" => Option::Some(ModelStatusModelStage::RETIRED)
_ => Option::None
}
},
raw => ModelStatusModelStage::Unknown(raw),
)
}
///|
///
/// The status of the underlying model. This is used to indicate the stage of the underlying model and the retirement time if applicable.
#derive(Eq, @debug.Debug)
pub(all) struct ModelStatus {
retirement_time : String?
message : String?
model_stage : ModelStatusModelStage?
}
///|
pub extend ModelStatus with Eq::{equal, not_equal}
///|
pub extend ModelStatus with @debug.Debug::{to_repr}
///|
///
/// Creates a ModelStatus with omitted optional fields absent.
pub fn ModelStatus::new(
retirement_time? : String,
message? : String,
model_stage? : ModelStatusModelStage,
) -> ModelStatus {
{ retirement_time, message, model_stage, }
}
///|
///
/// Encodes this value as JSON.
pub extend ModelStatus with ToJson::{to_json}
///|
pub impl ToJson for ModelStatus with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("retirementTime", self.retirement_time)
.opt("message", self.message)
.opt("modelStage", self.model_stage)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ModelStatus with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ModelStatus with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
retirement_time: @sdkjson.opt_field(obj, "retirementTime", path),
message: @sdkjson.opt_field(obj, "message", path),
model_stage: @sdkjson.opt_field(obj, "modelStage", path),
}
}
///|
///
/// Response with CachedContents list.
#derive(Eq, @debug.Debug)
pub(all) struct ListCachedContentsResponse {
cached_contents : Array[CachedContent]?
next_page_token : String?
}
///|
pub extend ListCachedContentsResponse with Eq::{equal, not_equal}
///|
pub extend ListCachedContentsResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a ListCachedContentsResponse with omitted optional fields absent.
pub fn ListCachedContentsResponse::new(
cached_contents? : Array[CachedContent],
next_page_token? : String,
) -> ListCachedContentsResponse {
{ cached_contents, next_page_token, }
}
///|
///
/// Encodes this value as JSON.
pub extend ListCachedContentsResponse with ToJson::{to_json}
///|
pub impl ToJson for ListCachedContentsResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("cachedContents", self.cached_contents)
.opt("nextPageToken", self.next_page_token)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ListCachedContentsResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ListCachedContentsResponse with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
cached_contents: @sdkjson.opt_field(obj, "cachedContents", path),
next_page_token: @sdkjson.opt_field(obj, "nextPageToken", path),
}
}
///|
///
/// Response from the model supporting multiple candidate responses. Safety ratings and content filtering are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API: - Returns either all requested candidates or none of them - Returns no candidates at all only if there was something wrong with the prompt (check `prompt_feedback`) - Reports feedback on each candidate in `finish_reason` and `safety_ratings`.
#derive(Eq, @debug.Debug)
pub(all) struct GenerateContentResponse {
candidates : Array[Candidate]?
prompt_feedback : PromptFeedback?
response_id : String?
model_version : String?
model_status : ModelStatus?
usage_metadata : UsageMetadata?
}
///|
pub extend GenerateContentResponse with Eq::{equal, not_equal}
///|
pub extend GenerateContentResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a GenerateContentResponse with omitted optional fields absent.
pub fn GenerateContentResponse::new(
candidates? : Array[Candidate],
prompt_feedback? : PromptFeedback,
response_id? : String,
model_version? : String,
model_status? : ModelStatus,
usage_metadata? : UsageMetadata,
) -> GenerateContentResponse {
{
candidates,
prompt_feedback,
response_id,
model_version,
model_status,
usage_metadata,
}
}
///|
///
/// Encodes this value as JSON.
pub extend GenerateContentResponse with ToJson::{to_json}
///|
pub impl ToJson for GenerateContentResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("candidates", self.candidates)
.opt("promptFeedback", self.prompt_feedback)
.opt("responseId", self.response_id)
.opt("modelVersion", self.model_version)
.opt("modelStatus", self.model_status)
.opt("usageMetadata", self.usage_metadata)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GenerateContentResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GenerateContentResponse with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
candidates: @sdkjson.opt_field(obj, "candidates", path),
prompt_feedback: @sdkjson.opt_field(obj, "promptFeedback", path),
response_id: @sdkjson.opt_field(obj, "responseId", path),
model_version: @sdkjson.opt_field(obj, "modelVersion", path),
model_status: @sdkjson.opt_field(obj, "modelStatus", path),
usage_metadata: @sdkjson.opt_field(obj, "usageMetadata", path),
}
}
///|
///
/// Response for `ListFiles`.
#derive(Eq, @debug.Debug)
pub(all) struct ListFilesResponse {
next_page_token : String?
files : Array[File]?
}
///|
pub extend ListFilesResponse with Eq::{equal, not_equal}
///|
pub extend ListFilesResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a ListFilesResponse with omitted optional fields absent.
pub fn ListFilesResponse::new(
next_page_token? : String,
files? : Array[File],
) -> ListFilesResponse {
{ next_page_token, files, }
}
///|
///
/// Encodes this value as JSON.
pub extend ListFilesResponse with ToJson::{to_json}
///|
pub impl ToJson for ListFilesResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("nextPageToken", self.next_page_token)
.opt("files", self.files)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend ListFilesResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for ListFilesResponse with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
next_page_token: @sdkjson.opt_field(obj, "nextPageToken", path),
files: @sdkjson.opt_field(obj, "files", path),
}
}
///|
///
/// The response to a `BatchEmbedContentsRequest`.
#derive(Eq, @debug.Debug)
pub(all) struct BatchEmbedContentsResponse {
embeddings : Array[ContentEmbedding]?
usage_metadata : EmbeddingUsageMetadata?
}
///|
pub extend BatchEmbedContentsResponse with Eq::{equal, not_equal}
///|
pub extend BatchEmbedContentsResponse with @debug.Debug::{to_repr}
///|
///
/// Creates a BatchEmbedContentsResponse with omitted optional fields absent.
pub fn BatchEmbedContentsResponse::new(
embeddings? : Array[ContentEmbedding],
usage_metadata? : EmbeddingUsageMetadata,
) -> BatchEmbedContentsResponse {
{ embeddings, usage_metadata, }
}
///|
///
/// Encodes this value as JSON.
pub extend BatchEmbedContentsResponse with ToJson::{to_json}
///|
pub impl ToJson for BatchEmbedContentsResponse with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.opt("embeddings", self.embeddings)
.opt("usageMetadata", self.usage_metadata)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend BatchEmbedContentsResponse with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for BatchEmbedContentsResponse with fn from_json(
value,
path,
) {
let obj = @sdkjson.expect_object(value, path)
{
embeddings: @sdkjson.opt_field(obj, "embeddings", path),
usage_metadata: @sdkjson.opt_field(obj, "usageMetadata", path),
}
}
///|
///
/// Generated representation of GoogleErrorStatus.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleErrorStatus {
code : Int32
message : String
status : String
details : Array[Json]?
}
///|
pub extend GoogleErrorStatus with Eq::{equal, not_equal}
///|
pub extend GoogleErrorStatus with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleErrorStatus with omitted optional fields absent.
pub fn GoogleErrorStatus::new(
code~ : Int32,
message~ : String,
status~ : String,
details? : Array[Json],
) -> GoogleErrorStatus {
{ code, message, status, details, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleErrorStatus with ToJson::{to_json}
///|
pub impl ToJson for GoogleErrorStatus with fn to_json(self) {
@sdkjson.ObjBuilder::new()
.field("code", self.code)
.field("message", self.message)
.field("status", self.status)
.opt("details", self.details)
.build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleErrorStatus with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GoogleErrorStatus with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{
code: required_field(obj, "code", path),
message: required_field(obj, "message", path),
status: required_field(obj, "status", path),
details: @sdkjson.opt_field(obj, "details", path),
}
}
///|
///
/// Generated representation of GoogleError.
#derive(Eq, @debug.Debug)
pub(all) struct GoogleError {
error : GoogleErrorStatus
}
///|
pub extend GoogleError with Eq::{equal, not_equal}
///|
pub extend GoogleError with @debug.Debug::{to_repr}
///|
///
/// Creates a GoogleError with omitted optional fields absent.
pub fn GoogleError::new(error~ : GoogleErrorStatus) -> GoogleError {
{ error, }
}
///|
///
/// Encodes this value as JSON.
pub extend GoogleError with ToJson::{to_json}
///|
pub impl ToJson for GoogleError with fn to_json(self) {
@sdkjson.ObjBuilder::new().field("error", self.error).build()
}
///|
///
/// Decodes this value from JSON.
pub extend GoogleError with @json.FromJson::{from_json}
///|
pub impl @json.FromJson for GoogleError with fn from_json(value, path) {
let obj = @sdkjson.expect_object(value, path)
{ error: required_field(obj, "error", path), }
}