pub enum Delta {
BeginPart {
part_id: PartId,
kind: PartKind,
},
AppendText {
part_id: PartId,
chunk: String,
},
AppendBytes {
part_id: PartId,
chunk: Vec<u8>,
},
ReplaceStructured {
part_id: PartId,
value: Value,
},
SetMetadata {
part_id: PartId,
metadata: MetadataMap,
},
CommitPart {
part: Part,
},
}Expand description
An incremental update emitted while a model turn is streaming.
The provider adapter emits a sequence of Delta values that the loop and
reporters consume to reconstruct the full Item progressively. A typical
sequence looks like:
BeginPart– allocates a new part buffer.- One or more
AppendText/AppendBytes– fills the buffer. CommitPart– finalises the part.
§Example
use agentkit_core::{Delta, PartId, PartKind};
let deltas = vec![
Delta::BeginPart { part_id: PartId::new("p1"), kind: PartKind::Text },
Delta::AppendText { part_id: PartId::new("p1"), chunk: "Hello".into() },
Delta::AppendText { part_id: PartId::new("p1"), chunk: ", world!".into() },
];
assert_eq!(deltas.len(), 3);Variants§
BeginPart
Signals the start of a new part with the given kind.
Fields
AppendText
Appends a text chunk to an in-progress part.
AppendBytes
Appends raw bytes to an in-progress part.
ReplaceStructured
Replaces the structured value of an in-progress part wholesale.
SetMetadata
Sets or replaces the metadata on an in-progress part.
CommitPart
Finalises a part, providing the fully assembled Part.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Delta
impl<'de> Deserialize<'de> for Delta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Delta
Auto Trait Implementations§
impl Freeze for Delta
impl RefUnwindSafe for Delta
impl Send for Delta
impl Sync for Delta
impl Unpin for Delta
impl UnsafeUnpin for Delta
impl UnwindSafe for Delta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more