gemini_bridge 0.1.1

Types and functions to interact with Gemini AI API
Documentation
use serde::Deserialize;

#[derive(Deserialize, Debug)]
pub struct GenerateContentResponse {
    pub candidates: Vec<Candidate>,

    #[serde(rename = "usageMetadata")]
    pub usage_metadata: UsageMetadata,

    #[serde(rename = "modelVersion")]
    pub model_version: String,
}

#[derive(Deserialize, Debug)]
pub struct Candidate {
    pub content: Content,

    #[serde(rename = "finishReason")]
    pub finish_reason: String,

    pub index: i32,

    #[serde(rename = "safetyRatings")]
    pub safety_ratings: Vec<SafetyRating>,
}

#[derive(Deserialize, Debug)]
pub struct Content {
    pub parts: Vec<Part>,
    pub role: String,
}

#[derive(Deserialize, Debug)]
pub struct Part {
    pub text: String,
}

#[derive(Deserialize, Debug)]
pub struct SafetyRating {
    pub category: String,
    pub probability: String,
}

#[derive(Deserialize, Debug)]
pub struct UsageMetadata {
    #[serde(rename = "promptTokenCount")]
    pub prompt_token_count: i32,

    #[serde(rename = "candidatesTokenCount")]
    pub candidates_token_count: i32,

    #[serde(rename = "totalTokenCount")]
    pub total_token_count: i32,
}