fix(bifrost): tiers sur gpt-oss (Groq a retiré les llama) + marge de raisonnement

RAPIDE groq/llama-3.1-8b-instant → groq/openai/gpt-oss-20b ; APPROFONDI
groq/llama-3.3-70b-versatile → groq/openai/gpt-oss-120b ; replis inchangés.
Les chatbots vivaient sur le repli Gemini depuis le retrait.

gpt-oss raisonne : ses tokens de raisonnement sont décomptés de max_tokens.
REASONING_MARGIN_TOKENS (800) ajouté au budget des trois routes, et
bifrostContent() signale au journal une réponse tronquée (finish_reason
length). Le champ message.reasoning est ignoré. Défaut WORKER_MODEL aligné
sur la prod. En-têtes « Mistral Small » corrigés, PIPE-IA-DOC §11.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AzGo8bxhHp6M9RxuAFbyLU
This commit is contained in:
Jules Neny
2026-09-28 16:48:24 +02:00
co-authored by Claude Opus 5.5
parent 288a9c9126
commit 8f94a1acda
6 changed files with 91 additions and 19 deletions
+4 -4
View File
@@ -1,12 +1,12 @@
/**
* POST /api/chatbot-reseaux
* Chatbot Réseaux AEP — Carte 2 "Réseaux de bifurcation"
* Keyword search sur reseaux-bifurcation.json + Mistral Small.
* Keyword search sur reseaux-bifurcation.json + LLM via Bifrost (server/utils/bifrost.ts).
*/
// @ts-ignore — JSON import résolu par Rollup
import reseauxData from '../../public/data/reseaux-bifurcation.json'
import { checkRateLimitJson } from '~/server/utils/rateLimitJson'
import { pickBifrostTier, type BifrostChatResponse } from '~/server/utils/bifrost'
import { pickBifrostTier, bifrostContent, REASONING_MARGIN_TOKENS, type BifrostChatResponse } from '~/server/utils/bifrost'
interface Structure {
id: string
@@ -99,7 +99,7 @@ export default defineEventHandler(async (event) => {
model: tier.model,
fallbacks: tier.fallbacks,
temperature: 0.3,
max_tokens: 700,
max_tokens: 700 + REASONING_MARGIN_TOKENS,
response_format: { type: 'json_object' },
messages: [
{ role: 'system', content: systemPrompt },
@@ -108,7 +108,7 @@ export default defineEventHandler(async (event) => {
}),
}
)
mistralRaw = res.choices?.[0]?.message?.content ?? '{}'
mistralRaw = bifrostContent(res, 'chatbot-reseaux')
} catch {
throw createError({ statusCode: 502, message: 'Erreur IA — réessaie dans quelques instants.' })
}