feat: Refactor result preparation and add contradiction checks

This commit is contained in:
AG
2025-10-11 17:03:13 +03:00
parent 42303b1fc3
commit fd2676dd5f
14 changed files with 436 additions and 211 deletions

View File

@@ -0,0 +1,33 @@
import { LLMService } from '../src/services/LLMService';
require('dotenv').config();
describe('LLMService Refactor', () => {
let llmService: LLMService;
beforeAll(() => {
const apiKey = process.env.GEMINI_API_KEY;
if (!apiKey) {
throw new Error('GEMINI_API_KEY is not defined in .env file');
}
llmService = new LLMService(apiKey);
});
it('should correctly categorize desires based on the rules', async () => {
const desireSets = [
{ participantId: '1', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Salad'] },
{ participantId: '2', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Tacos'] },
];
const result = await llmService.analyzeDesires(desireSets as any);
expect(result.goTo).toContain('Pizza');
expect(result.alsoGood).toContain('Pasta');
expect(result.noGoes).toEqual(expect.arrayContaining(['Salad', 'Tacos']));
});
it('should detect inner contradictions in a desire set', async () => {
const desireSet = { wants: ['Ice Cream', 'No desserts'], accepts: [], noGoes: [] };
const hasContradictions = await llmService.checkForInnerContradictions(desireSet as any);
expect(hasContradictions).toBe(true);
});
});