objectiveai_sdk/laboratories/executions/response/streaming/
builder_chunk.rs1use crate::agent;
2use serde::{Deserialize, Serialize};
3use schemars::JsonSchema;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, JsonSchema, arbitrary::Arbitrary)]
7#[schemars(rename = "laboratories.executions.response.streaming.BuilderChunk")]
8pub struct BuilderChunk {
9 #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
11 pub index: u64,
12 #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
14 pub agent_index: u64,
15 #[serde(flatten)]
16 pub inner: agent::completions::response::streaming::AgentCompletionChunk,
17}
18
19impl BuilderChunk {
20 pub fn push(&mut self, other: &BuilderChunk) {
21 self.inner.push(&other.inner);
22 }
23
24 #[cfg(feature = "filesystem")]
29 pub fn produce_files(&self) -> (serde_json::Value, Vec<crate::filesystem::logs::LogFile>) {
30 let (mut reference, files) = match self.inner.produce_files() {
31 Some((reference, files)) => (reference, files),
32 None => return (serde_json::json!({ "type": "reference", "index": self.index, "agent_index": self.agent_index }), Vec::new()),
33 };
34 if let Some(map) = reference.as_object_mut() {
35 map.insert("index".to_string(), serde_json::json!(self.index));
36 map.insert("agent_index".to_string(), serde_json::json!(self.agent_index));
37 }
38 (reference, files)
39 }
40}