Redesign complete. Not much UI changes

This commit is contained in:
AG
2025-10-11 19:10:58 +03:00
parent 9bbd690f40
commit f42bac001d
20 changed files with 425 additions and 64 deletions

View File

@@ -1,4 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['jest-fetch-mock/setupJest'],
};

View File

@@ -11,7 +11,9 @@
"dependencies": {
"@google/generative-ai": "^0.1.0",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^4.17.2",
"jest-fetch-mock": "^3.0.3",
"uuid": "^8.3.2",
"ws": "^8.4.0"
},
@@ -2094,6 +2096,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/cross-fetch": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.2.0.tgz",
"integrity": "sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q==",
"license": "MIT",
"dependencies": {
"node-fetch": "^2.7.0"
}
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@@ -2278,6 +2289,18 @@
"node": ">=8"
}
},
"node_modules/dotenv": {
"version": "17.2.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -3567,6 +3590,16 @@
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
}
},
"node_modules/jest-fetch-mock": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz",
"integrity": "sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw==",
"license": "MIT",
"dependencies": {
"cross-fetch": "^3.0.4",
"promise-polyfill": "^8.1.3"
}
},
"node_modules/jest-get-type": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.5.1.tgz",
@@ -4358,6 +4391,48 @@
"node": ">= 0.6"
}
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-fetch/node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/node-fetch/node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/node-fetch/node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@@ -4728,6 +4803,12 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/promise-polyfill": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.3.0.tgz",
"integrity": "sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==",
"license": "MIT"
},
"node_modules/prompts": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",

View File

@@ -31,7 +31,9 @@
"dependencies": {
"@google/generative-ai": "^0.1.0",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^4.17.2",
"jest-fetch-mock": "^3.0.3",
"uuid": "^8.3.2",
"ws": "^8.4.0"
}

View File

@@ -1,10 +1,16 @@
/// <reference types="jest-fetch-mock" />
import 'jest-fetch-mock';
import { FetchMock } from 'jest-fetch-mock';
import { LLMService } from '../src/services/LLMService';
require('dotenv').config();
const fetchMock = fetch as FetchMock;
describe('LLMService Refactor', () => {
let llmService: LLMService;
beforeAll(() => {
fetchMock.enableMocks(); // Enable mocks
const apiKey = process.env.GEMINI_API_KEY;
if (!apiKey) {
throw new Error('GEMINI_API_KEY is not defined in .env file');
@@ -12,7 +18,27 @@ describe('LLMService Refactor', () => {
llmService = new LLMService(apiKey);
});
afterEach(() => {
fetchMock.resetMocks(); // Reset mocks after each test
});
it('should correctly categorize desires based on the rules', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
candidates: [{
content: {
parts: [{
text: JSON.stringify({
goTo: ['Pizza'],
alsoGood: ['Pasta'],
noGoes: ['Salad', 'Tacos'],
needsDiscussion: [],
considerable: []
})
}]
}
}]
}));
const desireSets = [
{ participantId: '1', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Salad'] },
{ participantId: '2', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Tacos'] },
@@ -26,6 +52,16 @@ describe('LLMService Refactor', () => {
});
it('should detect inner contradictions in a desire set', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
candidates: [{
content: {
parts: [{
text: 'true'
}]
}
}]
}));
const desireSet = { wants: ['Ice Cream', 'No desserts'], accepts: [], noGoes: [] };
const hasContradictions = await llmService.checkForInnerContradictions(desireSet as any);
expect(hasContradictions).toBe(true);

View File

@@ -3,7 +3,7 @@
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"types": ["node", "jest"],
"types": ["node", "jest", "jest-fetch-mock"],
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,