pub struct Agent { /* private fields */ }Expand description
Agent that can use tools and maintain conversation
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(
llm_client: Client,
tool_executor: ToolExecutor,
config: AgentConfig,
) -> RragResult<Self>
pub fn new( llm_client: Client, tool_executor: ToolExecutor, config: AgentConfig, ) -> RragResult<Self>
Create a new agent (legacy constructor - uses in-memory ConversationMemory)
Sourcepub fn new_with_memory(
llm_client: Client,
tool_executor: ToolExecutor,
memory_manager: AgentMemoryManager,
config: AgentConfig,
) -> RragResult<Self>
pub fn new_with_memory( llm_client: Client, tool_executor: ToolExecutor, memory_manager: AgentMemoryManager, config: AgentConfig, ) -> RragResult<Self>
Create a new agent with persistent memory
Sourcepub async fn run(&mut self, user_input: impl Into<String>) -> RragResult<String>
pub async fn run(&mut self, user_input: impl Into<String>) -> RragResult<String>
Run the agent with a user query
In stateless mode: Creates fresh conversation for each call In stateful mode: Continues previous conversation
Sourcepub async fn reset(&mut self) -> RragResult<()>
pub async fn reset(&mut self) -> RragResult<()>
Reset conversation (clears history, keeps system prompt)
Sourcepub fn get_conversation(&self) -> &[ChatMessage]
pub fn get_conversation(&self) -> &[ChatMessage]
Get conversation history (legacy - uses in-memory only)
Sourcepub async fn get_conversation_async(&self) -> RragResult<Vec<ChatMessage>>
pub async fn get_conversation_async(&self) -> RragResult<Vec<ChatMessage>>
Get conversation history from persistent memory (async)
Sourcepub fn config(&self) -> &AgentConfig
pub fn config(&self) -> &AgentConfig
Get agent configuration
Sourcepub fn config_mut(&mut self) -> &mut AgentConfig
pub fn config_mut(&mut self) -> &mut AgentConfig
Get mutable configuration
Sourcepub fn memory(&self) -> Option<&AgentMemoryManager>
pub fn memory(&self) -> Option<&AgentMemoryManager>
Get access to the memory manager (if using persistent memory)
Sourcepub fn memory_mut(&mut self) -> Option<&mut AgentMemoryManager>
pub fn memory_mut(&mut self) -> Option<&mut AgentMemoryManager>
Get mutable access to the memory manager (if using persistent memory)
Auto Trait Implementations§
impl Freeze for Agent
impl !RefUnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl !UnwindSafe for Agent
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