Skip to main content

objectiveai_sdk/functions/executions/response/streaming/
vector_completion_task_chunk.rs

1use crate::agent::completions::response::streaming::AgentCompletionIds;
2use crate::{error, vector};
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6#[derive(
7    Debug,
8    Clone,
9    PartialEq,
10    Serialize,
11    Deserialize,
12    Default,
13    JsonSchema,
14    arbitrary::Arbitrary,
15)]
16#[schemars(
17    rename = "functions.executions.response.streaming.VectorCompletionTaskChunk"
18)]
19pub struct VectorCompletionTaskChunk {
20    #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
21    pub index: u64,
22    #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
23    pub task_index: u64,
24    #[arbitrary(with = crate::arbitrary_util::arbitrary_vec_u64)]
25    pub task_path: Vec<u64>,
26    #[serde(flatten)]
27    pub inner: vector::completions::response::streaming::VectorCompletionChunk,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    #[schemars(extend("omitempty" = true))]
30    pub error: Option<error::ResponseError>,
31}
32
33impl AgentCompletionIds for VectorCompletionTaskChunk {
34    fn agent_completion_ids(&self) -> impl Iterator<Item = &str> + Send {
35        self.inner.agent_completion_ids()
36    }
37}
38
39impl VectorCompletionTaskChunk {
40    pub fn push(&mut self, other: &VectorCompletionTaskChunk) {
41        self.inner.push(&other.inner);
42        if let Some(error) = &other.error {
43            self.error = Some(error.clone());
44        }
45    }
46
47}