pub struct LLMController { /* private fields */ }Expand description
The main LLM controller that manages sessions and coordinates communication
Implementations§
Source§impl LLMController
impl LLMController
Sourcepub async fn start(&self)
pub async fn start(&self)
Starts the controller’s event loop. This is idempotent - calling it multiple times has no effect. Should be spawned as a tokio task.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Gracefully shuts down the controller and all sessions. This is idempotent - calling it multiple times has no effect.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns true if the controller has been shutdown
Sourcepub fn is_started(&self) -> bool
pub fn is_started(&self) -> bool
Returns true if the controller has been started
Sourcepub async fn create_session(
&self,
config: LLMSessionConfig,
) -> Result<i64, LlmError>
pub async fn create_session( &self, config: LLMSessionConfig, ) -> Result<i64, LlmError>
Sourcepub async fn get_session(&self, session_id: i64) -> Option<Arc<LLMSession>>
pub async fn get_session(&self, session_id: i64) -> Option<Arc<LLMSession>>
Sourcepub async fn session_count(&self) -> usize
pub async fn session_count(&self) -> usize
Returns the number of active sessions
Sourcepub async fn send_input(
&self,
input: ControllerInputPayload,
) -> Result<(), ControllerError>
pub async fn send_input( &self, input: ControllerInputPayload, ) -> Result<(), ControllerError>
Sourcepub async fn get_session_token_usage(
&self,
session_id: i64,
) -> Option<TokenMeter>
pub async fn get_session_token_usage( &self, session_id: i64, ) -> Option<TokenMeter>
Get token usage for a specific session.
Sourcepub async fn get_model_token_usage(&self, model: &str) -> Option<TokenMeter>
pub async fn get_model_token_usage(&self, model: &str) -> Option<TokenMeter>
Get token usage for a specific model.
Sourcepub async fn get_total_token_usage(&self) -> TokenMeter
pub async fn get_total_token_usage(&self) -> TokenMeter
Get total token usage across all sessions.
Sourcepub fn token_usage(&self) -> &TokenUsageTracker
pub fn token_usage(&self) -> &TokenUsageTracker
Get a reference to the token usage tracker for advanced queries.
Sourcepub fn tool_registry(&self) -> &Arc<ToolRegistry>
pub fn tool_registry(&self) -> &Arc<ToolRegistry>
Returns a reference to the tool registry.
Sourcepub fn user_interaction_registry(&self) -> &Arc<UserInteractionRegistry>
pub fn user_interaction_registry(&self) -> &Arc<UserInteractionRegistry>
Returns a reference to the user interaction registry.
Sourcepub async fn respond_to_interaction(
&self,
tool_use_id: &str,
response: AskUserQuestionsResponse,
) -> Result<(), UserInteractionError>
pub async fn respond_to_interaction( &self, tool_use_id: &str, response: AskUserQuestionsResponse, ) -> Result<(), UserInteractionError>
Respond to a pending user interaction.
This is called by the UI when the user has answered questions.
§Arguments
tool_use_id- ID of the tool use to respond to.response- The user’s answers.
Sourcepub async fn pending_interactions_for_session(
&self,
session_id: i64,
) -> Vec<PendingQuestionInfo>
pub async fn pending_interactions_for_session( &self, session_id: i64, ) -> Vec<PendingQuestionInfo>
Get all pending interactions for a session.
This is called by the UI when switching sessions to display any pending questions for that session.
Sourcepub async fn has_pending_interactions(&self, session_id: i64) -> bool
pub async fn has_pending_interactions(&self, session_id: i64) -> bool
Check if a session has pending user interactions.
Sourcepub fn permission_registry(&self) -> &Arc<PermissionRegistry>
pub fn permission_registry(&self) -> &Arc<PermissionRegistry>
Returns a reference to the permission registry.
Sourcepub async fn respond_to_permission(
&self,
tool_use_id: &str,
response: PermissionResponse,
) -> Result<(), PermissionError>
pub async fn respond_to_permission( &self, tool_use_id: &str, response: PermissionResponse, ) -> Result<(), PermissionError>
Respond to a pending permission request.
This is called by the UI when the user has granted or denied permission.
§Arguments
tool_use_id- ID of the tool use to respond to.response- The user’s response (grant/deny with scope).
Sourcepub async fn pending_permissions_for_session(
&self,
session_id: i64,
) -> Vec<PendingPermissionInfo>
pub async fn pending_permissions_for_session( &self, session_id: i64, ) -> Vec<PendingPermissionInfo>
Get all pending permission requests for a session.
This is called by the UI when switching sessions to display any pending permission requests for that session.
Sourcepub async fn has_pending_permissions(&self, session_id: i64) -> bool
pub async fn has_pending_permissions(&self, session_id: i64) -> bool
Check if a session has pending permission requests.
Sourcepub async fn cancel_permission(
&self,
tool_use_id: &str,
) -> Result<(), PermissionError>
pub async fn cancel_permission( &self, tool_use_id: &str, ) -> Result<(), PermissionError>
Cancel a pending permission request.
This is called by the UI when the user closes the permission dialog without responding.
Auto Trait Implementations§
impl !Freeze for LLMController
impl !RefUnwindSafe for LLMController
impl Send for LLMController
impl Sync for LLMController
impl Unpin for LLMController
impl !UnwindSafe for LLMController
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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