Files
aurak/test-graph.js
T
Developer 0a9588abb7 feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params)
- Add findByTemplateId method to service
- Add GET /by-template/:templateId endpoint to controller
- Service already includes CRUD for QuestionBank and QuestionBankItem
2026-04-23 17:19:11 +08:00

42 lines
1.9 KiB
JavaScript

const { createEvaluationGraph } = require('./server/src/assessment/graph/builder');
const { HumanMessage } = require('@langchain/core/messages');
async function testGraph() {
const graph = createEvaluationGraph();
const config = {
configurable: {
thread_id: "test-session",
model: {
invoke: async (msgs) => {
console.log("Mock Model Invoked with:", msgs[0].content);
if (msgs[0].content.includes("考官")) {
return { content: JSON.stringify({ score: 9, feedback: "Good job", should_follow_up: false }) };
}
if (msgs[0].content.includes("教育顾问")) {
return { content: "LEVEL: Proficient\nThis is a test report." };
}
return { content: JSON.stringify([{ question_text: "Test Question?", key_points: ["A"], difficulty: "Medium", basis: "[1]..." }]) };
}
},
knowledgeBaseContent: "This is test content.",
language: "zh"
}
};
console.log("--- Starting Session ---");
let state = await graph.invoke({ messages: [new HumanMessage("Start")] }, config);
console.log("Interviewer said:", state.messages[state.messages.length - 1].content);
console.log("Questions length:", state.questions.length);
console.log("Current Index:", state.currentQuestionIndex);
console.log("\n--- Submitting Answer ---");
state = await graph.invoke({ messages: [new HumanMessage("My answer")] }, config);
console.log("Interviewer said:", state.messages[state.messages.length - 1].content);
console.log("Current Index:", state.currentQuestionIndex);
console.log("Report:", state.report);
}
// Note: This script needs the environment set up correctly to run.
// Since I can't easily run it with all dependencies, I'll rely on manual analysis first.