Files
Alfred/src/server/ai/agents/alfred-agent.ts

23 lines
671 B
TypeScript
Raw 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.
import { type LanguageModel, stepCountIs, ToolLoopAgent } from "ai";
import type { Logger } from "../../logger";
import { createGetCurrentTime } from "../tools/get-current-time";
const SYSTEM_PROMPT = `你是 Alfred一个 AI 助手。
## 输出规范
- 使用中文回复
- 代码块用 Markdown 围栏语法,标注语言
- 给出结论时简洁直接,不要长篇铺垫
- 不确定的事明确说"不确定"`;
export function createAlfredAgent(model: LanguageModel, logger?: Logger) {
return new ToolLoopAgent({
instructions: SYSTEM_PROMPT,
model,
stopWhen: stepCountIs(20),
tools: { getCurrentTime: createGetCurrentTime(logger) },
});
}