vtcode_llm/providers/gemini/wire/function_calling/
mod.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct FunctionCall {
6 pub name: String,
7 pub args: Value,
8 #[serde(default)]
9 pub id: Option<String>,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct FunctionResponse {
14 pub name: String,
15 pub response: Value,
16 #[serde(default, skip_serializing_if = "Option::is_none")]
17 pub id: Option<String>,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct FunctionCallingConfig {
22 pub(crate) mode: String,
23 #[serde(skip_serializing_if = "Option::is_none", rename = "allowedFunctionNames")]
24 pub(crate) allowed_function_names: Option<Vec<String>>,
25}
26
27const MODE_AUTO: &str = "AUTO";
29
30impl FunctionCallingConfig {
31 pub(crate) fn auto() -> Self {
32 Self {
33 mode: MODE_AUTO.to_owned(),
34 allowed_function_names: None,
35 }
36 }
37
38 pub(crate) fn validated() -> Self {
39 Self {
40 mode: "VALIDATED".to_owned(),
41 allowed_function_names: None,
42 }
43 }
44
45 pub(crate) fn none() -> Self {
46 Self {
47 mode: "NONE".to_owned(),
48 allowed_function_names: None,
49 }
50 }
51
52 pub(crate) fn any() -> Self {
53 Self {
54 mode: "ANY".to_owned(),
55 allowed_function_names: None,
56 }
57 }
58
59 pub(crate) fn is_default_auto(&self) -> bool {
62 self.mode == MODE_AUTO && self.allowed_function_names.is_none()
63 }
64}