RAG: ночная пакетная индексация эмбеддингов, очередь embedding_queue, MCP get_organization_context, снижение OLLAMA_KEEP_ALIVE
This commit is contained in:
@@ -2995,6 +2995,27 @@ export const ragEmbeddings = pgTable("rag_embeddings", {
|
||||
export type RagEmbedding = typeof ragEmbeddings.$inferSelect;
|
||||
export type InsertRagEmbedding = typeof ragEmbeddings.$inferInsert;
|
||||
|
||||
// =====================
|
||||
// Embedding Queue (отложенная генерация эмбеддингов для RAG)
|
||||
// =====================
|
||||
export const embeddingQueue = pgTable("embedding_queue", {
|
||||
id: serial("id").primaryKey(),
|
||||
organizationId: integer("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
|
||||
entityType: varchar("entity_type", { length: 20 }).notNull(), // 'form' | 'task' | 'task_message'
|
||||
entityId: integer("entity_id").notNull(),
|
||||
operation: varchar("operation", { length: 20 }).notNull().default("upsert"), // 'upsert' | 'delete'
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
processedAt: timestamp("processed_at"),
|
||||
}, (table) => ({
|
||||
// Only one pending operation per entity
|
||||
pendingEntityIdx: uniqueIndex("embedding_queue_pending_entity_idx").on(table.organizationId, table.entityType, table.entityId).where(sql`${table.processedAt} IS NULL`),
|
||||
pendingIdx: index("embedding_queue_processed_at_idx").on(table.processedAt).where(sql`${table.processedAt} IS NULL`),
|
||||
createdAtIdx: index("embedding_queue_created_at_idx").on(table.createdAt),
|
||||
}));
|
||||
|
||||
export type EmbeddingQueue = typeof embeddingQueue.$inferSelect;
|
||||
export type InsertEmbeddingQueue = typeof embeddingQueue.$inferInsert;
|
||||
|
||||
// =====================
|
||||
// RAG Settings (настройки LLM/эмбеддингов на уровне организации)
|
||||
// =====================
|
||||
|
||||
Reference in New Issue
Block a user