feat: AI category matching — pass all categories to GPT for best-fit selection
Previously: heuristic text matching (sub_type in category.name) — failed for semantic cases like 'Iran Ceasefire Talks' → 'Guerre — Moyen-Orient'. Now: all EventCategories are sent in the prompt (name + type + description). The AI picks matched_category by semantic understanding, returns it in JSON. - Validates returned name against known categories (case-insensitive) - Auto-sets event sub_type when AI finds a match and sub_type was empty - Returns matched_category in evaluate response + shown in UI eval message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -356,7 +356,8 @@ function EventDetail({
|
||||
const r = await fetch(`/api/market-events/${event.id}/evaluate?force=${force}`, { method: 'POST' })
|
||||
const d = await r.json()
|
||||
if (!r.ok) throw new Error(d.detail || r.statusText)
|
||||
setEvalMsg(`✓ ${d.n_instruments} instruments évalués`)
|
||||
const catInfo = d.matched_category ? ` · catégorie: ${d.matched_category}` : ''
|
||||
setEvalMsg(`✓ ${d.n_instruments} instruments évalués${catInfo}`)
|
||||
await loadDetail()
|
||||
} catch (e: any) {
|
||||
setEvalMsg(`✗ ${e.message}`)
|
||||
|
||||
Reference in New Issue
Block a user