NODEDC_1C/llm_normalizer/backend/tests/evalRuntimeQuestionSplit.te...

70 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from "vitest";
import { __evalRouteTestUtils } from "../src/routes/eval";
describe("eval runtime question splitting", () => {
it("merges short conversational tails into previous question", () => {
const parsed = __evalRouteTestUtils.splitQuestionCandidate(
"Покажи контрагентов с риском несверки по акту? и коротко? без воды?"
);
expect(parsed).toHaveLength(1);
expect(parsed[0]).toMatch(/коротко/i);
expect(parsed[0]).toMatch(/без воды/i);
});
it("keeps independent full questions as separate items", () => {
const parsed = __evalRouteTestUtils.splitQuestionCandidate(
"Где зависли оплаты по счету 60? Какие документы не закрылись по 62 за июль 2020?"
);
expect(parsed).toHaveLength(2);
expect(parsed[0]).toMatch(/\?/);
expect(parsed[1]).toMatch(/\?/);
});
it("normalizes list input and removes placeholders and duplicates", () => {
const parsed = __evalRouteTestUtils.normalizeRuntimeQuestions([
"Вопросы",
"Покажи хвосты по поставщикам",
"и коротко?"
]);
expect(parsed).toHaveLength(1);
expect(parsed[0]).toMatch(/поставщик/i);
expect(parsed[0]).toMatch(/коротко/i);
});
it("repairs mojibake questions before runtime job materialization", () => {
const parsed = __evalRouteTestUtils.normalizeRuntimeQuestions([
"кайф - что там на складе по остаткам?"
]);
expect(parsed).toEqual(["кайф - что там на складе по остаткам?"]);
});
it("repairs damaged clarification as one scenario turn when splitting is disabled", () => {
const parsed = __evalRouteTestUtils.normalizeRuntimeQuestions(
["\u0410\u041b\u042c\u0422\u0415\u0420\u041d\u0410\u0422\uFFFD?\u0412\u0410"],
{
dedupe: false,
splitCandidates: false
}
);
expect(parsed).toEqual(["\u0410\u041b\u042c\u0422\u0415\u0420\u041d\u0410\u0422\u0418\u0412\u0410"]);
});
it("repairs C1-control autorun clarification before runtime job materialization", () => {
const damagedAlternative = String.fromCharCode(
0x420, 0x452, 0x420, 0x203a, 0x420, 0xac, 0x420, 0x45e, 0x420, 0x2022, 0x420, 0xa0, 0x420,
0x45c, 0x420, 0x452, 0x420, 0x45e, 0x420, 0x98, 0x420, 0x2019, 0x420, 0x452
);
const parsed = __evalRouteTestUtils.normalizeRuntimeQuestions([damagedAlternative], {
dedupe: false,
splitCandidates: false
});
expect(parsed).toEqual(["\u0410\u041b\u042c\u0422\u0415\u0420\u041d\u0410\u0422\u0418\u0412\u0410"]);
});
});