fix: resolve magic scan crash and implement context-aware AI languages

- Fixed SQL syntax error in magicScan caused by single quotes
- Implemented dynamic locale-aware AI suggestions (Technical: EN, Custom Tags: Localized)
- Updated Dexie schema to version 2 (added locale to pending_scans)
- Fixed missing bottle_id in UploadQueue synchronization
- Installed missing dexie dependencies via pnpm
This commit is contained in:
2025-12-19 14:06:13 +01:00
parent 60ca3a6190
commit f52cfb80fc
9 changed files with 61 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ import { createHash } from 'crypto';
import { trackApiUsage } from './track-api-usage';
import { checkCreditBalance, deductCredits } from './credit-service';
export async function analyzeBottle(base64Image: string, tags?: string[]): Promise<AnalysisResponse> {
export async function analyzeBottle(base64Image: string, tags?: string[], locale: string = 'de'): Promise<AnalysisResponse> {
const supabase = createServerActionClient({ cookies });
if (!process.env.GEMINI_API_KEY) {
@@ -48,7 +48,9 @@ export async function analyzeBottle(base64Image: string, tags?: string[]): Promi
};
}
const instruction = SYSTEM_INSTRUCTION.replace('{AVAILABLE_TAGS}', tags ? tags.join(', ') : 'No tags available');
const instruction = SYSTEM_INSTRUCTION
.replace('{AVAILABLE_TAGS}', tags ? tags.join(', ') : 'No tags available')
.replace('{LANGUAGE}', locale === 'en' ? 'English' : 'German');
const result = await geminiModel.generateContent([
{