From 505339aa331f65733b4420ad5a873a05dbc7aed7 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Thu, 21 May 2026 09:45:39 +0200 Subject: [PATCH] Changed Mistral LLM to mistral-8b-2512. Changed timeout for LMM in .env --- .env | 2 +- backend/src/ai/ai.service.ts | 2 +- .../src/flyer-import/services/ai-flyer-parser.service.ts | 8 ++++---- backend/src/recipes/recipes.service.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 82bdd132..2649c09b 100644 --- a/.env +++ b/.env @@ -19,7 +19,7 @@ SEED_USER2_PASSWORD=Test-Anv2-FBG AUTH_SECRET=WheqAss4F/al9yRZRqepJEBs6TzPsN3brX0iBiF4Oww= JWT_SECRET=uK9yRQpyyWOcHYcYbpAdsJ7NJcEsyCYZcgF82OnBz2k= MISTRAL_API_KEY=JGPjLuNnzaLSYMxKbexLZohUOegrSLye -FLYER_AI_TIMEOUT_MS=45000 +FLYER_AI_TIMEOUT_MS=60000 FLYER_AI_RETRIES=2 FLYER_AI_DEBUG=1 FLYER_AI_DEBUG_DIR=/app/debug diff --git a/backend/src/ai/ai.service.ts b/backend/src/ai/ai.service.ts index 4383ef17..7a49f008 100644 --- a/backend/src/ai/ai.service.ts +++ b/backend/src/ai/ai.service.ts @@ -2,7 +2,7 @@ import { Injectable, Logger, ServiceUnavailableException } from '@nestjs/common' import { FlatCategory } from '../categories/categories.service'; const MISTRAL_API_URL = 'https://api.mistral.ai/v1/chat/completions'; -export const AI_CATEGORIZATION_MODEL = 'mistral-tiny'; +export const AI_CATEGORIZATION_MODEL = 'mistral-8b-2512'; const MODEL = AI_CATEGORIZATION_MODEL; export type CategorySuggestion = { diff --git a/backend/src/flyer-import/services/ai-flyer-parser.service.ts b/backend/src/flyer-import/services/ai-flyer-parser.service.ts index 7828f234..57f93514 100644 --- a/backend/src/flyer-import/services/ai-flyer-parser.service.ts +++ b/backend/src/flyer-import/services/ai-flyer-parser.service.ts @@ -56,7 +56,7 @@ export class AiFlyerParserService { } /** - * Skickar flyer-text till Mistral Tiny för strukturerad extraktion. + * Skickar flyer-text till mistral-8b-2512 för strukturerad extraktion. * * @param text Text från flyern (från pdf-parse eller OCR) * @returns Array av parsade produkter @@ -169,7 +169,7 @@ Extrahera ALL produktinformation från följande text och returnera den som en J För varje produkt, inkludera: - name: Produktnamn (fullständigt namn) - weight: Vikt (om tillgänglig, t.ex. "150g", "Ca 1kg") eller null -- origin: Ursprung/land/märke (om tillgänglig, t.ex. "FALKENBERG") eller null +- origin: Ursprung/land/märke (om tillgänglig, t.ex. "Grönland") eller null - price: Pris som nummer (t.ex. 39.90) eller null - comparisonPrice: Jämförpris som nummer (t.ex. 266.00) eller null - unit: Enhet (kg, st, förp, l, etc.) eller null @@ -187,7 +187,7 @@ Exempel på utdata: { "name": "KALLRÖKT LAX, GRAVAD LAX", "weight": "150g", - "origin": "FALKENBERG", + "origin": "Grönland", "price": 39.90, "comparisonPrice": 266.00, "unit": "kg", @@ -315,7 +315,7 @@ Exempel på utdata: const response = await this.withTimeout( client.chat({ - model: 'mistral-tiny', + model: 'mistral-8b-2512', messages: [{ role: 'user', content: prompt }], temperature: 0.1, }), diff --git a/backend/src/recipes/recipes.service.ts b/backend/src/recipes/recipes.service.ts index 61a96d31..bac47435 100644 --- a/backend/src/recipes/recipes.service.ts +++ b/backend/src/recipes/recipes.service.ts @@ -666,7 +666,7 @@ Regler: Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ - model: 'mistral-small-latest', + model: 'mistral-8b-2512', messages: [ { role: 'system', content: systemPrompt }, { role: 'user', content: userPrompt },