feat(ai): localize AI features

This commit is contained in:
Sepehr Ramezani
2026-02-15 17:38:16 +01:00
parent 8f9031f076
commit 9eb3bd912a
72 changed files with 17098 additions and 7759 deletions

View File

@@ -17,7 +17,7 @@ export async function POST(request: NextRequest) {
}
const body = await request.json()
const { notebookId } = body
const { notebookId, language = 'en' } = body
if (!notebookId || typeof notebookId !== 'string') {
return NextResponse.json(
@@ -45,7 +45,8 @@ export async function POST(request: NextRequest) {
// Get label suggestions
const suggestions = await autoLabelCreationService.suggestLabels(
notebookId,
session.user.id
session.user.id,
language
)
if (!suggestions) {

View File

@@ -16,9 +16,25 @@ export async function POST(request: NextRequest) {
)
}
// Get language from request headers or body
let language = 'en'
try {
const body = await request.json()
if (body.language) {
language = body.language
}
} catch (e) {
// If no body or invalid json, check headers
const acceptLanguage = request.headers.get('accept-language')
if (acceptLanguage) {
language = acceptLanguage.split(',')[0].split('-')[0]
}
}
// Create organization plan
const plan = await batchOrganizationService.createOrganizationPlan(
session.user.id
session.user.id,
language
)
return NextResponse.json({

View File

@@ -17,7 +17,7 @@ export async function POST(request: NextRequest) {
}
const body = await request.json()
const { notebookId } = body
const { notebookId, language = 'en' } = body
if (!notebookId || typeof notebookId !== 'string') {
return NextResponse.json(
@@ -45,7 +45,8 @@ export async function POST(request: NextRequest) {
// Generate summary
const summary = await notebookSummaryService.generateSummary(
notebookId,
session.user.id
session.user.id,
language
)
if (!summary) {

View File

@@ -10,7 +10,7 @@ export async function POST(req: NextRequest) {
}
const body = await req.json()
const { noteContent } = body
const { noteContent, language = 'en' } = body
if (!noteContent || typeof noteContent !== 'string') {
return NextResponse.json({ error: 'noteContent is required' }, { status: 400 })
@@ -29,7 +29,8 @@ export async function POST(req: NextRequest) {
// Get suggestion from AI service
const suggestedNotebook = await notebookSuggestionService.suggestNotebook(
noteContent,
session.user.id
session.user.id,
language
)
return NextResponse.json({

View File

@@ -8,6 +8,7 @@ import { z } from 'zod';
const requestSchema = z.object({
content: z.string().min(1, "Le contenu ne peut pas être vide"),
notebookId: z.string().optional(),
language: z.string().default('en'),
});
export async function POST(req: NextRequest) {
@@ -18,14 +19,15 @@ export async function POST(req: NextRequest) {
}
const body = await req.json();
const { content, notebookId } = requestSchema.parse(body);
const { content, notebookId, language } = requestSchema.parse(body);
// If notebookId is provided, use contextual suggestions (IA2)
if (notebookId) {
const suggestions = await contextualAutoTagService.suggestLabels(
content,
notebookId,
session.user.id
session.user.id,
language
);
// Convert label → tag to match TagSuggestion interface
@@ -37,7 +39,7 @@ export async function POST(req: NextRequest) {
...(s.isNewLabel !== undefined && { isNewLabel: s.isNewLabel })
}));
return NextResponse.json({ tags: convertedTags });
return NextResponse.json({ tags: convertedTags });
}
// Otherwise, use legacy auto-tagging (generates new tags)