objectiveai_sdk/functions/inventions/recursive/response/streaming/
function_invention_chunk.rs1use crate::functions;
2use serde::{Deserialize, Serialize};
3use schemars::JsonSchema;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, arbitrary::Arbitrary)]
6#[schemars(rename = "functions.inventions.recursive.response.streaming.FunctionInventionChunk")]
7pub struct FunctionInventionChunk {
8 #[arbitrary(with = crate::arbitrary_util::arbitrary_u64)]
9 pub index: u64,
10 #[serde(flatten)]
11 pub inner:
12 functions::inventions::response::streaming::FunctionInventionChunk,
13}
14
15impl FunctionInventionChunk {
16 pub fn push(&mut self, other: &FunctionInventionChunk) {
17 self.inner.push(&other.inner);
18 }
19
20 #[cfg(feature = "filesystem")]
25 pub fn produce_files(&self) -> (serde_json::Value, Vec<crate::filesystem::logs::LogFile>) {
26 let (mut reference, files) = match self.inner.produce_files() {
27 Some((reference, files)) => (reference, files),
28 None => return (serde_json::json!({ "type": "reference", "index": self.index }), Vec::new()),
29 };
30 if let Some(map) = reference.as_object_mut() {
31 map.insert("index".to_string(), serde_json::json!(self.index));
32 }
33 (reference, files)
34 }
35}