objectiveai-sdk 2.0.6

ObjectiveAI SDK, definitions, and utilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
//! Function types and client-side compilation.
//!
//! # Output Computation
//!
//! Functions do **not** have a top-level output expression. Instead, each task has its
//! own `output` expression that transforms its raw result into a [`TaskOutputOwned`].
//! The function's final output is computed as a **weighted average** of all task outputs
//! using profile weights.
//!
//! - If a function has only 1 task, that task's output becomes the function's output directly
//! - If a function has multiple tasks, each task's output is weighted and averaged
//!
//! Each task's `output` expression must return a valid `TaskOutputOwned` for the function's type:
//! - **Scalar functions**: each task must return `Scalar(value)` where value is in [0, 1]
//! - **Vector functions**: each task must return `Vector(values)` where values sum to ~1
//!
//! [`TaskOutputOwned`]: super::expression::TaskOutputOwned

use serde::{Deserialize, Serialize};
use schemars::JsonSchema;

/// A Function definition, either remote or inline.
///
/// Functions are composable scoring pipelines that transform structured input
/// into scores. Each task has an `output` expression that transforms its raw result
/// into a `TaskOutputOwned`. The function's final output is the weighted average of
/// all task outputs using profile weights.
///
/// Use [`compile_tasks`](Self::compile_tasks) to preview how task expressions resolve
/// for given inputs.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "functions.Function")]
pub enum Function {
    /// A remote function with metadata (description, schema, etc.).
    #[schemars(title = "Remote")]
    Remote(RemoteFunction),
    /// An inline function definition without metadata.
    #[schemars(title = "Inline")]
    Inline(InlineFunction),
}

impl Function {
    /// Validates the input against the function's input schema.
    ///
    /// For remote functions, checks whether the provided input conforms to
    /// the function's JSON Schema definition. For inline functions, returns
    /// `None` since they lack schema definitions.
    ///
    /// # Returns
    ///
    /// - `Some(true)` if the input is valid against the schema
    /// - `Some(false)` if the input is invalid
    /// - `None` for inline functions (no schema to validate against)
    pub fn validate_input(
        &self,
        input: &super::expression::InputValue,
    ) -> Option<bool> {
        match self {
            Function::Remote(remote_function) => {
                Some(remote_function.input_schema().validate_input(input))
            }
            Function::Inline(_) => None,
        }
    }

    /// Compiles task expressions to show the final tasks for a given input.
    ///
    /// Evaluates all expressions (JMESPath or Starlark) in the function's tasks
    /// using the provided input data. Tasks with `skip` expressions that evaluate
    /// to true return `None`. Tasks with `map` fields produce multiple task instances.
    ///
    /// # Returns
    ///
    /// A vector where each element corresponds to a task definition:
    /// - `None` if the task was skipped
    /// - `Some(CompiledTask::One(...))` for non-mapped tasks
    /// - `Some(CompiledTask::Many(...))` for mapped tasks
    pub fn compile_tasks(
        self,
        input: &super::expression::InputValue,
    ) -> Result<
        Vec<Option<super::CompiledTask>>,
        super::expression::ExpressionError,
    > {
        // extract task expressions
        let task_exprs = match self {
            Function::Remote(RemoteFunction::Scalar { tasks, .. }) => tasks,
            Function::Remote(RemoteFunction::Vector { tasks, .. }) => tasks,
            Function::Inline(InlineFunction::Scalar { tasks, .. }) => tasks,
            Function::Inline(InlineFunction::Vector { tasks, .. }) => tasks,
        };

        // prepare params for compiling expressions
        let mut params =
            super::expression::Params::Ref(super::expression::ParamsRef {
                input,
                output: None,
                map: None,
                tasks_min: None,
                tasks_max: None,
                depth: None,
                name: None,
                spec: None,
            });

        // compile tasks
        let mut tasks = Vec::with_capacity(task_exprs.len());
        for mut task_expr in task_exprs {
            tasks.push(
                if let Some(skip_expr) = task_expr.take_skip()
                    && skip_expr.compile_one::<bool>(&params)?
                {
                    // None if task is skipped
                    None
                } else if let Some(map_expr) = task_expr.map() {
                    // evaluate map expression to get count
                    let count: u64 = map_expr.compile_one(&params)?;
                    // compile task for each map index
                    let mut map_tasks = Vec::with_capacity(count as usize);
                    for i in 0..count {
                        // set map index
                        match &mut params {
                            super::expression::Params::Ref(params_ref) => {
                                params_ref.map = Some(i);
                            }
                            _ => unreachable!(),
                        }
                        // compile task with map index
                        map_tasks.push(task_expr.clone().compile(&params)?);
                        // reset map index
                        match &mut params {
                            super::expression::Params::Ref(params_ref) => {
                                params_ref.map = None;
                            }
                            _ => unreachable!(),
                        }
                    }
                    Some(super::CompiledTask::Many(map_tasks))
                } else {
                    // compile single task
                    Some(super::CompiledTask::One(task_expr.compile(&params)?))
                },
            );
        }

        // compiled tasks
        Ok(tasks)
    }

