pub struct AgentBuilder { /* private fields */ }
Expand description
Builder for creating reactive LLM agents.
AgentBuilder provides a clean interface for creating agents that can:
- React to messages from other agents based on role and conditions
- Share memory across multiple agents
- Control reactive cycles to prevent infinite loops
- Maintain conversation context
- Handle speech-to-text and text-to-speech capabilities
Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn role(self, role: impl Into<String>) -> Self
pub fn role(self, role: impl Into<String>) -> Self
Sets the role name for this agent.
The role is used to identify messages from this agent in shared memory and for reactive message filtering.
Sourcepub fn on(self, role: impl Into<String>, condition: MessageCondition) -> Self
pub fn on(self, role: impl Into<String>, condition: MessageCondition) -> Self
Configures the agent to react to messages from a specific role with a condition.
The agent will only trigger when messages from the specified role match the condition.
Sourcepub fn max_cycles(self, max: u32) -> Self
pub fn max_cycles(self, max: u32) -> Self
Sets the maximum number of reactive cycles this agent can perform.
This prevents infinite loops in multi-agent conversations.
Sourcepub fn single_reply_per_turn(self, enabled: bool) -> Self
pub fn single_reply_per_turn(self, enabled: bool) -> Self
Configures the agent to send only one reply per conversational turn.
Sourcepub fn debounce(self, ms: u64) -> Self
pub fn debounce(self, ms: u64) -> Self
Sets a debounce delay in milliseconds before reacting to messages.
Sourcepub fn llm(self, llm_builder: LLMBuilder) -> Self
pub fn llm(self, llm_builder: LLMBuilder) -> Self
Sets the underlying LLM configuration.
Sourcepub fn stt(self, stt_builder: LLMBuilder) -> Self
pub fn stt(self, stt_builder: LLMBuilder) -> Self
Sets the Speech-to-Text LLM configuration.
Sourcepub fn tts(self, tts_builder: LLMBuilder) -> Self
pub fn tts(self, tts_builder: LLMBuilder) -> Self
Sets the Text-to-Speech LLM configuration.
Sourcepub fn memory(self, memory: impl MemoryProvider + 'static) -> Self
pub fn memory(self, memory: impl MemoryProvider + 'static) -> Self
Sets a memory provider for the agent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgentBuilder
impl !RefUnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl Sync for AgentBuilder
impl Unpin for AgentBuilder
impl !UnwindSafe for AgentBuilder
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