autogen_core.tool_agent#

exception InvalidToolArgumentsException(call_id: str, content: str, name: str)[源代码]#

基础:ToolException

class ToolAgent(description: str, tools: 列表[工具])[源代码]#

基础:RoutedAgent

一个工具代理接收类型为FunctionCall的直接消息,使用提供的参数执行请求的工具,并将结果作为FunctionExecutionResult消息返回。

Parameters:
  • 描述 (str) – 代理的描述。

  • 工具 (列表[工具]) – 代理可以执行的工具列表。

async handle_function_call(message: FunctionCall, ctx: 消息上下文) FunctionExecutionResult[源代码]#

通过执行提供的参数处理FunctionCall消息请求的工具。

Parameters:
Returns:

FunctionExecutionResult – 函数执行的结果。

Raises:
property tools: 列表[工具]#
exception ToolException(call_id: str, content: str, name: str)[源代码]#

基础:BaseException

call_id: str#
content: str#
name: str#
exception ToolExecutionException(call_id: str, content: str, name: str)[源代码]#

基础:ToolException

exception ToolNotFoundException(call_id: str, content: str, name: str)[源代码]#

基础:ToolException

async tool_agent_caller_loop(caller: BaseAgent | AgentRuntime, tool_agent_id: AgentId, model_client: ChatCompletionClient, input_messages: 列表[已注解[系统消息 | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], tool_schema: 列表[工具模式] | 列表[工具], cancellation_token: CancellationToken | = None, caller_source: str = 'assistant') 列表[已注解[系统消息 | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]][源代码]#

开始一个工具代理的调用循环。此函数以交替方式向工具代理和模型客户端发送消息,直到模型客户端停止生成工具调用。

Parameters:
  • tool_agent_id (AgentId) – 工具代理的Agent ID。

  • input_messages (List[LLMMessage]) – 输入的LLMMessage对象列表。

  • model_client (ChatCompletionClient) – 用于模型API的模型客户端。

  • tool_schema (List[Tool | ToolSchema]) – 模型可以使用的工具列表。

Returns:

List[LLMMessage] – 在调用者循环中创建的输出消息列表。