pub struct Trajectory {
pub id: String,
pub session_id: String,
pub model: String,
pub timestamp: i64,
pub total_tokens: usize,
pub tool_calls: usize,
pub iterations: usize,
pub success: bool,
pub steps: Vec<TrajectoryStep>,
pub messages: Vec<TrajectoryMessage>,
pub metadata: HashMap<String, String>,
}Expand description
A complete trajectory (conversation) ready for training.
Fields§
§id: StringUnique identifier
session_id: StringSession ID this trajectory came from
model: StringModel used for generation
timestamp: i64Unix timestamp
total_tokens: usizeTotal tokens consumed
tool_calls: usizeNumber of tool calls made
iterations: usizeNumber of iterations (LLM rounds)
success: boolWhether the overall task was successful
steps: Vec<TrajectoryStep>The individual ReAct steps
messages: Vec<TrajectoryMessage>Raw messages for full fidelity
metadata: HashMap<String, String>Arbitrary metadata
Implementations§
Source§impl Trajectory
impl Trajectory
pub fn new( id: impl Into<String>, session_id: impl Into<String>, model: impl Into<String>, ) -> Self
Sourcepub fn add_step(&mut self, step: TrajectoryStep)
pub fn add_step(&mut self, step: TrajectoryStep)
Add a ReAct step to the trajectory.
Sourcepub fn record_tool_step(
&mut self,
thought: Option<String>,
action: String,
action_args: String,
observation: String,
success: bool,
)
pub fn record_tool_step( &mut self, thought: Option<String>, action: String, action_args: String, observation: String, success: bool, )
Record a ReAct tool step directly (used by the agent loop).
Sourcepub fn record_response(&mut self, response: String)
pub fn record_response(&mut self, response: String)
Record the final text response for the current step (used by loop_runner).
Sourcepub fn add_message(
&mut self,
role: &str,
content: &str,
tool_call_id: Option<&str>,
tool_name: Option<&str>,
)
pub fn add_message( &mut self, role: &str, content: &str, tool_call_id: Option<&str>, tool_name: Option<&str>, )
Add a raw message to the trajectory.
Sourcepub fn save_to_file(&self, path: &Path) -> Result<()>
pub fn save_to_file(&self, path: &Path) -> Result<()>
Save to a JSON file (alias for save). Creates parent directories.
Trait Implementations§
Source§impl Clone for Trajectory
impl Clone for Trajectory
Source§fn clone(&self) -> Trajectory
fn clone(&self) -> Trajectory
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Trajectory
impl Debug for Trajectory
Source§impl<'de> Deserialize<'de> for Trajectory
impl<'de> Deserialize<'de> for Trajectory
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
Auto Trait Implementations§
impl Freeze for Trajectory
impl RefUnwindSafe for Trajectory
impl Send for Trajectory
impl Sync for Trajectory
impl Unpin for Trajectory
impl UnsafeUnpin for Trajectory
impl UnwindSafe for Trajectory
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more