fix: send accumulated answers to LLM grader for follow-up context
- Grader now passes all rounds of user answers to LLM (tagged 第N轮回答) - LLM can see what was already answered and avoid redundant follow-ups - Updated all three language prompts with multi-round guidance
This commit is contained in:
@@ -96,7 +96,7 @@ export const graderNode = async (
|
||||
|
||||
重要提示:
|
||||
1. **你必须使用以下语言提供反馈:中文 (Simplified Chinese)**。
|
||||
2. 即使用户的回答或知识库内容涉及其他语言,请确保你的反馈和解释依然严格使用中文。不要夹杂日文。
|
||||
2. 如果这是多轮追问,用户消息中会包含多轮回答("第N轮回答:"标记),请综合所有轮次判断用户是否已覆盖关键点。已经在前几轮中回答过的内容,不要追问。
|
||||
|
||||
问题:${currentQuestion.questionText}
|
||||
预期的关键点:${currentQuestion.keyPoints.join(', ')}
|
||||
@@ -132,7 +132,7 @@ export const graderNode = async (
|
||||
|
||||
重要事項:
|
||||
1. **フィードバックは必ず次の言語で提供してください:日本語**。
|
||||
2. ユーザーの回答やナレッジベースの内容に他の言語(中国語や英語など)が含まれている場合でも、フィードバックと説明は必ず日本語のみで行ってください。中国語が混ざらないよう厳格に注意してください。
|
||||
2. 複数回の追質問の場合、ユーザーメッセージには複数ラウンドの回答が含まれます(「第N輪回答:」マーク)。すべてのラウンドを総合して、ユーザーがキーポイントを既にカバーしているか判断してください。前のラウンドで既に回答済みの内容は追質問しないでください。
|
||||
|
||||
質問:${currentQuestion.questionText}
|
||||
期待されるキーポイント:${currentQuestion.keyPoints.join(', ')}
|
||||
@@ -168,7 +168,7 @@ Grade the user's answer based on the following question and key points.
|
||||
|
||||
IMPORTANT:
|
||||
1. **You MUST provide the feedback in English.**
|
||||
2. If the user's answer or knowledge base content references other languages, ensure your feedback and explanation remain strictly in English.
|
||||
2. In multi-round follow-ups, user messages contain multiple rounds of answers (marked "第N轮回答:" or "Round N:"). Consider ALL rounds when determining what the user has already covered. Do not ask follow-up questions about content already answered in previous rounds.
|
||||
|
||||
QUESTION: ${currentQuestion.questionText}
|
||||
EXPECTED KEY POINTS: ${currentQuestion.keyPoints.join(', ')}
|
||||
@@ -221,6 +221,15 @@ Bad example:
|
||||
? lastUserMessage.content
|
||||
: JSON.stringify(lastUserMessage.content);
|
||||
|
||||
let allAnswers = userContentText;
|
||||
if (currentFollowUpCount > 0) {
|
||||
const prevAnswers = state.messages
|
||||
.filter(m => m instanceof HumanMessage)
|
||||
.slice(-(currentFollowUpCount + 1))
|
||||
.map((m, i) => `第${i + 1}轮回答:${typeof m.content === 'string' ? m.content : JSON.stringify(m.content)}`);
|
||||
allAnswers = prevAnswers.join('\n\n');
|
||||
}
|
||||
|
||||
console.log('[GraderNode] === START GRADING ===');
|
||||
console.log('[GraderNode] User answer length:', userContentText.length);
|
||||
console.log('[GraderNode] Question:', currentQuestion?.questionText?.substring(0, 100));
|
||||
@@ -229,7 +238,7 @@ Bad example:
|
||||
try {
|
||||
const response = await model.invoke([
|
||||
new SystemMessage(systemPrompt),
|
||||
new HumanMessage(userContentText),
|
||||
new HumanMessage(allAnswers),
|
||||
]);
|
||||
|
||||
console.log('[GraderNode] LLM invoke completed');
|
||||
|
||||
Reference in New Issue
Block a user