pub struct AgentLoop { /* private fields */ }Expand description
Agent loop that processes messages with tool support
Implementations§
Source§impl AgentLoop
impl AgentLoop
Sourcepub fn new(
provider: Arc<dyn LLMProvider>,
tools: Arc<dyn ToolExecutor>,
config: AgentLoopConfig,
) -> AgentLoop
pub fn new( provider: Arc<dyn LLMProvider>, tools: Arc<dyn ToolExecutor>, config: AgentLoopConfig, ) -> AgentLoop
Create a new agent loop
Sourcepub fn with_defaults(
provider: Arc<dyn LLMProvider>,
tools: Arc<dyn ToolExecutor>,
) -> AgentLoop
pub fn with_defaults( provider: Arc<dyn LLMProvider>, tools: Arc<dyn ToolExecutor>, ) -> AgentLoop
Create with default configuration
Sourcepub async fn process_message(
&self,
context: Vec<ChatMessage>,
content: &str,
media: Option<Vec<String>>,
) -> Result<String, Error>
pub async fn process_message( &self, context: Vec<ChatMessage>, content: &str, media: Option<Vec<String>>, ) -> Result<String, Error>
Process a single message with tool execution loop
Sourcepub async fn process_with_model(
&self,
context: Vec<ChatMessage>,
content: &str,
media: Option<Vec<String>>,
model: &str,
) -> Result<String, Error>
pub async fn process_with_model( &self, context: Vec<ChatMessage>, content: &str, media: Option<Vec<String>>, model: &str, ) -> Result<String, Error>
Process with custom model
Sourcepub async fn process_with_options(
&self,
context: Vec<ChatMessage>,
content: &str,
media: Option<Vec<String>>,
model: Option<&str>,
) -> Result<String, Error>
pub async fn process_with_options( &self, context: Vec<ChatMessage>, content: &str, media: Option<Vec<String>>, model: Option<&str>, ) -> Result<String, Error>
Process with custom context builder and options
Sourcepub async fn process_with_context_builder(
&self,
context_builder: &AgentContextBuilder,
history: Vec<ChatMessage>,
content: &str,
media: Option<Vec<String>>,
model: Option<&str>,
) -> Result<String, Error>
pub async fn process_with_context_builder( &self, context_builder: &AgentContextBuilder, history: Vec<ChatMessage>, content: &str, media: Option<Vec<String>>, model: Option<&str>, ) -> Result<String, Error>
Process with a context builder (system prompt + history) and optional model.
Sourcepub async fn process_with_session(
&self,
session: &mut ChatSession,
content: &str,
media: Option<Vec<String>>,
context_builder: Option<&AgentContextBuilder>,
model: Option<&str>,
) -> Result<String, Error>
pub async fn process_with_session( &self, session: &mut ChatSession, content: &str, media: Option<Vec<String>>, context_builder: Option<&AgentContextBuilder>, model: Option<&str>, ) -> Result<String, Error>
Process with a session, updating history automatically.
If a context builder is provided, it will be used to construct the LLM prompt (system + history + user). The session will still record only the user/assistant messages.
Sourcepub fn config(&self) -> &AgentLoopConfig
pub fn config(&self) -> &AgentLoopConfig
Get the configuration
Auto Trait Implementations§
impl Freeze for AgentLoop
impl !RefUnwindSafe for AgentLoop
impl Send for AgentLoop
impl Sync for AgentLoop
impl Unpin for AgentLoop
impl UnsafeUnpin for AgentLoop
impl !UnwindSafe for AgentLoop
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> 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> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage