11use serde:: { Deserialize , Serialize } ;
2+ use serde_json:: Value ;
23use std:: collections:: HashMap ;
34
45#[ derive( Debug , Serialize , Deserialize ) ]
@@ -23,11 +24,24 @@ pub struct GenerateContentRequest {
2324#[ derive( Debug , Serialize , Deserialize ) ]
2425#[ serde( untagged) ]
2526pub enum ToolConfig {
27+ // will work for both v1 and v2 models
2628 #[ serde( rename = "function_declaration" ) ]
2729 FunctionDeclaration ( ToolConfigFunctionDeclaration ) ,
30+
31+ /* NOTE: For v1 models will be depreciated by google in 2025 */
2832 DynamicRetieval {
2933 google_search_retrieval : DynamicRetrieval ,
3034 } ,
35+
36+ /* NOTE: Used by v2 models if they have search built in */
37+ GoogleSearch {
38+ google_search : serde_json:: Value ,
39+ } ,
40+
41+ /* NOTE: Used by v2 models if they have the code execution built in */
42+ CodeExecution {
43+ code_execution : serde_json:: Value ,
44+ } ,
3145}
3246
3347#[ derive( Debug , Serialize , Deserialize ) ]
@@ -44,6 +58,10 @@ pub enum ContentPart {
4458 FunctionCall ( FunctionCall ) ,
4559 #[ serde( rename = "functionResponse" ) ]
4660 FunctionResponse ( FunctionResponse ) ,
61+ #[ serde( rename = "executableCode" ) ]
62+ ExecutableCode ( ExecutableCode ) ,
63+ #[ serde( rename = "codeExecutionResult" ) ]
64+ CodeExecutionResult ( Value ) ,
4765}
4866
4967#[ derive( Debug , Serialize , Deserialize ) ]
@@ -111,6 +129,10 @@ pub enum PartResponse {
111129 FunctionCall ( FunctionCall ) ,
112130 #[ serde( rename = "functionResponse" ) ]
113131 FunctionResponse ( FunctionResponse ) ,
132+ #[ serde( rename = "executableCode" ) ]
133+ ExecutableCode ( ExecutableCode ) ,
134+ #[ serde( rename = "codeExecutionResult" ) ]
135+ CodeExecutionResult ( Value ) ,
114136}
115137
116138#[ derive( Debug , Serialize , Deserialize , Clone ) ]
@@ -130,3 +152,8 @@ pub struct FunctionResponse {
130152pub struct FunctionResponsePayload {
131153 pub content : serde_json:: Value ,
132154}
155+
156+ #[ derive( Debug , Serialize , Deserialize ) ]
157+ pub struct ExecutableCode {
158+ pub code : String ,
159+ }
0 commit comments