fix: storage 默认 COS + indexStatus 更新 + BullMQ 跳过文件导入
- storage.config.ts: NODE_ENV=production 默认 COS - internal-rag.controller.ts: saveChunks 同步更新 indexStatus - document-import.worker.ts: 文件导入跳过,留给 Python RAG Worker - .gitignore: 添加 uploads/ Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cd2fb53101
commit
9d35c14bc2
1
.gitignore
vendored
1
.gitignore
vendored
@ -53,3 +53,4 @@ docs/AI回答.md
|
|||||||
|
|
||||||
# rag-worker (migrated to own project)
|
# rag-worker (migrated to own project)
|
||||||
rag-worker/
|
rag-worker/
|
||||||
|
uploads/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('storage', () => ({
|
export default registerAs('storage', () => ({
|
||||||
driver: process.env.STORAGE_DRIVER || 'local',
|
driver: process.env.STORAGE_DRIVER || (process.env.NODE_ENV === 'production' ? 'cos' : 'local'),
|
||||||
localPath: process.env.STORAGE_LOCAL_PATH || './uploads',
|
localPath: process.env.STORAGE_LOCAL_PATH || './uploads',
|
||||||
cos: {
|
cos: {
|
||||||
secretId: process.env.STORAGE_COS_SECRET_ID || '',
|
secretId: process.env.STORAGE_COS_SECRET_ID || '',
|
||||||
|
|||||||
@ -115,7 +115,7 @@ export class InternalRagController {
|
|||||||
const totalChars = sourceChunks.reduce((sum, c) => sum + (c.tokenCount || c.content?.length || 0), 0);
|
const totalChars = sourceChunks.reduce((sum, c) => sum + (c.tokenCount || c.content?.length || 0), 0);
|
||||||
await this.prisma.knowledgeSource.updateMany({
|
await this.prisma.knowledgeSource.updateMany({
|
||||||
where: { id: sourceId },
|
where: { id: sourceId },
|
||||||
data: { textLength: totalChars, parseStatus: 'completed', updatedAt: new Date() },
|
data: { textLength: totalChars, parseStatus: 'completed', indexStatus: 'completed', updatedAt: new Date() },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,6 +140,15 @@ export class InternalRagController {
|
|||||||
body.importId,
|
body.importId,
|
||||||
body.candidates || [],
|
body.candidates || [],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 更新 source 的学习状态
|
||||||
|
if (body.sourceId && body.candidates?.length > 0) {
|
||||||
|
await this.prisma.knowledgeSource.updateMany({
|
||||||
|
where: { id: body.sourceId },
|
||||||
|
data: { learningStatus: 'completed', updatedAt: new Date() },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return { success: true, count: body.candidates?.length || 0 };
|
return { success: true, count: body.candidates?.length || 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,10 +40,9 @@ export class DocumentImportWorker extends WorkerHost {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (!rawText) {
|
if (!rawText) {
|
||||||
await this.repository.updateStatus(importId, 'completed');
|
// 文件导入(PDF/Office 等),由 Python RAG Worker 处理
|
||||||
await this.redis.set(`job:document-import:${importId}:status`, 'completed', 86400);
|
// BullMQ Worker 只处理纯文本导入
|
||||||
await this.redis.set(`job:document-import:${importId}:progress`, '100', 86400);
|
this.logger.log(`Skipping file import ${importId} — delegated to Python RAG Worker`);
|
||||||
await this.redis.set(`job:document-import:${importId}:message`, '无需解析的空文件', 86400);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user