pub struct ToolUseLoop { /* private fields */ }Expand description
管理 LLM 与工具调用闭环。
内部全为 Arc/Clone,clone 为 O(1),支持并发 execute。
Implementations§
Source§impl ToolUseLoop
impl ToolUseLoop
pub fn new( model: ResolvedModel, executor: ToolExecutor, config: ToolUseConfig, deps: ToolUseDeps, ) -> Self
Sourcepub fn simple(model: ResolvedModel, executor: ToolExecutor) -> Self
pub fn simple(model: ResolvedModel, executor: ToolExecutor) -> Self
便捷构造 — 使用默认配置和依赖。
Sourcepub async fn execute(
&self,
messages: Vec<Message>,
) -> Result<ToolUseResult, LlmError>
pub async fn execute( &self, messages: Vec<Message>, ) -> Result<ToolUseResult, LlmError>
非流式执行
Sourcepub fn execute_stream(&self, messages: Vec<Message>) -> AgentStream
pub fn execute_stream(&self, messages: Vec<Message>) -> AgentStream
流式执行,返回事件接收器
Trait Implementations§
Source§impl Clone for ToolUseLoop
impl Clone for ToolUseLoop
Source§fn clone(&self) -> ToolUseLoop
fn clone(&self) -> ToolUseLoop
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolUseLoop
impl !UnwindSafe for ToolUseLoop
impl Freeze for ToolUseLoop
impl Send for ToolUseLoop
impl Sync for ToolUseLoop
impl Unpin for ToolUseLoop
impl UnsafeUnpin for ToolUseLoop
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