objectiveai_sdk/functions/check/example_inputs/
video.rs1use rand::Rng;
2use rand::seq::SliceRandom;
3
4use crate::agent::completions::message::{RichContentPart, VideoUrl};
5use crate::functions::expression::{InputValue, VideoInputSchema};
6
7pub const fn permutations(_schema: &VideoInputSchema) -> usize {
8 2usize
9}
10
11pub fn generate<R: Rng>(
12 _schema: &VideoInputSchema,
13 mut rng: R,
14) -> Generator<R> {
15 let mut indices: Vec<usize> = (0..2).collect();
16 indices.shuffle(&mut rng);
17 Generator {
18 indices,
19 pos: 0,
20 rng,
21 }
22}
23
24pub struct Generator<R: Rng> {
25 indices: Vec<usize>,
26 pos: usize,
27 rng: R,
28}
29
30impl<R: Rng> Iterator for Generator<R> {
31 type Item = InputValue;
32 fn next(&mut self) -> Option<InputValue> {
33 if self.pos >= self.indices.len() {
34 self.indices.shuffle(&mut self.rng);
35 self.pos = 0;
36 }
37 let index = self.indices[self.pos];
38 self.pos += 1;
39 let video_url = VideoUrl {
40 url: super::string::random_string(&mut self.rng),
41 };
42 Some(InputValue::RichContentPart(match index {
43 0 => RichContentPart::VideoUrl { video_url },
44 _ => RichContentPart::InputVideo { video_url },
45 }))
46 }
47}