40 lines
1023 B
TypeScript
40 lines
1023 B
TypeScript
|
|
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();
|