Struct App

Source
pub struct App {
Show 17 fields pub state: AppState, pub messages: Vec<String>, pub logs: Vec<String>, pub available_models: Vec<ModelConfig>, pub error_message: Option<String>, pub last_query_time: Instant, pub use_agent: bool, pub agent: Option<Agent>, pub tokio_runtime: Option<Runtime>, pub api_key: Option<String>, pub current_working_dir: Option<String>, pub tasks: Vec<Task>, pub current_task_id: Option<String>, pub conversation_summaries: Vec<ConversationSummary>, pub session_manager: Option<SessionManager>, pub session_id: String, pub tool_executions: HashMap<String, ToolExecution>,
}
Expand description

Main backend application state

Fields§

§state: AppState§messages: Vec<String>§logs: Vec<String>§available_models: Vec<ModelConfig>§error_message: Option<String>§last_query_time: Instant§use_agent: bool§agent: Option<Agent>§tokio_runtime: Option<Runtime>§api_key: Option<String>§current_working_dir: Option<String>§tasks: Vec<Task>§current_task_id: Option<String>§conversation_summaries: Vec<ConversationSummary>§session_manager: Option<SessionManager>§session_id: String§tool_executions: HashMap<String, ToolExecution>

Implementations§

Source§

impl App

Source

pub fn new() -> Self

Create a new App instance

Source

pub fn current_model(&self, index: usize) -> Result<&ModelConfig>

Get the current model configuration

Source

pub fn query_model(&mut self, prompt: &str) -> Result<String>

Query the model with the given prompt

Source

pub fn has_active_tasks(&self) -> bool

Check if there are any active tasks

Source

pub fn get_task_statuses(&self) -> Vec<Value>

Get the task statuses for all tasks

Source

pub fn create_task(&mut self, description: &str) -> String

Create a new task and set it as current

Source

pub fn current_task(&self) -> Option<&Task>

Get the current task if any

Source

pub fn current_task_mut(&mut self) -> Option<&mut Task>

Get the current task as mutable if any

Source

pub fn add_tool_use(&mut self)

Add a tool use to the current task

Source

pub fn add_input_tokens(&mut self, tokens: u32)

Add input tokens to the current task

Source

pub fn complete_current_task(&mut self, tokens: u32)

Complete the current task

Source

pub fn fail_current_task(&mut self, error: &str)

Mark the current task as failed

Source

pub fn start_tool_execution(&mut self, name: &str) -> Option<String>

Start a new tool execution

Source

pub fn update_tool_progress( &mut self, tool_id: &str, message: &str, metadata: Option<HashMap<String, Value>>, )

Update tool execution progress

Source

pub fn complete_tool_execution( &mut self, tool_id: &str, message: &str, metadata: Option<HashMap<String, Value>>, )

Complete a tool execution

Source

pub fn fail_tool_execution(&mut self, tool_id: &str, error: &str)

Mark a tool execution as failed

Source

pub fn cleanup_old_tool_executions(&mut self)

Clean up old completed tool executions (older than 10 minutes)

Source

pub fn log(&mut self, _message: &str)

👎Deprecated since 0.2.0: Use eprintln with format_log_with_color instead

Add a log message (now deprecated in favor of direct eprintln calls)

Trait Implementations§

Source§

impl ContextCompressor for App

Source§

fn compress_context(&mut self) -> Result<()>

Generate a summary of the conversation history
Source§

fn should_compress(&self) -> bool

Check if conversation should be summarized based on thresholds
Source§

fn conversation_char_count(&self) -> usize

Get the total character count of conversation history
Source§

fn summary_count(&self) -> usize

Get summaries count
Source§

fn clear_history(&mut self)

Clear all summaries and history
Source§

fn display_to_session_messages( &self, display_messages: &[String], ) -> Vec<Message>

Convert display messages to session messages
Source§

fn session_to_display_messages( &self, session_messages: &[Message], ) -> Vec<String>

Convert session messages to display messages
Source§

impl Default for App

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for App

§

impl !RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl !UnwindSafe for App

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T