Added semantic episode searching

This commit is contained in:
Storme-bit
2026-04-05 21:49:31 -07:00
parent 8765dc3c2d
commit b71005d2b1
4 changed files with 100 additions and 14 deletions

View File

@@ -0,0 +1,27 @@
const {getEnv, QDRANT, COLLECTIONS } = require('@nexusai/shared')
const BASE_URL = getEnv('QDrant_URL', QDRANT.DEFAULT_URL);
async function searchEpisodes( vector, {limit = 5, scoreThreshold = 0.75, sessionId } = {}) {
const body = {vector, limit, score_threshold: scoreThreshold, with_payload: true};
if (sessionId) {
body.filter = { must: [{key: 'sessionId', match: {value: sessionId} }] };
}
const res = await fetch (
`${BASE_URL}/collections/${COLLECTIONS.EPISODES}/points/search`,
{
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(body)
}
);
if (!res.ok) throw new Error(`QDrant error: ${res.status}`);
const data = await res.json();
return data.result;
}
module.exports = { searchEpisodes };