    // /// Computes the final output given input and task outputs.
    // ///
    // /// Evaluates the function's output expression using the provided input data
    // /// and task results. Also validates that the output meets constraints:
    // /// - Scalar functions: output must be in [0, 1]
    // /// - Vector functions: output must sum to approximately 1
    // pub fn compile_output(
    //     self,
    //     input: &super::expression::InputValue,
    //     task_outputs: &[Option<super::expression::TaskOutput>],
    // ) -> Result<
    //     super::expression::CompiledFunctionOutput,
    //     super::expression::ExpressionError,
    // > {
    //     #[derive(Clone, Copy)]
    //     enum FunctionType {
    //         Scalar,
    //         Vector,
    //     }

    //     // prepare params for compiling output_length expression
    //     let mut params =
    //         super::expression::Params::Ref(super::expression::ParamsRef {
    //             input,
    //             output: None,
    //             map: None,
    //         });

    //     // extract output expression and output_length
    //     let (function_type, output_expr, output_length) = match self {
    //         Function::Remote(RemoteFunction::Scalar { output, .. }) => {
    //             (FunctionType::Scalar, output, None)
    //         }
    //         Function::Remote(RemoteFunction::Vector {
    //             output,
    //             output_length,
    //             ..
    //         }) => (
    //             FunctionType::Vector,
    //             output,
    //             Some(output_length.compile_one(&params)?),
    //         ),
    //         Function::Inline(InlineFunction::Scalar { output, .. }) => {
    //             (FunctionType::Scalar, output, None)
    //         }
    //         Function::Inline(InlineFunction::Vector { output, .. }) => {
    //             (FunctionType::Vector, output, None)
    //         }
    //     };

    //     // prepare params for compiling output expression
    //     match &mut params {
    //         super::expression::Params::Ref(params_ref) => {
    //             params_ref.tasks = task_outputs;
    //         }
    //         _ => unreachable!(),
    //     }

    //     // compile output
    //     let output = output_expr
    //         .compile_one::<super::expression::FunctionOutput>(&params)?;

    //     // validate output
    //     let valid = match (function_type, &output, output_length) {
    //         (
    //             FunctionType::Scalar,
    //             &super::expression::FunctionOutput::Scalar(scalar),
    //             _,
    //         ) => {
    //             scalar >= rust_decimal::Decimal::ZERO
    //                 && scalar <= rust_decimal::Decimal::ONE
    //         }
    //         (
    //             FunctionType::Vector,
    //             super::expression::FunctionOutput::Vector(vector),
    //             Some(length),
    //         ) => {
    //             let sum = vector.iter().sum::<rust_decimal::Decimal>();
    //             vector.len() == length as usize
    //                 && sum >= rust_decimal::dec!(0.99)
    //                 && sum <= rust_decimal::dec!(1.01)
    //         }
    //         (
    //             FunctionType::Vector,
    //             super::expression::FunctionOutput::Vector(vector),
    //             None,
    //         ) => {
    //             let sum = vector.iter().sum::<rust_decimal::Decimal>();
    //             sum >= rust_decimal::dec!(0.99)
    //                 && sum <= rust_decimal::dec!(1.01)
    //         }
    //         _ => false,
    //     };

    //     // compiled output
    //     Ok(super::expression::CompiledFunctionOutput { output, valid })
    // }

