feat: port quality, escalation, KB version, site-map KB, experiments and metrics

This commit is contained in:
wangliang
2026-10-23 11:41:09 +08:00
parent 81b49c9350
commit b778570045
33 changed files with 2446 additions and 344 deletions
+18
View File
@@ -0,0 +1,18 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { createReranker } = require('../src/reranker');
test('reranker: returns LLM-selected candidates', async () => {
const llm = { async chat() { return { content: '2,0' }; } };
const candidates = [{ question: 'a' }, { question: 'b' }, { question: 'c' }];
const out = await createReranker(llm).rerank('q', candidates, 2);
assert.deepEqual(out.map((x) => x.question), ['c', 'a']);
});
test('reranker: short list passes through', async () => {
const candidates = [{ question: 'a' }];
const out = await createReranker({ chat: async () => ({ content: '' }) }).rerank('q', candidates, 2);
assert.deepEqual(out, candidates);
});