forked from hangshuo652/aurak
fix: natural follow-up conversation flow
- Grader: separate followup hint from scoring feedback - Interviewer: use followup hint directly without prefix/suffix - Restored standard and choice question presentation paths
This commit is contained in:
@@ -252,10 +252,15 @@ Format your response as JSON:
|
|||||||
shouldFollowUp = false;
|
shouldFollowUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let followupHintMsg: AIMessage | null = null;
|
||||||
if (shouldFollowUp && followupHints.length > 0) {
|
if (shouldFollowUp && followupHints.length > 0) {
|
||||||
const hint = followupHints[Math.min(currentFollowUpCount, followupHints.length - 1)];
|
const hint = followupHints[Math.min(currentFollowUpCount, followupHints.length - 1)];
|
||||||
const hintLabel = isZh ? '追问方向' : isJa ? '追加の方向性' : 'Follow-up hint';
|
const hintLabel = isZh
|
||||||
enhancedFeedback = `${result.feedback}\n\n${hintLabel}: ${hint}`;
|
? `让我帮你完善一下:${hint}`
|
||||||
|
: isJa
|
||||||
|
? `もう少し詳しく伺います:${hint}`
|
||||||
|
: `Let me help you elaborate: ${hint}`;
|
||||||
|
followupHintMsg = new AIMessage(hintLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
const feedbackMessage = new AIMessage(
|
const feedbackMessage = new AIMessage(
|
||||||
@@ -271,8 +276,12 @@ Format your response as JSON:
|
|||||||
saysIDontKnow,
|
saysIDontKnow,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const feedbackHistoryMessages = followupHintMsg
|
||||||
|
? [feedbackMessage, followupHintMsg]
|
||||||
|
: [feedbackMessage];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
feedbackHistory: [feedbackMessage],
|
feedbackHistory: feedbackHistoryMessages,
|
||||||
scores: newScores,
|
scores: newScores,
|
||||||
shouldFollowUp: shouldFollowUp,
|
shouldFollowUp: shouldFollowUp,
|
||||||
followUpCount: shouldFollowUp ? currentFollowUpCount + 1 : 0,
|
followUpCount: shouldFollowUp ? currentFollowUpCount + 1 : 0,
|
||||||
|
|||||||
@@ -81,14 +81,13 @@ describe('interviewerNode', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('follow-up mode', () => {
|
describe('follow-up mode', () => {
|
||||||
it('should include feedback in follow-up prompt', async () => {
|
it('should use last feedbackHistory message content as follow-up prompt', async () => {
|
||||||
const state = baseState({
|
const state = baseState({
|
||||||
shouldFollowUp: true,
|
shouldFollowUp: true,
|
||||||
feedbackHistory: [new AIMessage('Feedback: You need more details')],
|
feedbackHistory: [new AIMessage('You need more details')],
|
||||||
});
|
});
|
||||||
const result = await interviewerNode(state);
|
const result = await interviewerNode(state);
|
||||||
const msg = (result.messages as any)[0].content as string;
|
const msg = (result.messages as any)[0].content as string;
|
||||||
expect(msg).toContain('Follow-up');
|
|
||||||
expect(msg).toContain('You need more details');
|
expect(msg).toContain('You need more details');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,27 +49,7 @@ export const interviewerNode = async (
|
|||||||
) {
|
) {
|
||||||
const lastFeedbackMsg =
|
const lastFeedbackMsg =
|
||||||
state.feedbackHistory[state.feedbackHistory.length - 1];
|
state.feedbackHistory[state.feedbackHistory.length - 1];
|
||||||
const feedbackText = lastFeedbackMsg.content.toString();
|
prompt = lastFeedbackMsg.content.toString();
|
||||||
|
|
||||||
const feedbackMatch = feedbackText.match(
|
|
||||||
/(?:Feedback|反馈|フィードバック): ([\s\S]*)/i,
|
|
||||||
);
|
|
||||||
const specificFeedback = feedbackMatch
|
|
||||||
? feedbackMatch[1].trim()
|
|
||||||
: feedbackText;
|
|
||||||
|
|
||||||
const followUpLabel = isZh
|
|
||||||
? '补充追问'
|
|
||||||
: isJa
|
|
||||||
? '追加の質問'
|
|
||||||
: 'Follow-up Clarification';
|
|
||||||
const followUpInstruction = isZh
|
|
||||||
? '根据以上反馈,请补充更具体的信息:'
|
|
||||||
: isJa
|
|
||||||
? '上記のフィードバックに基づき、より具体的な情報を追加してください:'
|
|
||||||
: 'Based on the feedback above, please provide more specific details:';
|
|
||||||
|
|
||||||
prompt = `${followUpLabel}\n\n${specificFeedback}\n\n${followUpInstruction}`;
|
|
||||||
} else if (currentQuestion.questionType === 'MULTIPLE_CHOICE' && currentQuestion.options?.length > 0) {
|
} else if (currentQuestion.questionType === 'MULTIPLE_CHOICE' && currentQuestion.options?.length > 0) {
|
||||||
const label = isZh
|
const label = isZh
|
||||||
? `问题 ${currentQuestionIndex + 1}`
|
? `问题 ${currentQuestionIndex + 1}`
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user