Skip serializing None
fields in Gemini API (#29632)
Release Notes: - N/A
This commit is contained in:
parent
b1395c5fdf
commit
b4732235e3
1 changed files with 30 additions and 4 deletions
|
@ -124,8 +124,11 @@ pub struct GenerateContentRequest {
|
||||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||||
pub model: String,
|
pub model: String,
|
||||||
pub contents: Vec<Content>,
|
pub contents: Vec<Content>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub system_instruction: Option<SystemInstruction>,
|
pub system_instruction: Option<SystemInstruction>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub generation_config: Option<GenerationConfig>,
|
pub generation_config: Option<GenerationConfig>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub safety_settings: Option<Vec<SafetySetting>>,
|
pub safety_settings: Option<Vec<SafetySetting>>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tools: Option<Vec<Tool>>,
|
pub tools: Option<Vec<Tool>>,
|
||||||
|
@ -136,19 +139,27 @@ pub struct GenerateContentRequest {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GenerateContentResponse {
|
pub struct GenerateContentResponse {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub candidates: Option<Vec<GenerateContentCandidate>>,
|
pub candidates: Option<Vec<GenerateContentCandidate>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub prompt_feedback: Option<PromptFeedback>,
|
pub prompt_feedback: Option<PromptFeedback>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub usage_metadata: Option<UsageMetadata>,
|
pub usage_metadata: Option<UsageMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GenerateContentCandidate {
|
pub struct GenerateContentCandidate {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub index: Option<usize>,
|
pub index: Option<usize>,
|
||||||
pub content: Content,
|
pub content: Content,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub finish_reason: Option<String>,
|
pub finish_reason: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub finish_message: Option<String>,
|
pub finish_message: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub safety_ratings: Option<Vec<SafetyRating>>,
|
pub safety_ratings: Option<Vec<SafetyRating>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub citation_metadata: Option<CitationMetadata>,
|
pub citation_metadata: Option<CitationMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,9 +227,13 @@ pub struct FunctionResponsePart {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CitationSource {
|
pub struct CitationSource {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub start_index: Option<usize>,
|
pub start_index: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub end_index: Option<usize>,
|
pub end_index: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub uri: Option<String>,
|
pub uri: Option<String>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub license: Option<String>,
|
pub license: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,30 +246,44 @@ pub struct CitationMetadata {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PromptFeedback {
|
pub struct PromptFeedback {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub block_reason: Option<String>,
|
pub block_reason: Option<String>,
|
||||||
pub safety_ratings: Vec<SafetyRating>,
|
pub safety_ratings: Vec<SafetyRating>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub block_reason_message: Option<String>,
|
pub block_reason_message: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct UsageMetadata {
|
pub struct UsageMetadata {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub prompt_token_count: Option<usize>,
|
pub prompt_token_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub cached_content_token_count: Option<usize>,
|
pub cached_content_token_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub candidates_token_count: Option<usize>,
|
pub candidates_token_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub tool_use_prompt_token_count: Option<usize>,
|
pub tool_use_prompt_token_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub thoughts_token_count: Option<usize>,
|
pub thoughts_token_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub total_token_count: Option<usize>,
|
pub total_token_count: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GenerationConfig {
|
pub struct GenerationConfig {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub candidate_count: Option<usize>,
|
pub candidate_count: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub stop_sequences: Option<Vec<String>>,
|
pub stop_sequences: Option<Vec<String>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub max_output_tokens: Option<usize>,
|
pub max_output_tokens: Option<usize>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub temperature: Option<f64>,
|
pub temperature: Option<f64>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub top_p: Option<f64>,
|
pub top_p: Option<f64>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub top_k: Option<usize>,
|
pub top_k: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,16 +321,13 @@ pub enum HarmCategory {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
pub enum HarmBlockThreshold {
|
pub enum HarmBlockThreshold {
|
||||||
#[serde(rename = "HARM_BLOCK_THRESHOLD_UNSPECIFIED")]
|
#[serde(rename = "HARM_BLOCK_THRESHOLD_UNSPECIFIED")]
|
||||||
Unspecified,
|
Unspecified,
|
||||||
#[serde(rename = "BLOCK_LOW_AND_ABOVE")]
|
|
||||||
BlockLowAndAbove,
|
BlockLowAndAbove,
|
||||||
#[serde(rename = "BLOCK_MEDIUM_AND_ABOVE")]
|
|
||||||
BlockMediumAndAbove,
|
BlockMediumAndAbove,
|
||||||
#[serde(rename = "BLOCK_ONLY_HIGH")]
|
|
||||||
BlockOnlyHigh,
|
BlockOnlyHigh,
|
||||||
#[serde(rename = "BLOCK_NONE")]
|
|
||||||
BlockNone,
|
BlockNone,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue