pub struct Conversation {
pub messages: Vec<Message>,
pub working_directory: PathBuf,
pub active_message_id: Option<String>,
}Expand description
A conversation history
Fields§
§messages: Vec<Message>§working_directory: PathBuf§active_message_id: Option<String>The ID of the currently active message (head of the selected branch). None means use last message semantics for backward compatibility.
Implementations§
Source§impl Conversation
impl Conversation
pub fn new() -> Self
pub fn add_message(&mut self, message: Message)
pub fn add_message_from_data(&mut self, message_data: MessageData) -> &Message
pub fn clear(&mut self)
Sourcepub fn find_tool_name_by_id(&self, tool_id: &str) -> Option<String>
pub fn find_tool_name_by_id(&self, tool_id: &str) -> Option<String>
Find the tool name by its ID by searching through assistant messages with tool calls
Sourcepub async fn compact(
&mut self,
api_client: &ApiClient,
model: Model,
token: CancellationToken,
) -> Result<CompactResult>
pub async fn compact( &mut self, api_client: &ApiClient, model: Model, token: CancellationToken, ) -> Result<CompactResult>
Compact the conversation by summarizing older messages in the active thread
Sourcepub fn edit_message(
&mut self,
message_id: &str,
new_content: Vec<UserContent>,
) -> Option<String>
pub fn edit_message( &mut self, message_id: &str, new_content: Vec<UserContent>, ) -> Option<String>
Edit a message non-destructively by creating a new branch. Returns the ID of the new message if successful.
Sourcepub fn checkout(&mut self, message_id: &str) -> bool
pub fn checkout(&mut self, message_id: &str) -> bool
Switch to another branch by setting active_message_id
Sourcepub fn get_active_thread(&self) -> Vec<&Message>
pub fn get_active_thread(&self) -> Vec<&Message>
Get messages in the currently active thread
Sourcepub fn get_thread_messages(&self) -> Vec<&Message>
pub fn get_thread_messages(&self) -> Vec<&Message>
Get messages in the current active branch by following parent links from the last message This is a thin wrapper around get_active_thread for backward compatibility
Trait Implementations§
Source§impl Clone for Conversation
impl Clone for Conversation
Source§fn clone(&self) -> Conversation
fn clone(&self) -> Conversation
Returns a duplicate of the value. Read more
1.0.0 · 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 Conversation
impl Debug for Conversation
Source§impl Default for Conversation
impl Default for Conversation
Source§impl<'de> Deserialize<'de> for Conversation
impl<'de> Deserialize<'de> for Conversation
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 Conversation
impl RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl UnwindSafe for Conversation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request