pub struct Agent<P: Provider> { /* private fields */ }Expand description
The main Agent struct
Implementations§
Source§impl<P: Provider> Agent<P>
impl<P: Provider> Agent<P>
Sourcepub fn builder(provider: P) -> AgentBuilder<P>
pub fn builder(provider: P) -> AgentBuilder<P>
Create a new agent builder
Sourcepub fn subscribe(&self) -> Receiver<AgentEvent>
pub fn subscribe(&self) -> Receiver<AgentEvent>
Subscribe to agent events
Sourcepub async fn notify(&self, channel: NotifyChannel, message: &str) -> Result<()>
pub async fn notify(&self, channel: NotifyChannel, message: &str) -> Result<()>
Send a notification via the configured notifier
Sourcepub async fn checkpoint(
&self,
messages: &[Message],
step: usize,
status: SessionStatus,
) -> Result<()>
pub async fn checkpoint( &self, messages: &[Message], step: usize, status: SessionStatus, ) -> Result<()>
Save current state to persistent storage
Sourcepub async fn resume(&self, session_id: &str) -> Result<String>
pub async fn resume(&self, session_id: &str) -> Result<String>
Resume a previously saved session
Sourcepub async fn prompt(&self, prompt: impl Into<String>) -> Result<String>
pub async fn prompt(&self, prompt: impl Into<String>) -> Result<String>
Send a prompt and get a response (non-streaming)
Sourcepub async fn chat(&self, messages: Vec<Message>) -> Result<String>
pub async fn chat(&self, messages: Vec<Message>) -> Result<String>
Send messages and get a response (non-streaming)
Sourcepub async fn stream(
&self,
prompt: impl Into<String>,
) -> Result<StreamingResponse>
pub async fn stream( &self, prompt: impl Into<String>, ) -> Result<StreamingResponse>
Stream a prompt response
Sourcepub async fn stream_chat(
&self,
messages: Vec<Message>,
) -> Result<StreamingResponse>
pub async fn stream_chat( &self, messages: Vec<Message>, ) -> Result<StreamingResponse>
Stream a chat response
Sourcepub async fn call_tool(&self, name: &str, arguments: &str) -> Result<String>
pub async fn call_tool(&self, name: &str, arguments: &str) -> Result<String>
Call a tool by name (Direct call helper)
Sourcepub async fn tool_definitions(&self) -> Vec<ToolDefinition>
pub async fn tool_definitions(&self) -> Vec<ToolDefinition>
Add tool definitions
Sourcepub fn config(&self) -> &AgentConfig
pub fn config(&self) -> &AgentConfig
Get the agent’s configuration
Trait Implementations§
Source§impl<P: Provider> MultiAgent for Agent<P>
impl<P: Provider> MultiAgent for Agent<P>
Source§fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: AgentMessage,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: AgentMessage,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle an incoming message from another agent
Auto Trait Implementations§
impl<P> Freeze for Agent<P>
impl<P> !RefUnwindSafe for Agent<P>
impl<P> Send for Agent<P>
impl<P> Sync for Agent<P>
impl<P> Unpin for Agent<P>
impl<P> !UnwindSafe for Agent<P>
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
Mutably borrows from an owned value. Read more
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§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>
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 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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request