    /// Computes the expected output length for a vector function.
    ///
    /// Evaluates the `output_length` expression to determine how many elements
    /// the output vector should contain. This is only applicable to remote
    /// vector functions which have an `output_length` field.
    ///
    /// # Arguments
    ///
    /// * `input` - The function input used to compute the output length
    ///
    /// # Returns
    ///
    /// - `Ok(Some(u64))` - The expected output length for remote vector functions
    /// - `Ok(None)` - For scalar functions or inline functions
    /// - `Err(ExpressionError)` - If the expression fails to compile
    pub fn compile_output_length(
        self,
        input: &super::expression::InputValue,
    ) -> Result<Option<u64>, super::expression::ExpressionError> {
        let output_length_expr = match self {
            Function::Remote(RemoteFunction::Scalar { .. }) => None,
            Function::Remote(RemoteFunction::Vector {
                output_length, ..
            }) => Some(output_length),
            Function::Inline(InlineFunction::Scalar { .. }) => None,
            Function::Inline(InlineFunction::Vector { .. }) => None,
        };
        match output_length_expr {
            Some(output_length_expr) => {
                // prepare params for compiling output_length expression
                let params = super::expression::Params::Ref(
                    super::expression::ParamsRef {
                        input,
                        output: None,
                        map: None,
                        tasks_min: None,
                        tasks_max: None,
                        depth: None,
                        name: None,
                        spec: None,
                    },
                );
                // compile output_length
                let output_length = output_length_expr.compile_one(&params)?;
                Ok(Some(output_length))
            }
            None => Ok(None),
        }
    }

    /// Compiles the `input_split` expression to split input into multiple sub-inputs.
    ///
    /// Used by strategies like Swiss System that need to partition input into
    /// smaller pools. The expression transforms the original input into an array
    /// of inputs, where each element can be processed independently.
    ///
    /// # Arguments
    ///
    /// * `input` - The original function input to split
    ///
    /// # Returns
    ///
    /// - `Ok(Some(Vec<Input>))` - The split inputs for vector functions with `input_split` defined
    /// - `Ok(None)` - For scalar functions or functions without `input_split`
    /// - `Err(ExpressionError)` - If the expression fails to compile
    pub fn compile_input_split(
        self,
        input: &super::expression::InputValue,
    ) -> Result<
        Option<Vec<super::expression::InputValue>>,
        super::expression::ExpressionError,
    > {
        let input_split_expr = match self {
            Function::Remote(RemoteFunction::Scalar { .. }) => None,
            Function::Remote(RemoteFunction::Vector {
                input_split, ..
            }) => Some(input_split),
            Function::Inline(InlineFunction::Scalar { .. }) => None,
            Function::Inline(InlineFunction::Vector {
                input_split, ..
            }) => input_split,
        };
        match input_split_expr {
            Some(input_split_expr) => {
                // prepare params for compiling input_split expression
                let params = super::expression::Params::Ref(
                    super::expression::ParamsRef {
                        input,
                        output: None,
                        map: None,
                        tasks_min: None,
                        tasks_max: None,
                        depth: None,
                        name: None,
                        spec: None,
                    },
                );
                // compile input_split
                let input_split = input_split_expr.compile_one(&params)?;
                Ok(Some(input_split))
            }
            None => Ok(None),
        }
    }

    /// Compiles the `input_merge` expression to merge multiple sub-inputs back into one.
    ///
    /// Used by strategies like Swiss System to recombine a subset of split inputs
    /// into a single input for pool execution. The expression transforms an array
    /// of inputs (a subset from `input_split`) into a single merged input.
    ///
    /// # Arguments
    ///
    /// * `input` - An array of inputs to merge (typically a subset from `compile_input_split`)
    ///
    /// # Returns
    ///
    /// - `Ok(Some(Input))` - The merged input for vector functions with `input_merge` defined
    /// - `Ok(None)` - For scalar functions or functions without `input_merge`
    /// - `Err(ExpressionError)` - If the expression fails to compile
    pub fn compile_input_merge(
        self,
        input: &super::expression::InputValue,
    ) -> Result<
        Option<super::expression::InputValue>,
        super::expression::ExpressionError,
    > {
        let input_merge_expr = match self {
            Function::Remote(RemoteFunction::Scalar { .. }) => None,
            Function::Remote(RemoteFunction::Vector {
                input_merge, ..
            }) => Some(input_merge),
            Function::Inline(InlineFunction::Scalar { .. }) => None,
            Function::Inline(InlineFunction::Vector {
                input_merge, ..
            }) => input_merge,
        };
        match input_merge_expr {
            Some(input_merge_expr) => {
                // prepare params for compiling input_merge expression
                let params = super::expression::Params::Ref(
                    super::expression::ParamsRef {
                        input,
                        output: None,
                        map: None,
                        tasks_min: None,
                        tasks_max: None,
                        depth: None,
                        name: None,
                        spec: None,
                    },
                );
                // compile input_merge
                let input_merge = input_merge_expr.compile_one(&params)?;
                Ok(Some(input_merge))
            }
            None => Ok(None),
        }
    }

