RAG: ночная пакетная индексация эмбеддингов, очередь embedding_queue, MCP get_organization_context, снижение OLLAMA_KEEP_ALIVE
This commit is contained in:
@@ -13,7 +13,7 @@ import { webhookService } from "../services/webhook.service";
|
||||
import { generateBotServiceToken } from "../utils/jwt";
|
||||
import { sendWebhook } from "../utils/webhook";
|
||||
import { eventBus } from "./shared";
|
||||
import { buildMessageText, upsertEmbedding } from "../services/embedding.service";
|
||||
|
||||
import { handleAiBotMention, checkBotAccess } from "../services/ai-bot.service";
|
||||
import { db } from "../db";
|
||||
import { fileUploads } from "@shared/schema";
|
||||
@@ -300,22 +300,8 @@ export function registerChatMessageRoutes(router: Router): void {
|
||||
}
|
||||
|
||||
if (messageData.messageType === 'comment') {
|
||||
(async () => {
|
||||
try {
|
||||
const users = await storage.getUsersByOrganization(req.organizationId!);
|
||||
const usersMap = new Map(users.map(u => [u.id, u]));
|
||||
const authorUser = req.user?.id ? usersMap.get(req.user.id) : null;
|
||||
const authorName = authorUser
|
||||
? `${authorUser.firstName ?? ''} ${authorUser.middleName ?? ''} ${authorUser.lastName ?? ''}`.trim() || authorUser.email
|
||||
: 'Пользователь';
|
||||
const content = buildMessageText(createdMessage, authorName, task.title);
|
||||
await upsertEmbedding(req.organizationId!, 'task_message', createdMessage.id, content, {
|
||||
taskId, formId: task.formId, authorId: req.user?.id,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[RAG] indexMessage error:', err);
|
||||
}
|
||||
})();
|
||||
storage.enqueueEmbedding(req.organizationId!, 'task_message', createdMessage.id, 'upsert')
|
||||
.catch(err => console.error('[RAG] enqueue message embedding error:', err));
|
||||
}
|
||||
|
||||
if (req.user?.id) {
|
||||
|
||||
Reference in New Issue
Block a user