pub struct AgentBuilder { /* private fields */ }Expand description
Agent builder
Implementations§
Source§impl AgentBuilder
impl AgentBuilder
pub fn new(provider: Box<dyn Provider>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn model_name(self, name: impl Into<String>) -> Self
pub fn max_tokens(self, tokens: u32) -> Self
Sourcepub fn context_size(self, context_size: Option<u32>) -> Self
pub fn context_size(self, context_size: Option<u32>) -> Self
Override provider-inferred context window size.
pub fn think(self, enabled: bool) -> Self
pub fn approve_mode(self, mode: ApproveMode) -> Self
pub fn tool(self, tool: Arc<dyn Tool>) -> Self
Sourcepub fn tools_with_provider(self, tools: Vec<Box<dyn Tool>>) -> Self
pub fn tools_with_provider(self, tools: Vec<Box<dyn Tool>>) -> Self
Add multiple tools with provider support
Sourcepub fn event_tx(self, tx: Sender<AgentEvent>) -> Self
pub fn event_tx(self, tx: Sender<AgentEvent>) -> Self
Set external event sender for streaming events
Sourcepub fn profile(self, profile: PromptProfile) -> Self
pub fn profile(self, profile: PromptProfile) -> Self
Set prompt profile
Sourcepub fn project_path(self, path: PathBuf) -> Self
pub fn project_path(self, path: PathBuf) -> Self
Set project path (for dynamic tool injection like CodeGraph)
Sourcepub fn proxy_executor(
self,
executor: Arc<dyn ProxyToolExecutor>,
tool_defs: Vec<ProxyToolDef>,
) -> Self
pub fn proxy_executor( self, executor: Arc<dyn ProxyToolExecutor>, tool_defs: Vec<ProxyToolDef>, ) -> Self
设置代理工具执行器
§Example
ⓘ
use std::sync::Arc;
use serde_json::json;
use matrixcode_core::tools::toolproxy::{ProxyToolExecutor, ProxyToolDef};
let executor = Arc::new(MyProxyExecutor);
let tool_def = ProxyToolDef::new("image_search", "搜索图片", json!({...}))
.with_priority(true);
builder.proxy_executor(executor, vec![tool_def])pub fn build(self) -> Agent
Sourcepub fn mcp_registry(self, registry: Arc<RwLock<McpToolRegistry>>) -> Self
pub fn mcp_registry(self, registry: Arc<RwLock<McpToolRegistry>>) -> Self
Auto Trait Implementations§
impl Freeze for AgentBuilder
impl !RefUnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl Sync for AgentBuilder
impl Unpin for AgentBuilder
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more