pub struct Context {
pub messages: Vec<Message>,
pub system_prompt: Arc<Mutex<Box<dyn SystemInfo>>>,
pub tokens_limit: u32,
pub total_tokens: u32,
/* private fields */
}
Expand description
Chat context
Fields§
§messages: Vec<Message>
§system_prompt: Arc<Mutex<Box<dyn SystemInfo>>>
§tokens_limit: u32
§total_tokens: u32
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(system_prompt: Box<dyn SystemInfo>, tokens_limit: u32) -> Self
pub fn new(system_prompt: Box<dyn SystemInfo>, tokens_limit: u32) -> Self
Creates a new chat context
Sourcepub fn get_as_string(&self) -> String
pub fn get_as_string(&self) -> String
Returns all context messages as single string
Sourcepub fn count_tokens(&self, text: &str) -> u32
pub fn count_tokens(&self, text: &str) -> u32
Calculates tokens count
Sourcepub async fn update_system_info(&mut self)
pub async fn update_system_info(&mut self)
Updates the actual system info
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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