pub struct Thread { /* private fields */ }Expand description
Represents a thread of conversation with the agent.
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn id(&self) -> Option<String>
pub fn id(&self) -> Option<String>
Returns the current thread id, if available.
§Example
use codex::Codex;
let codex = Codex::new(None)?;
let thread = codex.start_thread(None);
let _id = thread.id();Sourcepub async fn run_streamed(
&self,
input: impl Into<Input>,
turn_options: Option<TurnOptions>,
) -> Result<RunStreamedResult>
pub async fn run_streamed( &self, input: impl Into<Input>, turn_options: Option<TurnOptions>, ) -> Result<RunStreamedResult>
Provides input to the agent and streams events as they are produced.
§Example
use codex::{Codex, ThreadEvent};
use futures::StreamExt;
let codex = Codex::new(None)?;
let thread = codex.start_thread(None);
let mut events = thread.run_streamed("Review this code", None).await?.events;
while let Some(event) = events.next().await {
if let ThreadEvent::TurnCompleted { usage } = event? {
println!("{usage:?}");
}
}Sourcepub async fn run(
&self,
input: impl Into<Input>,
turn_options: Option<TurnOptions>,
) -> Result<Turn>
pub async fn run( &self, input: impl Into<Input>, turn_options: Option<TurnOptions>, ) -> Result<Turn>
Provides input to the agent and returns the completed turn.
§Example
use codex::Codex;
let codex = Codex::new(None)?;
let thread = codex.start_thread(None);
let turn = thread.run("Summarize current repository state", None).await?;
println!("{}", turn.final_response);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Thread
impl RefUnwindSafe for Thread
impl Send for Thread
impl Sync for Thread
impl Unpin for Thread
impl UnsafeUnpin for Thread
impl UnwindSafe for Thread
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