pub struct LLMController { /* private fields */ }Expand description
The main LLM controller that manages sessions and coordinates communication
Implementations§
Source§impl LLMController
impl LLMController
Sourcepub fn new(
permission_registry: Arc<PermissionRegistry>,
ui_tx: Option<Sender<UiMessage>>,
channel_size: Option<usize>,
) -> Self
pub fn new( permission_registry: Arc<PermissionRegistry>, ui_tx: Option<Sender<UiMessage>>, channel_size: Option<usize>, ) -> Self
Creates a new LLM controller
§Arguments
permission_registry- Permission registry for batch permission requestsui_tx- Optional UI channel sender for forwarding eventschannel_size- Optional channel buffer size (defaults to DEFAULT_CHANNEL_SIZE)
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 remove_session(&self, session_id: i64) -> bool
pub async fn remove_session(&self, session_id: i64) -> bool
Removes a session from the controller.
This only removes the session from the session manager. For full cleanup
including permission and interaction registries, use AgentCore::remove_session.
§Arguments
session_id- The ID of the session to remove
§Returns
true if the session was found and removed, false otherwise
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.