pub struct SyncStatefulChat { /* private fields */ }Expand description
Blocking wrapper for stateful chat interactions.
Implementations§
Source§impl SyncStatefulChat
impl SyncStatefulChat
Sourcepub fn append(
&mut self,
role: Role,
content: impl Into<MessageContent>,
) -> &mut Self
pub fn append( &mut self, role: Role, content: impl Into<MessageContent>, ) -> &mut Self
Append a message to local state.
Sourcepub fn append_system(&mut self, content: impl Into<String>) -> &mut Self
pub fn append_system(&mut self, content: impl Into<String>) -> &mut Self
Append a system message.
Sourcepub fn append_user(&mut self, content: impl Into<MessageContent>) -> &mut Self
pub fn append_user(&mut self, content: impl Into<MessageContent>) -> &mut Self
Append a user message.
Sourcepub fn append_assistant(&mut self, content: impl Into<String>) -> &mut Self
pub fn append_assistant(&mut self, content: impl Into<String>) -> &mut Self
Append an assistant message.
Sourcepub fn append_tool_result(
&mut self,
tool_call_id: impl Into<String>,
content: impl Into<String>,
) -> &mut Self
pub fn append_tool_result( &mut self, tool_call_id: impl Into<String>, content: impl Into<String>, ) -> &mut Self
Append a tool result message.
Sourcepub fn append_message(&mut self, message: Message) -> &mut Self
pub fn append_message(&mut self, message: Message) -> &mut Self
Append a pre-built message.
Sourcepub fn pending_tool_calls(&self) -> &[ToolCall]
pub fn pending_tool_calls(&self) -> &[ToolCall]
Get pending tool calls from the latest sampled response.
Sourcepub fn take_pending_tool_calls(&mut self) -> Vec<ToolCall>
pub fn take_pending_tool_calls(&mut self) -> Vec<ToolCall>
Take and clear pending tool calls.
Sourcepub fn append_response_text(&mut self, response: &Response) -> &mut Self
pub fn append_response_text(&mut self, response: &Response) -> &mut Self
Append assistant text from a sampled response.
Sourcepub fn append_response_semantics(&mut self, response: &Response) -> &mut Self
pub fn append_response_semantics(&mut self, response: &Response) -> &mut Self
Append response semantics and pending tool calls to local state.
Sourcepub fn sample_and_append(&mut self) -> Result<Response>
pub fn sample_and_append(&mut self) -> Result<Response>
Sample and append response semantics.
Sourcepub fn sample_with_tool_loop<H>(&mut self, handler: H) -> Result<Response>
pub fn sample_with_tool_loop<H>(&mut self, handler: H) -> Result<Response>
Run a blocking tool loop with default max rounds.
Trait Implementations§
Source§impl Clone for SyncStatefulChat
impl Clone for SyncStatefulChat
Source§fn clone(&self) -> SyncStatefulChat
fn clone(&self) -> SyncStatefulChat
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 moreAuto Trait Implementations§
impl Freeze for SyncStatefulChat
impl !RefUnwindSafe for SyncStatefulChat
impl Send for SyncStatefulChat
impl Sync for SyncStatefulChat
impl Unpin for SyncStatefulChat
impl UnsafeUnpin for SyncStatefulChat
impl !UnwindSafe for SyncStatefulChat
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