pub struct FunctionCallingAgent { /* private fields */ }Expand description
Function Calling Agent
使用 LLM 原生 Function Calling 的 Agent。
不依赖文本解析,直接处理 tool_calls。
支持任何实现了 BaseChatModel 的 LLM Provider。
Implementations§
Source§impl FunctionCallingAgent
impl FunctionCallingAgent
Sourcepub fn new<L>(
llm: L,
tools: Vec<Arc<dyn BaseTool>>,
system_prompt: Option<String>,
) -> Self
pub fn new<L>( llm: L, tools: Vec<Arc<dyn BaseTool>>, system_prompt: Option<String>, ) -> Self
Sourcepub fn from_arc(
llm: Arc<dyn BaseChatModel<Error = ProviderError> + Send + Sync>,
tools: Vec<Arc<dyn BaseTool>>,
system_prompt: Option<String>,
) -> Self
pub fn from_arc( llm: Arc<dyn BaseChatModel<Error = ProviderError> + Send + Sync>, tools: Vec<Arc<dyn BaseTool>>, system_prompt: Option<String>, ) -> Self
从已包装的 Arc<dyn BaseChatModel> 创建 Agent
适用于已通过 wrap_chat_model() 或 LLMClient 创建的 LLM 实例。
Sourcepub fn tools_count(&self) -> usize
pub fn tools_count(&self) -> usize
获取工具数量
Sourcepub fn system_prompt(&self) -> Option<&str>
pub fn system_prompt(&self) -> Option<&str>
获取系统提示词
Trait Implementations§
Source§impl BaseAgent for FunctionCallingAgent
impl BaseAgent for FunctionCallingAgent
Source§fn plan<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [AgentStep],
inputs: &'life2 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn plan<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [AgentStep],
inputs: &'life2 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Plans the next action. Read more
Source§fn input_keys(&self) -> Vec<&str>
fn input_keys(&self) -> Vec<&str>
Returns input keys.
Source§fn return_stopped_response(
&self,
_intermediate_steps: &[AgentStep],
) -> AgentFinish
fn return_stopped_response( &self, _intermediate_steps: &[AgentStep], ) -> AgentFinish
Returns stopped response when max iterations reached.
Auto Trait Implementations§
impl !RefUnwindSafe for FunctionCallingAgent
impl !UnwindSafe for FunctionCallingAgent
impl Freeze for FunctionCallingAgent
impl Send for FunctionCallingAgent
impl Sync for FunctionCallingAgent
impl Unpin for FunctionCallingAgent
impl UnsafeUnpin for FunctionCallingAgent
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