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 },
|
||||
|
||||
Reference in New Issue
Block a user