objectiveai_sdk/functions/inventions/
schema.rs1use indexmap::IndexMap;
2use serde::Deserialize;
3
4pub trait JsonSchema {
5 fn json_schema() -> serde_json::Map<String, serde_json::Value>;
6 fn indexmap_json_schema() -> IndexMap<String, serde_json::Value> {
7 Self::json_schema().into_iter().collect()
8 }
9}
10
11pub struct EmptyObjectJsonSchema;
12
13impl JsonSchema for EmptyObjectJsonSchema {
14 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
15 let mut map = serde_json::Map::new();
16 map.insert(
17 "type".to_string(),
18 serde_json::Value::String("object".to_string()),
19 );
20 map.insert(
21 "additionalProperties".to_string(),
22 serde_json::Value::Bool(false),
23 );
24 map
25 }
26}
27
28pub struct AnyObjectJsonSchema;
29
30impl JsonSchema for AnyObjectJsonSchema {
31 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
32 let mut map = serde_json::Map::new();
33 map.insert(
34 "type".to_string(),
35 serde_json::Value::String("object".to_string()),
36 );
37 map
38 }
39}
40
41fn string_property_schema(prop_name: &str, description: &str) -> serde_json::Map<String, serde_json::Value> {
43 let mut prop = serde_json::Map::with_capacity(2);
44 prop.insert("type".to_string(), serde_json::Value::String("string".to_string()));
45 prop.insert("description".to_string(), serde_json::Value::String(description.to_string()));
46
47 let mut properties = serde_json::Map::with_capacity(1);
48 properties.insert(prop_name.to_string(), serde_json::Value::Object(prop));
49
50 let mut map = serde_json::Map::with_capacity(4);
51 map.insert("type".to_string(), serde_json::Value::String("object".to_string()));
52 map.insert("properties".to_string(), serde_json::Value::Object(properties));
53 map.insert("required".to_string(), serde_json::Value::Array(vec![serde_json::Value::String(prop_name.to_string())]));
54 map.insert("additionalProperties".to_string(), serde_json::Value::Bool(false));
55 map
56}
57
58#[derive(Deserialize, schemars::JsonSchema)]
61#[schemars(rename = "functions.inventions.ScalarInputSchemaObject")]
62pub struct ScalarInputSchemaObject {
63 pub schema: String,
64}
65
66impl JsonSchema for ScalarInputSchemaObject {
67 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
68 string_property_schema("schema", "A JSON string conforming to the functions.expression.ObjectInputSchema schema. Use the ReadObjectInputSchemaSchema tool to see the schema definition.")
69 }
70}
71
72#[derive(Deserialize, schemars::JsonSchema)]
75#[schemars(rename = "functions.inventions.VectorInputSchemaObject")]
76pub struct VectorInputSchemaObject {
77 pub schema: String,
78}
79
80impl JsonSchema for VectorInputSchemaObject {
81 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
82 string_property_schema("schema", "A JSON string conforming to the functions.alpha_vector.expression.VectorFunctionInputSchema schema. Use the Readfunctions_alpha_vector_expression_VectorFunctionInputSchemaSchema tool to see the schema definition.")
83 }
84}
85
86#[derive(Deserialize, schemars::JsonSchema)]
89#[schemars(rename = "functions.inventions.ScalarLeafTaskObject")]
90pub struct ScalarLeafTaskObject {
91 pub task: String,
92}
93
94impl JsonSchema for ScalarLeafTaskObject {
95 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
96 string_property_schema("task", "A JSON string conforming to the functions.alpha_scalar.LeafTaskExpression schema. Use the Readfunctions_alpha_scalar_LeafTaskExpressionSchema tool to see the schema definition.")
97 }
98}
99
100#[derive(Deserialize, schemars::JsonSchema)]
103#[schemars(rename = "functions.inventions.ScalarBranchTaskObject")]
104pub struct ScalarBranchTaskObject {
105 pub task: String,
106}
107
108impl JsonSchema for ScalarBranchTaskObject {
109 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
110 string_property_schema("task", "A JSON string conforming to the functions.alpha_scalar.PartialPlaceholderBranchTaskExpression schema. Use the Readfunctions_alpha_scalar_PartialPlaceholderBranchTaskExpressionSchema tool to see the schema definition.")
111 }
112}
113
114#[derive(Deserialize, schemars::JsonSchema)]
117#[schemars(rename = "functions.inventions.VectorLeafTaskObject")]
118pub struct VectorLeafTaskObject {
119 pub task: String,
120}
121
122impl JsonSchema for VectorLeafTaskObject {
123 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
124 string_property_schema("task", "A JSON string conforming to the functions.alpha_vector.LeafTaskExpression schema. Use the Readfunctions_alpha_vector_LeafTaskExpressionSchema tool to see the schema definition.")
125 }
126}
127
128#[derive(Deserialize, schemars::JsonSchema)]
131#[schemars(rename = "functions.inventions.VectorBranchTaskObject")]
132pub struct VectorBranchTaskObject {
133 pub task: String,
134}
135
136impl JsonSchema for VectorBranchTaskObject {
137 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
138 string_property_schema("task", "A JSON string conforming to the functions.alpha_vector.PartialPlaceholderBranchTaskExpression schema. Use the Readfunctions_alpha_vector_PartialPlaceholderBranchTaskExpressionSchema tool to see the schema definition.")
139 }
140}
141
142#[derive(Deserialize, schemars::JsonSchema)]
143#[schemars(rename = "functions.inventions.IndexObject")]
144pub struct IndexObject {
145 pub index: u64,
146}
147
148impl JsonSchema for IndexObject {
149 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
150 let mut index_prop = serde_json::Map::with_capacity(1);
151 index_prop.insert(
152 "type".to_string(),
153 serde_json::Value::String("integer".to_string()),
154 );
155
156 let mut properties = serde_json::Map::with_capacity(1);
157 properties.insert(
158 "index".to_string(),
159 serde_json::Value::Object(index_prop),
160 );
161
162 let mut map = serde_json::Map::with_capacity(4);
163 map.insert(
164 "type".to_string(),
165 serde_json::Value::String("object".to_string()),
166 );
167 map.insert(
168 "properties".to_string(),
169 serde_json::Value::Object(properties),
170 );
171 map.insert(
172 "required".to_string(),
173 serde_json::Value::Array(vec![serde_json::Value::String(
174 "index".to_string(),
175 )]),
176 );
177 map.insert(
178 "additionalProperties".to_string(),
179 serde_json::Value::Bool(false),
180 );
181 map
182 }
183}
184
185#[derive(Deserialize, schemars::JsonSchema)]
186#[schemars(rename = "functions.inventions.EssayObject")]
187pub struct EssayObject {
188 pub essay: String,
189}
190
191impl JsonSchema for EssayObject {
192 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
193 let mut essay_prop = serde_json::Map::with_capacity(1);
194 essay_prop.insert(
195 "type".to_string(),
196 serde_json::Value::String("string".to_string()),
197 );
198
199 let mut properties = serde_json::Map::with_capacity(1);
200 properties.insert(
201 "essay".to_string(),
202 serde_json::Value::Object(essay_prop),
203 );
204
205 let mut map = serde_json::Map::with_capacity(4);
206 map.insert(
207 "type".to_string(),
208 serde_json::Value::String("object".to_string()),
209 );
210 map.insert(
211 "properties".to_string(),
212 serde_json::Value::Object(properties),
213 );
214 map.insert(
215 "required".to_string(),
216 serde_json::Value::Array(vec![serde_json::Value::String(
217 "essay".to_string(),
218 )]),
219 );
220 map.insert(
221 "additionalProperties".to_string(),
222 serde_json::Value::Bool(false),
223 );
224 map
225 }
226}
227
228#[derive(Deserialize, schemars::JsonSchema)]
229#[schemars(rename = "functions.inventions.EssayTasksObject")]
230pub struct EssayTasksObject {
231 pub essay_tasks: String,
232}
233
234impl JsonSchema for EssayTasksObject {
235 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
236 let mut essay_tasks_prop = serde_json::Map::with_capacity(1);
237 essay_tasks_prop.insert(
238 "type".to_string(),
239 serde_json::Value::String("string".to_string()),
240 );
241
242 let mut properties = serde_json::Map::with_capacity(1);
243 properties.insert(
244 "essay_tasks".to_string(),
245 serde_json::Value::Object(essay_tasks_prop),
246 );
247
248 let mut map = serde_json::Map::with_capacity(4);
249 map.insert(
250 "type".to_string(),
251 serde_json::Value::String("object".to_string()),
252 );
253 map.insert(
254 "properties".to_string(),
255 serde_json::Value::Object(properties),
256 );
257 map.insert(
258 "required".to_string(),
259 serde_json::Value::Array(vec![serde_json::Value::String(
260 "essay_tasks".to_string(),
261 )]),
262 );
263 map.insert(
264 "additionalProperties".to_string(),
265 serde_json::Value::Bool(false),
266 );
267 map
268 }
269}
270
271#[derive(Deserialize, schemars::JsonSchema)]
272#[schemars(rename = "functions.inventions.TasksLengthObject")]
273pub struct TasksLengthObject {
274 pub tasks_length: u64,
275}
276
277impl JsonSchema for TasksLengthObject {
278 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
279 let mut tasks_length_prop = serde_json::Map::with_capacity(1);
280 tasks_length_prop.insert(
281 "type".to_string(),
282 serde_json::Value::String("integer".to_string()),
283 );
284
285 let mut properties = serde_json::Map::with_capacity(1);
286 properties.insert(
287 "tasks_length".to_string(),
288 serde_json::Value::Object(tasks_length_prop),
289 );
290
291 let mut map = serde_json::Map::with_capacity(4);
292 map.insert(
293 "type".to_string(),
294 serde_json::Value::String("object".to_string()),
295 );
296 map.insert(
297 "properties".to_string(),
298 serde_json::Value::Object(properties),
299 );
300 map.insert(
301 "required".to_string(),
302 serde_json::Value::Array(vec![serde_json::Value::String(
303 "tasks_length".to_string(),
304 )]),
305 );
306 map.insert(
307 "additionalProperties".to_string(),
308 serde_json::Value::Bool(false),
309 );
310 map
311 }
312}
313
314#[derive(Deserialize, schemars::JsonSchema)]
315#[schemars(rename = "functions.inventions.DescriptionObject")]
316pub struct DescriptionObject {
317 pub description: String,
318}
319
320impl JsonSchema for DescriptionObject {
321 fn json_schema() -> serde_json::Map<String, serde_json::Value> {
322 let mut description_prop = serde_json::Map::with_capacity(1);
323 description_prop.insert(
324 "type".to_string(),
325 serde_json::Value::String("string".to_string()),
326 );
327
328 let mut properties = serde_json::Map::with_capacity(1);
329 properties.insert(
330 "description".to_string(),
331 serde_json::Value::Object(description_prop),
332 );
333
334 let mut map = serde_json::Map::with_capacity(4);
335 map.insert(
336 "type".to_string(),
337 serde_json::Value::String("object".to_string()),
338 );
339 map.insert(
340 "properties".to_string(),
341 serde_json::Value::Object(properties),
342 );
343 map.insert(
344 "required".to_string(),
345 serde_json::Value::Array(vec![serde_json::Value::String(
346 "description".to_string(),
347 )]),
348 );
349 map.insert(
350 "additionalProperties".to_string(),
351 serde_json::Value::Bool(false),
352 );
353 map
354 }
355}