Files
Momento/memento-note/app/api/ai/test-chat/route.ts
sepehr 153c921960
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m7s
fix: comprehensive i18n — replace hardcoded French/English strings with t() calls
Replaced ~100+ hardcoded French and English text strings across 30+ components
with proper i18n t() calls. Added 57 new translation keys to all 15 locale files
(ar, de, en, es, fa, fr, hi, it, ja, ko, nl, pl, pt, ru, zh).

Key changes:
- contextual-ai-chat.tsx: 30 French strings → t() (actions, toasts, labels, placeholders)
- ai-chat.tsx: 15 French/English strings → t() (header, tabs, welcome, insights, history)
- note-inline-editor.tsx: 20 French fallbacks removed (toolbar, save status, checklist)
- lab-skeleton.tsx: French loading text → t()
- admin-header.tsx, header.tsx, editor-connections-section.tsx: French fallbacks removed
- New AI chat component, agent cards, sidebar, settings panel i18n cleanup

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 21:14:45 +02:00

47 lines
1.3 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { getChatProvider } from '@/lib/ai/factory'
import { getSystemConfig } from '@/lib/config'
export async function POST(request: NextRequest) {
try {
const config = await getSystemConfig()
const provider = getChatProvider(config)
const testMessage = 'Réponds en exactement 3 mots : quel est ton nom ?'
const startTime = Date.now()
const response = await provider.generateText(testMessage)
const endTime = Date.now()
if (!response || response.trim().length === 0) {
return NextResponse.json(
{
success: false,
error: 'No response from chat provider',
model: config.AI_MODEL_CHAT || 'granite4:latest',
},
{ status: 500 }
)
}
return NextResponse.json({
success: true,
model: config.AI_MODEL_CHAT || 'granite4:latest',
chatResponse: response.trim(),
responseTime: endTime - startTime,
})
} catch (error: any) {
const config = await getSystemConfig()
return NextResponse.json(
{
success: false,
error: error.message || 'Unknown error',
model: config.AI_MODEL_CHAT || 'granite4:latest',
stack: process.env.NODE_ENV === 'development' ? error.stack : undefined,
},
{ status: 500 }
)
}
}