gproxy_protocol/protocol/openai/common/tools/
definitions.rs1use serde::{Deserialize, Serialize};
2
3use super::super::{CustomToolGrammarSyntax, Extra, JsonSchema};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct FunctionDefinition {
7 pub name: String,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub description: Option<String>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub parameters: Option<JsonSchema>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub strict: Option<bool>,
14 #[serde(
15 default,
16 flatten,
17 skip_serializing_if = "std::collections::BTreeMap::is_empty"
18 )]
19 pub extra: Extra,
20}
21
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
23pub struct FunctionCall {
24 pub arguments: String,
25 pub name: String,
26 #[serde(
27 default,
28 flatten,
29 skip_serializing_if = "std::collections::BTreeMap::is_empty"
30 )]
31 pub extra: Extra,
32}
33
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub struct CustomToolDefinition {
36 pub name: String,
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub description: Option<String>,
39 #[serde(skip_serializing_if = "Option::is_none")]
40 pub format: Option<CustomToolInputFormat>,
41 #[serde(
42 default,
43 flatten,
44 skip_serializing_if = "std::collections::BTreeMap::is_empty"
45 )]
46 pub extra: Extra,
47}
48
49#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum CustomToolInputFormat {
52 Text(CustomToolTextFormat),
53 Grammar(CustomToolGrammarFormat),
54}
55
56#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
57#[serde(deny_unknown_fields)]
58pub struct CustomToolTextFormat {
59 #[serde(rename = "type")]
60 pub type_: CustomToolTextFormatType,
61}
62
63#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
64pub enum CustomToolTextFormatType {
65 #[serde(rename = "text")]
66 Text,
67}
68
69#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
70#[serde(deny_unknown_fields)]
71pub struct CustomToolGrammarFormat {
72 #[serde(rename = "type")]
73 pub type_: CustomToolGrammarFormatType,
74 pub grammar: CustomToolGrammar,
75}
76
77#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78pub enum CustomToolGrammarFormatType {
79 #[serde(rename = "grammar")]
80 Grammar,
81}
82
83#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
84#[serde(deny_unknown_fields)]
85pub struct CustomToolGrammar {
86 pub definition: String,
87 pub syntax: CustomToolGrammarSyntax,
88}
89
90#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
91pub struct NamedTool {
92 pub name: String,
93 #[serde(
94 default,
95 flatten,
96 skip_serializing_if = "std::collections::BTreeMap::is_empty"
97 )]
98 pub extra: Extra,
99}