pub struct Conversation { /* private fields */ }Expand description
Multi-turn conversation manager
Implementations§
Source§impl Conversation
impl Conversation
Sourcepub fn new(template: ChatTemplate, system_prompt: impl Into<String>) -> Self
pub fn new(template: ChatTemplate, system_prompt: impl Into<String>) -> Self
Create a new conversation with a system prompt
Sourcepub fn without_system(template: ChatTemplate) -> Self
pub fn without_system(template: ChatTemplate) -> Self
Create without a system prompt
Sourcepub fn with_options(self, options: ChatTemplateOptions) -> Self
pub fn with_options(self, options: ChatTemplateOptions) -> Self
Set options (e.g., enable thinking mode)
Sourcepub fn user_turn(
&mut self,
content: impl Into<String>,
) -> Result<String, ChatTemplateError>
pub fn user_turn( &mut self, content: impl Into<String>, ) -> Result<String, ChatTemplateError>
Add a user message and return the formatted prompt for generation
Sourcepub fn assistant_response(&mut self, content: impl Into<String>)
pub fn assistant_response(&mut self, content: impl Into<String>)
Record the assistant’s response after generation
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message with a custom role
Sourcepub fn format_history(&self) -> Result<String, ChatTemplateError>
pub fn format_history(&self) -> Result<String, ChatTemplateError>
Format entire conversation for display (no generation prompt)
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> 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