objectiveai_sdk/functions/alpha_vector/expression/
input_value.rs1use crate::functions;
2use indexmap::IndexMap;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6pub type ScalarFunctionInputValueExpression = functions::expression::Expression;
7
8pub mod scalar_function_input_value_expression {
9 use crate::functions;
10 pub fn transpile(
11 this: super::ScalarFunctionInputValueExpression,
12 ) -> functions::expression::WithExpression<
13 functions::expression::InputValueExpression,
14 > {
15 functions::expression::WithExpression::Expression(this)
16 }
17}
18
19#[derive(
20 Debug,
21 Clone,
22 PartialEq,
23 Serialize,
24 Deserialize,
25 JsonSchema,
26 arbitrary::Arbitrary,
27)]
28#[schemars(
29 rename = "functions.alpha_vector.expression.VectorFunctionInputValueExpression"
30)]
31pub struct VectorFunctionInputValueExpression {
32 #[serde(skip_serializing_if = "Option::is_none")]
33 #[schemars(extend("omitempty" = true))]
34 pub context: Option<functions::expression::Expression>,
35 pub items: functions::expression::Expression,
36}
37
38impl VectorFunctionInputValueExpression {
39 pub fn transpile(
40 self,
41 ) -> functions::expression::WithExpression<
42 functions::expression::InputValueExpression,
43 > {
44 functions::expression::WithExpression::Value(
45 functions::expression::InputValueExpression::Object({
46 let mut map =
47 IndexMap::with_capacity(if self.context.is_some() {
48 2
49 } else {
50 1
51 });
52 if let Some(context) = self.context {
53 map.insert(
54 "context".to_string(),
55 functions::expression::WithExpression::Expression(
56 context,
57 ),
58 );
59 }
60 map.insert(
61 "items".to_string(),
62 functions::expression::WithExpression::Expression(
63 self.items,
64 ),
65 );
66 map
67 }),
68 )
69 }
70}
71
72pub type ScalarFunctionInputValue =
73 IndexMap<String, functions::expression::InputValue>;
74
75pub mod scalar_function_input_value {
76 use crate::functions;
77 pub fn transpile(
78 this: super::ScalarFunctionInputValue,
79 ) -> functions::expression::InputValue {
80 functions::expression::InputValue::Object(this)
81 }
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, JsonSchema)]
85#[schemars(
86 rename = "functions.alpha_vector.expression.VectorFunctionInputValue"
87)]
88pub struct VectorFunctionInputValue {
89 #[serde(skip_serializing_if = "Option::is_none")]
90 #[schemars(extend("omitempty" = true))]
91 pub context: Option<IndexMap<String, functions::expression::InputValue>>,
92 pub items: Vec<functions::expression::InputValue>,
93}
94
95impl VectorFunctionInputValue {
96 pub fn transpile(self) -> functions::expression::InputValue {
97 functions::expression::InputValue::Object({
98 let mut map = IndexMap::with_capacity(if self.context.is_some() {
99 2
100 } else {
101 1
102 });
103 if let Some(context) = self.context {
104 map.insert(
105 "context".to_string(),
106 functions::expression::InputValue::Object(context),
107 );
108 }
109 map.insert(
110 "items".to_string(),
111 functions::expression::InputValue::Array(self.items),
112 );
113 map
114 })
115 }
116}