Files
ars-backend/app/Services/Tool/ToolCall.php
ROOG 59d4831f00 main: 增强工具调用与消息流程
- 支持 tool.call 和 tool.result 消息类型处理
- 引入 Tool 调度与执行逻辑,支持超时与结果截断
- 增加 ToolRegistry 和 ToolExecutor 管理工具定义与执行
- 更新上下文构建与消息映射逻辑,适配工具闭环处理
- 扩展配置与环境变量,支持 Tool 调用相关选项
- 增强单元测试覆盖工具调用与执行情景
- 更新文档和 OpenAPI,新增工具相关说明与模型定义
2025-12-22 12:36:59 +08:00

53 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Services\Tool;
/**
* Tool 调用请求 DTO携带父子 Run 关联信息与参数。
*/
final class ToolCall
{
/**
* @param array<string, mixed> $arguments
*/
public function __construct(
public string $runId,
public string $parentRunId,
public string $toolCallId,
public string $name,
public array $arguments,
public string $rawArguments = '',
) {
}
/**
* @param array<string, mixed> $payload
*/
public static function fromArray(array $payload): self
{
return new self(
(string) $payload['run_id'],
(string) $payload['parent_run_id'],
(string) $payload['tool_call_id'],
(string) $payload['name'],
(array) ($payload['arguments'] ?? []),
(string) ($payload['raw_arguments'] ?? '')
);
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'run_id' => $this->runId,
'parent_run_id' => $this->parentRunId,
'tool_call_id' => $this->toolCallId,
'name' => $this->name,
'arguments' => $this->arguments,
'raw_arguments' => $this->rawArguments,
];
}
}