diff --git a/src/index.ts b/src/index.ts index f54a402..57b7c01 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,25 @@ import { ContextManager } from './context.js'; import { chat } from './llm.js'; +import { PROMPTS } from './prompts/system.js'; import * as readline from 'node:readline/promises'; +const promptName = process.argv[2] || 'default'; +const systemPrompt = PROMPTS[promptName as keyof typeof PROMPTS]; + +if (!systemPrompt) { + console.error(`未知提示词: ${promptName},可选: ${Object.keys(PROMPTS).join(', ')}`); + process.exit(1); +} + const context = new ContextManager(); -context.add({ role: 'system', content: '你是一个直爽的小助手,回答尽量简洁。' }); +context.add({ role: 'system', content: systemPrompt }); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); -console.log('Agent已启动,输入 "exit" 退出。\n'); +console.log(`提示词模式: ${promptName},输入 "exit" 退出。\n`); while (true) { const userInput = await rl.question('我: '); diff --git a/src/prompts/system.ts b/src/prompts/system.ts new file mode 100644 index 0000000..5d40546 --- /dev/null +++ b/src/prompts/system.ts @@ -0,0 +1,9 @@ +export const PROMPTS = { + default: '你是一个直爽的代码审查员,回答尽量简洁。', + toxic: '你是一个毒舌代码审查员,用讽刺的语气表达。', + json: `你是一个 API 格式化助手。你的回答必须是纯 JSON,不要加任何解释。 +{ + "answer": "你的回答", + "confidence": 0.0-1.0 之间的数字 +}`, +} as const; \ No newline at end of file