Skip to main content

ChatState

Struct ChatState 

Source
pub struct ChatState {
    pub history: Vec<ChatHistoryEntry>,
    pub tool_call_format: ToolCallFormat,
    pub tool_descriptions: HashMap<String, String>,
    pub pending_tool_calls: usize,
    /* private fields */
}
Expand description

Core chat orchestration state.

Owns conversation history, token parsing, tool call detection, and the agentic loop. No I/O — all communication is via handle_command() → Vec<ChatEvent>.

Fields§

§history: Vec<ChatHistoryEntry>§tool_call_format: ToolCallFormat§tool_descriptions: HashMap<String, String>§pending_tool_calls: usize

Implementations§

Source§

impl ChatState

Source

pub fn new(format: ToolCallFormat) -> Self

Source

pub fn handle_command(&mut self, cmd: ChatCommand) -> Vec<ChatEvent>

Process a command and return events to emit.

Source

pub fn ingest_token(&mut self, token: &str) -> Vec<ChatEvent>

Process a streaming token. Handles <think>, <tool_call>, and content separation. Returns events to emit.

Mirrors the TUI’s ChatApp::ingest_token but returns events instead of mutating UI state.

Source

pub fn needs_reinvoke(&self) -> bool

Whether the state machine needs inference to be re-invoked (e.g. after all tool results have been received). Whether the state machine needs inference to be re-invoked (after all tool results received and a new empty assistant entry is ready).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.