pub struct Conversation { /* private fields */ }Expand description
The messages of one conversation.
Implementations§
Source§impl Conversation
impl Conversation
Sourcepub fn view(&self, budget: usize) -> Vec<Value>
pub fn view(&self, budget: usize) -> Vec<Value>
The messages as they go out in a request that is at most budget bytes: the conversation
as it is when it fits, and a trimmed view of it when it does not. What is kept is kept
whole, and nothing is asked of the model to make the view smaller.
Three parts are never shortened: the first message, which usually holds the task; the newest message, which holds the tool results the model is waiting for an answer to; and the shape of a call and its result, so that every call still has its answer. What is shortened first is the tool results of the turns in between, oldest first, since they are the biggest part of an old turn and the least needed of it; the text of those turns follows in the same order, only if the results alone are not enough. Wherever something is left out, an English note stands in its place saying what was left out, and the conversation kept here is not touched.
Sourcepub fn say(&mut self, text: &str)
pub fn say(&mut self, text: &str)
Adds what the person wrote. Right after another user message (a reply that was stopped before it said anything) the text joins that message, since the API wants the roles to take turns.
Sourcepub fn reply(&mut self, content: Vec<Value>)
pub fn reply(&mut self, content: Vec<Value>)
Adds the model’s reply. Nothing is added for a reply with no content.
Sourcepub fn results(&mut self, results: Vec<Value>)
pub fn results(&mut self, results: Vec<Value>)
Adds the results of tool calls, each a tool_result block.
Sourcepub fn open_calls(&self) -> Vec<Call>
pub fn open_calls(&self) -> Vec<Call>
The tool calls of the last message that have no result yet, in the order they were made.
Trait Implementations§
Source§impl Clone for Conversation
impl Clone for Conversation
Source§impl Debug for Conversation
impl Debug for Conversation
Source§impl Default for Conversation
impl Default for Conversation
Source§impl PartialEq for Conversation
impl PartialEq for Conversation
impl StructuralPartialEq for Conversation
Auto Trait Implementations§
impl Freeze for Conversation
impl RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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