    /// Returns the function's description, if available.
    pub fn description(&self) -> Option<&str> {
        match self {
            Function::Remote(remote_function) => {
                Some(remote_function.description())
            }
            Function::Inline(_) => None,
        }
    }

    /// Returns the function's input schema, if available.
    pub fn input_schema(&self) -> Option<&super::expression::InputSchema> {
        match self {
            Function::Remote(remote_function) => {
                Some(remote_function.input_schema())
            }
            Function::Inline(_) => None,
        }
    }

    /// Returns the function's tasks.
    pub fn tasks(&self) -> &[super::TaskExpression] {
        match self {
            Function::Remote(remote_function) => remote_function.tasks(),
            Function::Inline(inline_function) => inline_function.tasks(),
        }
    }

    /// Returns the function's expected output length expression, if defined.
    pub fn output_length(&self) -> Option<&super::expression::Expression> {
        match self {
            Function::Remote(remote_function) => {
                remote_function.output_length()
            }
            Function::Inline(_) => None,
        }
    }

    /// Returns the function's input_split expression, if defined.
    pub fn input_split(&self) -> Option<&super::expression::Expression> {
        match self {
            Function::Remote(remote_function) => remote_function.input_split(),
            Function::Inline(inline_function) => inline_function.input_split(),
        }
    }

    /// Returns the function's input_merge expression, if defined.
    pub fn input_merge(&self) -> Option<&super::expression::Expression> {
        match self {
            Function::Remote(remote_function) => remote_function.input_merge(),
            Function::Inline(inline_function) => inline_function.input_merge(),
        }
    }
}

/// A remote function with full metadata.
///
/// Remote functions are stored as `function.json` in repositories and
/// referenced by `remote/owner/repository`. They include documentation fields
/// that inline functions lack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
#[serde(tag = "type")]
#[schemars(rename = "functions.RemoteFunction")]
pub enum RemoteFunction {
    /// Produces a single score in [0, 1].
    #[schemars(title = "Scalar")]
    #[serde(rename = "scalar.function")]
    Scalar {
        /// Human-readable description of what the function does.
        description: String,
        /// JSON Schema defining the expected input structure.
        input_schema: super::expression::InputSchema,
        /// The list of tasks to execute. Tasks with a `map` expression are
        /// expanded into multiple instances. Each instance is compiled with
        /// `map` set to the current integer index.
        /// Receives: `input`, `map` (if mapped).
        tasks: Vec<super::TaskExpression>,
    },
    /// Produces a vector of scores that sums to 1.
    #[schemars(title = "Vector")]
    #[serde(rename = "vector.function")]
    Vector {
        /// Human-readable description of what the function does.
        description: String,
        /// JSON Schema defining the expected input structure.
        input_schema: super::expression::InputSchema,
        /// The list of tasks to execute. Tasks with a `map` expression are
        /// expanded into multiple instances. Each instance is compiled with
        /// `map` set to the current integer index.
        /// Receives: `input`, `map` (if mapped).
        tasks: Vec<super::TaskExpression>,
        /// Expression computing the expected output vector length for task outputs.
        /// Receives: `input`.
        output_length: super::expression::Expression,
        /// Expression transforming input into an input array of the output_length
        /// When the Function is executed with any input from the array,
        /// The output_length should be 1.
        /// Receives: `input`.
        input_split: super::expression::Expression,
        /// Expression transforming an array of inputs computed by `input_split`
        /// into a single Input object for the Function.
        /// Receives: `input` (as an array).
        input_merge: super::expression::Expression,
    },
}

impl RemoteFunction {
    /// Returns the function's description.
    pub fn description(&self) -> &str {
        match self {
            RemoteFunction::Scalar { description, .. } => description,
            RemoteFunction::Vector { description, .. } => description,
        }
    }

    /// Returns the function's input schema.
    pub fn input_schema(&self) -> &super::expression::InputSchema {
        match self {
            RemoteFunction::Scalar { input_schema, .. } => input_schema,
            RemoteFunction::Vector { input_schema, .. } => input_schema,
        }
    }

    /// Returns the function's tasks.
    pub fn tasks(&self) -> &[super::TaskExpression] {
        match self {
            RemoteFunction::Scalar { tasks, .. } => tasks,
            RemoteFunction::Vector { tasks, .. } => tasks,
        }
    }

