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>,
) -> LLMController
pub fn new( permission_registry: Arc<PermissionRegistry>, ui_tx: Option<Sender<UiMessage>>, channel_size: Option<usize>, ) -> LLMController
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.
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