feat(web): add pi-agent tool layer with pipeline integration

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 02:36:28 +08:00
parent e35778ebea
commit 19a1a4e6d2
2 changed files with 140 additions and 0 deletions

39
web/server/agent/index.ts Normal file
View File

@@ -0,0 +1,39 @@
import { tools, ToolDefinition } from './tools';
export class VideoAgent {
private tools: ToolDefinition[];
constructor() {
this.tools = tools;
}
getToolDefinitions() {
return this.tools.map((t) => ({
name: t.name,
description: t.description,
parameters: t.parameters,
}));
}
async executeTool(name: string, params: Record<string, unknown>): Promise<string> {
const tool = this.tools.find((t) => t.name === name);
if (!tool) throw new Error(`Unknown tool: ${name}`);
return tool.execute(params);
}
getSystemPrompt(accountContext?: string): string {
return `你是美图 Agent帮助用户进行短视频创作。
可用账号:${accountContext || '暂无'}
你可以:
1. 帮用户创建新账号
2. 查看和管理已有账号
3. 执行视频创作 pipeline分镜→生图→生视频→TTS→成片
4. 管理提示词模板
用户想创作视频时,一步步引导他们完成流程。`;
}
}
export const videoAgent = new VideoAgent();