forked from hangshuo652/aurak
fix: skip content check when bank questions available, early generator return
This commit is contained in:
@@ -585,15 +585,20 @@ private async getModel(tenantId: string): Promise<ChatOpenAI> {
|
||||
perQuestionTimeLimit: template?.perQuestionTimeLimit || 300,
|
||||
};
|
||||
|
||||
const content = await this.getSessionContent(sessionData);
|
||||
// Skip content check if questions are loaded from the question bank
|
||||
const hasBankQuestions = questionsFromBank.length > 0;
|
||||
|
||||
if (!content || content.trim().length < 10) {
|
||||
this.logger.error(
|
||||
`[startSession] Insufficient content length: ${content?.length || 0}`,
|
||||
);
|
||||
throw new BadRequestException(
|
||||
'Selected knowledge source has no sufficient content for evaluation.',
|
||||
);
|
||||
if (!hasBankQuestions) {
|
||||
const content = await this.getSessionContent(sessionData);
|
||||
|
||||
if (!content || content.trim().length < 10) {
|
||||
this.logger.error(
|
||||
`[startSession] Insufficient content length: ${content?.length || 0}`,
|
||||
);
|
||||
throw new BadRequestException(
|
||||
'Selected knowledge source has no sufficient content for evaluation.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const session = this.sessionRepository.create(
|
||||
@@ -634,12 +639,14 @@ private async getModel(tenantId: string): Promise<ChatOpenAI> {
|
||||
}
|
||||
|
||||
const model = await this.getModel(session.tenantId);
|
||||
const content = await this.getSessionContent(session);
|
||||
|
||||
// Check if questions already exist in session (from question bank)
|
||||
const existingQuestions = session.questions_json || [];
|
||||
const hasExistingQuestions = existingQuestions.length > 0;
|
||||
|
||||
// Skip content retrieval when bank questions exist (prevents generator errors)
|
||||
const content = hasExistingQuestions ? '' : await this.getSessionContent(session);
|
||||
|
||||
// Check if we already have state
|
||||
const existingState = await this.graph.getState({
|
||||
configurable: { thread_id: sessionId },
|
||||
|
||||
@@ -22,6 +22,14 @@ export const questionGeneratorNode = async (
|
||||
targetCount: limitCount,
|
||||
});
|
||||
|
||||
const existingQuestions = state.questions || [];
|
||||
|
||||
// Early return if enough questions from bank (no LLM call needed)
|
||||
if (existingQuestions.length >= limitCount) {
|
||||
console.log('[GeneratorNode] Skipping generation - enough questions from bank:', existingQuestions.length);
|
||||
return { questions: existingQuestions };
|
||||
}
|
||||
|
||||
if (!model || !knowledgeBaseContent) {
|
||||
console.error('[GeneratorNode] Missing model or knowledgeBaseContent');
|
||||
throw new Error(
|
||||
@@ -78,13 +86,6 @@ export const questionGeneratorNode = async (
|
||||
.map((r, i) => `${i + 1}. ${r}`)
|
||||
.join('\n');
|
||||
|
||||
const existingQuestions = state.questions || [];
|
||||
|
||||
if (existingQuestions.length >= limitCount) {
|
||||
console.log('[GeneratorNode] Skipping generation - enough questions from bank:', existingQuestions.length);
|
||||
return { questions: existingQuestions };
|
||||
}
|
||||
|
||||
const existingQuestionsText = existingQuestions
|
||||
.map((q, i) => `Q${i + 1}: ${q.questionText}`)
|
||||
.join('\n');
|
||||
|
||||
Reference in New Issue
Block a user