pub struct Session { /* private fields */ }Expand description
Stateful multi-turn conversation manager.
Automatically tracks message history and compresses the context when it approaches the configured token budget, so callers never have to think about context windows.
Implementations§
Source§impl Session
impl Session
pub fn new<C: OllamaClient + 'static>( client: Arc<C>, model: impl Into<String>, config: SessionConfig, ) -> Self
Sourcepub fn set_system_prompt(&mut self, prompt: impl Into<String>)
pub fn set_system_prompt(&mut self, prompt: impl Into<String>)
Prepend a system prompt. Replaces any existing system message.
Sourcepub async fn ask(
&mut self,
user_input: impl Into<String>,
) -> Result<String, OxideError>
pub async fn ask( &mut self, user_input: impl Into<String>, ) -> Result<String, OxideError>
Send a user message and return the assistant’s reply. History is updated automatically on both sides.
Sourcepub fn estimated_tokens(&self) -> usize
pub fn estimated_tokens(&self) -> usize
Estimated tokens currently in the context.
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl !UnwindSafe for Session
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