M3: console.log -> Logger + UI redesign (QuestionBank) + S7/A9/A10/A11/U11 bug fixes + #1/#2/#3/#4 enhancements + i18n for QuestionBank pages

This commit is contained in:
Developer
2026-05-19 16:57:45 +08:00
parent 5b5f14674d
commit 29bac74b58
20 changed files with 1081 additions and 501 deletions
+29 -29
View File
@@ -71,30 +71,30 @@ export class ChatService {
enableHyDE?: boolean, // New
tenantId?: string, // New: tenant isolation
): AsyncGenerator<{ type: 'content' | 'sources' | 'historyId'; data: any }> {
console.log('=== ChatService.streamChat ===');
console.log('User ID:', userId);
console.log('User language:', userLanguage);
console.log('Selected embedding model ID:', selectedEmbeddingId);
console.log('Selected groups:', selectedGroups);
console.log('Selected files:', selectedFiles);
console.log('History ID:', historyId);
console.log('Temperature:', temperature);
console.log('Max Tokens:', maxTokens);
console.log('Top K:', topK);
console.log('Similarity threshold:', similarityThreshold);
console.log('Rerank threshold:', rerankSimilarityThreshold);
console.log('Query expansion:', enableQueryExpansion);
console.log('HyDE:', enableHyDE);
console.log('Model configuration:', {
this.logger.log('=== ChatService.streamChat ===');
this.logger.log('User ID:', userId);
this.logger.log('User language:', userLanguage);
this.logger.log('Selected embedding model ID:', selectedEmbeddingId);
this.logger.log('Selected groups:', selectedGroups);
this.logger.log('Selected files:', selectedFiles);
this.logger.log('History ID:', historyId);
this.logger.log('Temperature:', temperature);
this.logger.log('Max Tokens:', maxTokens);
this.logger.log('Top K:', topK);
this.logger.log('Similarity threshold:', similarityThreshold);
this.logger.log('Rerank threshold:', rerankSimilarityThreshold);
this.logger.log('Query expansion:', enableQueryExpansion);
this.logger.log('HyDE:', enableHyDE);
this.logger.log('Model configuration:', {
name: modelConfig.name,
modelId: modelConfig.modelId,
baseUrl: modelConfig.baseUrl,
});
console.log(
this.logger.log(
'API Key prefix:',
modelConfig.apiKey?.substring(0, 10) + '...',
);
console.log('API Key length:', modelConfig.apiKey?.length);
this.logger.log('API Key length:', modelConfig.apiKey?.length);
// Get current language setting (keeping LANGUAGE_CONFIG for backward compatibility, now uses i18n service)
// Use actual language based on user settings
@@ -113,7 +113,7 @@ export class ChatService {
selectedGroups,
);
currentHistoryId = searchHistory.id;
console.log(
this.logger.log(
this.i18nService.getMessage(
'creatingHistory',
effectiveUserLanguage,
@@ -143,7 +143,7 @@ export class ChatService {
);
}
console.log(
this.logger.log(
this.i18nService.getMessage(
'usingEmbeddingModel',
effectiveUserLanguage,
@@ -156,7 +156,7 @@ export class ChatService {
);
// 2. Search using user's query directly
console.log(
this.logger.log(
this.i18nService.getMessage('startingSearch', effectiveUserLanguage),
);
yield {
@@ -204,7 +204,7 @@ export class ChatService {
// HybridSearch returns ES hit structure, but RagSearchResult is normalized
// BuildContext expects {fileName, content}. RagSearchResult has these
searchResults = ragResults;
console.log(
this.logger.log(
this.i18nService.getMessage(
'searchResultsCount',
effectiveUserLanguage,
@@ -274,7 +274,7 @@ export class ChatService {
};
}
} catch (searchError) {
console.error(
this.logger.error(
this.i18nService.getMessage(
'searchFailedLog',
effectiveUserLanguage,
@@ -461,14 +461,14 @@ ${instruction}`;
try {
// Join keywords into search string
const combinedQuery = keywords.join(' ');
console.log(
this.logger.log(
this.i18nService.getMessage('searchString', userLanguage) +
combinedQuery,
);
// Check if embedding model ID is provided
if (!embeddingModelId) {
console.log(
this.logger.log(
this.i18nService.getMessage(
'embeddingModelIdNotProvided',
userLanguage,
@@ -478,7 +478,7 @@ ${instruction}`;
}
// Use actual embedding vector
console.log(
this.logger.log(
this.i18nService.getMessage('generatingEmbeddings', userLanguage),
);
const queryEmbedding = await this.embeddingService.getEmbeddings(
@@ -486,7 +486,7 @@ ${instruction}`;
embeddingModelId,
);
const queryVector = queryEmbedding[0];
console.log(
this.logger.log(
this.i18nService.getMessage('embeddingsGenerated', userLanguage) +
this.i18nService.getMessage('dimensions', userLanguage) +
':',
@@ -494,7 +494,7 @@ ${instruction}`;
);
// Hybrid search
console.log(
this.logger.log(
this.i18nService.getMessage('performingHybridSearch', userLanguage),
);
const results = await this.elasticsearchService.hybridSearch(
@@ -507,7 +507,7 @@ ${instruction}`;
explicitFileIds, // Pass explicit file IDs
tenantId, // Pass tenant ID
);
console.log(
this.logger.log(
this.i18nService.getMessage('esSearchCompleted', userLanguage) +
this.i18nService.getMessage('resultsCount', userLanguage) +
':',
@@ -516,7 +516,7 @@ ${instruction}`;
return results.slice(0, 10);
} catch (error) {
console.error(
this.logger.error(
this.i18nService.getMessage('hybridSearchFailed', userLanguage) + ':',
error,
);