feat: новая функция

This commit is contained in:
2025-10-09 16:48:20 +03:00
parent dd2c9988a5
commit 13fb51e447
60 changed files with 7694 additions and 1157 deletions

View File

@@ -12,8 +12,10 @@
const axios = require('axios');
const logger = require('../utils/logger');
const ollamaConfig = require('./ollamaConfig');
const VECTOR_SEARCH_URL = process.env.VECTOR_SEARCH_URL || 'http://vector-search:8001';
const TIMEOUTS = ollamaConfig.getTimeouts();
async function upsert(tableId, rows) {
logger.info(`[VectorSearch] upsert: tableId=${tableId}, rows=${rows.length}`);
@@ -25,6 +27,8 @@ async function upsert(tableId, rows) {
text: r.text,
metadata: r.metadata || {}
}))
}, {
timeout: TIMEOUTS.vectorUpsert // Централизованный таймаут для индексации
});
logger.info(`[VectorSearch] upsert result:`, res.data);
return res.data;
@@ -41,6 +45,8 @@ async function search(tableId, query, topK = 3) {
table_id: String(tableId),
query,
top_k: topK
}, {
timeout: TIMEOUTS.vectorSearch // Централизованный таймаут для поиска
});
logger.info(`[VectorSearch] search result:`, res.data.results);
return res.data.results;
@@ -87,7 +93,7 @@ async function rebuild(tableId, rows) {
async function health() {
logger.info(`[VectorSearch] health check`);
try {
const res = await axios.get(`${VECTOR_SEARCH_URL}/health`, { timeout: 5000 });
const res = await axios.get(`${VECTOR_SEARCH_URL}/health`, { timeout: TIMEOUTS.vectorHealth });
logger.info(`[VectorSearch] health result:`, res.data);
return {
status: 'ok',