use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct GenerateContentRequest {
pub contents: Vec<Content>,
pub generation_config: GenerationConfig,
pub safety_settings: Vec<SafetySetting>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Content {
pub parts: Vec<Part>,
pub role: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Part {
pub text: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GenerationConfig {
#[serde(rename = "responseModalities")]
pub response_modalities: Vec<String>,
pub temperature: f32,
#[serde(rename = "maxOutputTokens")]
pub max_output_tokens: i32,
#[serde(rename = "topP")]
pub top_p: f32,
#[serde(rename = "responseMimeType")]
pub response_mime_type: String,
#[serde(rename = "responseSchema")]
pub response_schema: ResponseSchema,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ResponseSchema {
#[serde(rename = "type")]
pub schema_type: String,
pub properties: ResponseProperties,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ResponseProperties {
pub response: ResponseProperty,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ResponseProperty {
#[serde(rename = "type")]
pub property_type: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SafetySetting {
pub category: HarmCategory,
pub threshold: HarmBlockThreshold,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum HarmCategory {
#[serde(rename = "HARM_CATEGORY_HATE_SPEECH")]
HarmCategoryHateSpeech,
#[serde(rename = "HARM_CATEGORY_DANGEROUS_CONTENT")]
HarmCategoryDangerousContent,
#[serde(rename = "HARM_CATEGORY_SEXUALLY_EXPLICIT")]
HarmCategorySexuallyExplicit,
#[serde(rename = "HARM_CATEGORY_HARASSMENT")]
HarmCategoryHarassment,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum HarmBlockThreshold {
#[serde(rename = "OFF")]
Off,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct StreamResponse {
pub candidates: Option<Vec<Candidate>>,
#[serde(rename = "usageMetadata")]
pub usage_metadata: Option<UsageMetadata>,
#[serde(rename = "modelVersion")]
pub model_version: Option<String>,
#[serde(rename = "createTime")]
pub create_time: Option<String>,
#[serde(rename = "responseId")]
pub response_id: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Candidate {
pub content: CandidateContent,
#[serde(rename = "finishReason")]
pub finish_reason: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CandidateContent {
pub role: String,
pub parts: Vec<ContentPart>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ContentPart {
pub text: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct UsageMetadata {
#[serde(rename = "promptTokenCount")]
pub prompt_token_count: Option<i32>,
#[serde(rename = "candidatesTokenCount")]
pub candidates_token_count: Option<i32>,
#[serde(rename = "totalTokenCount")]
pub total_token_count: Option<i32>,
}