    /// Returns the function's expected output length, if defined (vector functions only).
    pub fn output_length(&self) -> Option<&super::expression::Expression> {
        match self {
            RemoteFunction::Scalar { .. } => None,
            RemoteFunction::Vector { output_length, .. } => Some(output_length),
        }
    }

    /// Returns the function's input_split expression, if defined (vector functions only).
    pub fn input_split(&self) -> Option<&super::expression::Expression> {
        match self {
            RemoteFunction::Scalar { .. } => None,
            RemoteFunction::Vector { input_split, .. } => Some(input_split),
        }
    }

    /// Returns the function's input_merge expression, if defined (vector functions only).
    pub fn input_merge(&self) -> Option<&super::expression::Expression> {
        match self {
            RemoteFunction::Scalar { .. } => None,
            RemoteFunction::Vector { input_merge, .. } => Some(input_merge),
        }
    }

    pub fn remotes(&self) -> impl Iterator<Item = &crate::RemotePath> {
        self.tasks().iter().filter_map(|task| match task {
            super::TaskExpression::ScalarFunction(t) => Some(&t.path),
            super::TaskExpression::VectorFunction(t) => Some(&t.path),
            _ => None,
        })
    }
}

/// An inline function definition without metadata.
///
/// Used when embedding function logic directly in requests rather than
/// referencing a remote function. Lacks description and input
/// schema fields.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "type")]
#[schemars(rename = "functions.InlineFunction")]
pub enum InlineFunction {
    /// Produces a single score in [0, 1].
    #[schemars(title = "Scalar")]
    #[serde(rename = "scalar.function")]
    Scalar {
        /// The list of tasks to execute. Tasks with a `map` expression are
        /// expanded into multiple instances. Each instance is compiled with
        /// `map` set to the current integer index.
        /// Receives: `input`, `map` (if mapped).
        tasks: Vec<super::TaskExpression>,
    },
    /// Produces a vector of scores that sums to 1.
    #[schemars(title = "Vector")]
    #[serde(rename = "vector.function")]
    Vector {
        /// The list of tasks to execute. Tasks with a `map` expression are
        /// expanded into multiple instances. Each instance is compiled with
        /// `map` set to the current integer index.
        /// Receives: `input`, `map` (if mapped).
        tasks: Vec<super::TaskExpression>,
        /// Expression transforming input into an input array of the output_length
        /// When the Function is executed with any input from the array,
        /// The output_length should be 1.
        /// Receives: `input`.
        /// Only required if the request uses a strategy that needs input splitting.
        input_split: Option<super::expression::Expression>,
        /// Expression transforming an array of inputs computed by `input_split`
        /// into a single Input object for the Function.
        /// Receives: `input` (as an array).
        /// Only required if the request uses a strategy that needs input splitting.
        input_merge: Option<super::expression::Expression>,
    },
}

impl InlineFunction {
    /// Returns the function's tasks.
    pub fn tasks(&self) -> &[super::TaskExpression] {
        match self {
            InlineFunction::Scalar { tasks, .. } => tasks,
            InlineFunction::Vector { tasks, .. } => tasks,
        }
    }

    /// Returns the function's input_split expression, if defined (vector functions only).
    pub fn input_split(&self) -> Option<&super::expression::Expression> {
        match self {
            InlineFunction::Scalar { .. } => None,
            InlineFunction::Vector { input_split, .. } => input_split.as_ref(),
        }
    }

    /// Returns the function's input_merge expression, if defined (vector functions only).
    pub fn input_merge(&self) -> Option<&super::expression::Expression> {
        match self {
            InlineFunction::Scalar { .. } => None,
            InlineFunction::Vector { input_merge, .. } => input_merge.as_ref(),
        }
    }

    pub fn remotes(&self) -> impl Iterator<Item = &crate::RemotePath> {
        self.tasks().iter().filter_map(|task| match task {
            super::TaskExpression::ScalarFunction(t) => Some(&t.path),
            super::TaskExpression::VectorFunction(t) => Some(&t.path),
            _ => None,
        })
    }
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[schemars(rename = "functions.FunctionType")]
pub enum FunctionType {
    #[schemars(title = "Scalar")]
    #[serde(rename = "scalar.function")]
    Scalar,
    #[schemars(title = "Vector")]
    #[serde(rename = "vector.function")]
    Vector,
}