Updates FunctionResponse

This commit is contained in:
2025-12-02 10:15:29 +00:00
parent 46525071e9
commit 5fb31d468b
2 changed files with 9 additions and 10 deletions

View File

@@ -1,7 +1,8 @@
use std::{env, error::Error};
use google_genai::prelude::{
Content, FunctionDeclaration, GeminiClient, GenerateContentRequest, Part, PartData, Role, Tools,
Content, FunctionDeclaration, FunctionResponse, GeminiClient, GenerateContentRequest, Part,
PartData, Role, Tools,
};
use serde_json::json;
@@ -85,12 +86,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
contents.push(Content {
role: Some(Role::User),
parts: Some(vec![Part {
data: PartData::FunctionResponse {
data: PartData::FunctionResponse(FunctionResponse {
id: id.clone(),
name: name.clone(),
response: json!({"result": 1234}),
will_continue: None,
},
parts: None,
scheduling: None,
}),
media_resolution: None,
part_metadata: None,
thought: None,

View File

@@ -3,6 +3,8 @@ use std::{fmt::Display, str::FromStr, vec};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::types::FunctionResponse;
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
pub struct Content {
pub role: Option<Role>,
@@ -118,13 +120,7 @@ pub enum PartData {
args: Option<Value>,
},
// https://ai.google.dev/api/caching#FunctionResponse
FunctionResponse {
id: Option<String>,
name: String,
response: Value,
will_continue: Option<bool>,
// TODO: Add remaining fields.
},
FunctionResponse(FunctionResponse),
FileData(Value),
ExecutableCode(Value),
CodeExecutionResult(Value),