pub struct Transcript<H: Harness = Common> {
pub meta: Meta,
pub body: H::Body,
}Expand description
Fields§
§meta: Meta§body: H::BodyImplementations§
Source§impl Transcript<Common>
impl Transcript<Common>
Sourcepub fn fragment(&self, span: &Span) -> Option<&[Message]>
pub fn fragment(&self, span: &Span) -> Option<&[Message]>
Resolve a Span to its messages, borrowing from this transcript.
None when the span reaches past the end of the session.
Sourcepub fn crop(&self, span: &Span) -> Result<Self, CropError>
pub fn crop(&self, span: &Span) -> Result<Self, CropError>
Create a non-destructive copy containing only span.
Metadata is preserved. A crop must contain at least one message and cannot separate a tool call from its result when both exist in the source transcript.
§Errors
When the span is invalid or splits a complete tool call/result pair.
Sourcepub fn crop_to(&self, spans: &[Span]) -> Result<Self, CropError>
pub fn crop_to(&self, spans: &[Span]) -> Result<Self, CropError>
Create a non-destructive copy containing only the messages in
spans, in their original order: the cut between one span and the
next is closed, so [0..3, 8..10] keeps five messages and drops
the five between them.
Spans may be given in any order and may overlap; together they must
name at least one message. Metadata is preserved. As with
crop, a tool call and its result are kept or
dropped together: the error names the span that holds one half and
the smallest expansion of it that holds both.
§Errors
When a span is invalid, the spans keep nothing, or a tool call is separated from its result.
Sourcepub fn tool_pairs(&self) -> Result<Vec<(usize, usize)>, CropError>
pub fn tool_pairs(&self) -> Result<Vec<(usize, usize)>, CropError>
The messages that must be kept or dropped together: each complete
tool call/result pair as (call index, result index), in the order
the results arrive. A call the transcript never answers is not a
pair.
§Errors
When a tool id is reused before its previous call resolves, or resolves more than once.