优化工具

This commit is contained in:
2025-12-10 17:11:46 +08:00
parent 4b451b2d58
commit af1185c4d7
18 changed files with 316 additions and 214 deletions
+8 -1
View File
@@ -35,11 +35,18 @@ export class Agent {
this.getModel = providerFactory(config.apiKey);
}
// 注册工具
// 注册单个工具
registerTool(customTool: Tool): void {
this.tools.set(customTool.name, customTool);
}
// 批量注册工具
registerTools(tools: Tool[]): void {
for (const tool of tools) {
this.tools.set(tool.name, tool);
}
}
// 将自定义工具转换为 Vercel AI SDK 的工具格式
private getVercelTools(): Record<string, AITool> {
const vercelTools: Record<string, AITool> = {};