objectiveai_sdk/functions/executions/response/streaming/
function_execution_task_chunk.rs1use serde::{Deserialize, Serialize};
2use schemars::JsonSchema;
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
5#[schemars(rename = "functions.executions.response.streaming.FunctionExecutionTaskChunk")]
6pub struct FunctionExecutionTaskChunk {
7 #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
8 pub index: u64,
9 #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
10 pub task_index: u64,
11 #[arbitrary(with = crate::arbitrary_util::arbitrary_vec_u64)]
12 pub task_path: Vec<u64>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 #[schemars(extend("omitempty" = true))]
15 #[arbitrary(with = crate::arbitrary_util::arbitrary_option_u64)]
16 pub swiss_pool_index: Option<u64>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 #[schemars(extend("omitempty" = true))]
19 #[arbitrary(with = crate::arbitrary_util::arbitrary_option_u64)]
20 pub swiss_round: Option<u64>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 #[schemars(extend("omitempty" = true))]
23 #[arbitrary(with = crate::arbitrary_util::arbitrary_option_u64)]
24 pub split_index: Option<u64>,
25 #[serde(flatten)]
26 pub inner: super::FunctionExecutionChunk,
27}
28
29impl FunctionExecutionTaskChunk {
30 pub fn push(&mut self, other: &super::FunctionExecutionTaskChunk) {
31 self.inner.push(&other.inner);
32 }
33
34 #[cfg(feature = "filesystem")]
41 pub fn produce_files(&self) -> (serde_json::Value, Vec<crate::filesystem::logs::LogFile>) {
42 let (mut reference, files) = match self.inner.produce_files() {
43 Some((reference, files)) => (reference, files),
44 None => return (serde_json::json!({ "type": "reference", "index": self.index, "task_index": self.task_index, "task_path": self.task_path }), Vec::new()),
45 };
46 if let Some(map) = reference.as_object_mut() {
47 map.insert("index".to_string(), serde_json::json!(self.index));
48 map.insert("task_index".to_string(), serde_json::json!(self.task_index));
49 map.insert("task_path".to_string(), serde_json::json!(self.task_path));
50 if let Some(v) = self.swiss_pool_index {
51 map.insert("swiss_pool_index".to_string(), serde_json::json!(v));
52 }
53 if let Some(v) = self.swiss_round {
54 map.insert("swiss_round".to_string(), serde_json::json!(v));
55 }
56 if let Some(v) = self.split_index {
57 map.insert("split_index".to_string(), serde_json::json!(v));
58 }
59 }
60 (reference, files)
61 }
62}