feat: POST /corrections/eo — Gemini transcription + DeepSeek EO — 84/84 tests

This commit is contained in:
Hermann_Kitio 2026-04-16 17:43:46 +03:00
parent 77d5a8373e
commit f4f8c55ce7
7 changed files with 422 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import type { AppVariables } from '../middleware/auth'
import * as correctionController from '../controllers/correctionController'
const VALID_TACHES_EE = ['EE_T1', 'EE_T2', 'EE_T3']
const VALID_TACHES_EO = ['EO_T1', 'EO_T3']
const corrections = new Hono<{ Variables: AppVariables }>()
@ -58,4 +59,55 @@ corrections.post('/ee', authMiddleware, async (c) => {
return c.json(result.data, 200)
})
corrections.post('/eo', authMiddleware, async (c) => {
let body: { simulationId?: unknown; transcript?: unknown; tache?: unknown }
try {
body = await c.req.json()
} catch {
return c.json(
{ error: true, code: 'VALIDATION_ERROR', message: 'Corps de la requête invalide.' },
400
)
}
if (!body.simulationId || typeof body.simulationId !== 'string') {
return c.json(
{ error: true, code: 'VALIDATION_ERROR', message: 'simulationId est requis.' },
400
)
}
if (!body.transcript || typeof body.transcript !== 'string') {
return c.json(
{ error: true, code: 'VALIDATION_ERROR', message: 'transcript est requis.' },
400
)
}
if (!body.tache || !VALID_TACHES_EO.includes(body.tache as string)) {
return c.json(
{
error: true,
code: 'VALIDATION_ERROR',
message: `Tâche invalide. Valeurs acceptées : ${VALID_TACHES_EO.join(', ')}`,
},
400
)
}
const profile = c.get('profile')
const result = await correctionController.correctEO(
body.simulationId as string,
body.transcript as string,
body.tache as string,
profile
)
if ('error' in result) {
return c.json(result, result.status as 401 | 404 | 500)
}
return c.json(result.data, 200)
})
export default corrections