33800 Docs

← Retour

Task : Intent Detection Layer + Upload Fichiers Chat AI

Date : 01/02/2026 00:30 (maj 10:20) Statut : EN COURS (tests front manuels restants)


Contexte

Le chat AI utilisait un prompt systeme de ~4500 tokens pour que le LLM (mistral 7B) genere des [TOOL_CALL:] structurees. Ca ne fonctionnait pas car mistral ne suit pas les instructions structurees. Solution : detection d'intent deterministe (code pur) + execution directe API + LLM uniquement pour formater les resultats.

Travail realise

1. Intent Detection Layer (intentDetector.ts) - CREE

Fichier : connectors-api/src/services/intentDetector.ts

2. Intent Executor (intentExecutor.ts) - CREE

Fichier : connectors-api/src/services/intentExecutor.ts

3. Integration aiChat.ts - MODIFIE

Fichier : connectors-api/src/services/aiChat.ts

4. Upload de fichiers - CREE/MODIFIE

Backend (connectors-api/src/index.ts) :

Frontend (connectors-front) :

src/components/ai/ChatInput.tsx - reecrit :

src/components/ai/ChatMessages.tsx - modifie :

src/lib/api.ts - modifie :

src/routes/chat/[id]/index.tsx - modifie :

5. Corrections de bugs

Bug Cause Fix Commit
Web-search → fallback au lieu de haute confiance medium confidence + pas de candidates Upgrade confidence quand endpoint+instance resolus 3d2fbcd
SearchTerms capture mauvais mots Regex lazy (.+?) Regex greedy (.+) + nettoyage bruit web 3d2fbcd
Scraper key = 'web-scraper' au lieu de 'scraper' Mauvais nom dans CONNECTOR_KEYWORDS Renomme en 'scraper' d0661f7
URL hackernews → web-search au lieu de scraper "news" dans URL matche web-search generic Step D0 : URL priority detection 6184528
YOLO + attachment → fallback Guard check intent.body?.url ignore bucketPath Ajoute \|\| intent.body?.bucketPath 7d0833e
Frontend build fail trailing comma Virgule apres methode dans classe Supprime virgule edf1e1d
"images chats" → clarification au lieu de ComfyUI AI_TOOL_KEYWORDS trop rigides (phrases exactes) Reecrit avec verb+noun pattern, exclusion si connecteur present c15cfbd
"batman" URLs hallucinées (/_playerUrl) JSON brut tronqué à 1500 chars, LLM invente les URLs manquantes preFormatMediaItems() : markdown compact avec vraies URLs 1b07d5b
URLs localhost:8080 dans réponses Jellyfin LLM invente des URLs absolues à partir de /player?src=... Remplacement par liens directs Jellyfin web UI (/web/index.html#!/details?id=X) 4f3c0cd
"affiche le film batman" → retourne TOUS les items Pas d'extraction searchTerm pour action "list" extractSubject() extrait le sujet des requêtes list 4f3c0cd
connector is not defined dans resolveJellyfinEndpoint Variable connector pas dans le scope de la fonction Passage de 'jellyfin' en dur 795fde8
Generation image hang/crash (SSE jamais ferme) Erreur AI job silencieusement avalee, pas de done SSE Branche else pour sauver erreur + return. Heartbeat SSE 15s pendant polling 56b83d4
Image generee affichee en texte au lieu d'inline Fichier genere: url en texte brut au lieu de markdown image ![Image generee](url) + [Telecharger](url) dans intent path 2d6354d
Image toujours en texte (fallback LLM path) Lignes 650-660 aiChat.ts utilisaient encore ancien format Meme fix markdown dans fallback tool_call path 382f29a
Image toujours en texte (formattedData fallback) intentExecutor.ts:322 utilisait Fichier genere: en texte Fix markdown image dans formattedData intentExecutor 965400a

Commits

connectors-api (projet GitLab #105)

965400a fix: use markdown image format in intentExecutor formattedData
382f29a fix: use markdown image format in fallback LLM tool_call path
2d6354d fix: display generated images inline with markdown syntax
56b83d4 fix: handle AI job errors + SSE heartbeat during polling
795fde8 fix(intent): pass connector name to extractSubject in jellyfin endpoint
4f3c0cd fix(intent): link to Jellyfin web UI + extract subject from list queries
1b07d5b fix(intent): pre-format media items to prevent LLM URL hallucination
c15cfbd fix(intent): improve AI generation detection with verb+noun pattern
7d0833e fix(intent): YOLO check includes bucketPath for uploaded images
b1b4bd3 feat(chat): file upload support for chat messages
2f72bc9 feat(intent): add YOLO object detection support
6184528 feat(intent): prioritize scraper when message contains URL
d0661f7 fix(intent): use correct connector type 'scraper' instead of 'web-scraper'
3d2fbcd fix(intent): upgrade confidence when endpoint+instance resolved, fix search terms
... (commits anterieurs pour intent detection layer)

connectors-front (projet GitLab #113)

edf1e1d fix(api): remove trailing comma in class method
0e170a4 feat(chat): file upload UI and attachment display
a1d15c7 feat(chat): SSE streaming progress indicators

Pipelines CI/CD

Projet Pipeline Statut
connectors-api #640 SUCCESS (upload + attachments)
connectors-api #643 SUCCESS (fix AI generation detection)
connectors-api #644 SUCCESS (fix URLs hallucinées media)
connectors-api #645 SUCCESS (liens Jellyfin directs + extractSubject)
connectors-api #646 SUCCESS (fix connector not defined)
connectors-api #648 SUCCESS (fix AI job error handling + SSE heartbeat)
connectors-api #649 SUCCESS (fix image display intent path)
connectors-api #650 SUCCESS (fix image display fallback path)
connectors-api #651 SUCCESS (fix image display intentExecutor formattedData)
connectors-front #641 SUCCESS (upload UI + attachment display)

Tests effectues (curl)

Test Resultat
"affiche la derniere video sur jellyfin" OK - haute confiance jellyfin, liens player
"recherche macron sur le web" OK - haute confiance web-search, resultats SearXNG
"ouvre la page https://news.ycombinator.com" OK - haute confiance scraper, contenu HN
YOLO avec URL image Wikipedia chat OK - 1 chat detecte, 88% confiance
Upload image (POST multipart) OK - retourne attachment avec id/filename/mime/size
Message + attachment_id "analyse cette image" OK - haute confiance YOLO, detection executee
Chat normal "bonjour" OK - fallback LLM sans tool call
"peux tu me donner deux images chats" OK - haute confiance comfyui (job lance)
"affiche la derniere video sur jellyfin" (regression) OK - haute confiance jellyfin (pas wan21)
"cherche batman sur jellyfin" (URLs hallucinées) OK - URLs réelles pour tous les 8 films Batman
"affiche la derniere video" (URLs) OK - URL correcte, image correcte, metadata (37min, serie)
"affiche le film batman sur jellyfin" (URLs directes) OK - liens Jellyfin web UI, searchTerm=batman, 8 films
"genere moi une image de chat" (crash) OK - haute confiance comfyui, job lancé sans crash
"fais moi une image de paysage" (markdown) OK - ![Image generee](url) inline + lien telecharger

Tests restants (navigateur sur https://connectors-front.33800.nowhere84.com)

Upload de fichiers (ChatInput)

Envoi avec piece jointe

Affichage messages (ChatMessages)

Generation d'images (intent AI)

Connecteurs (intent fetch)

Chat normal (fallback)

Prioritaires : bouton trombone, YOLO+image, texte seul, image de chat, batman jellyfin, derniere video, bonjour

Fichiers crees/modifies

Fichier Action
connectors-api/src/services/intentDetector.ts CREE
connectors-api/src/services/intentExecutor.ts CREE
connectors-api/src/services/aiChat.ts MODIFIE (integration intent + attachments)
connectors-api/src/index.ts MODIFIE (route upload + stream attachment_ids)
connectors-front/src/components/ai/ChatInput.tsx REECRIT (upload fichiers)
connectors-front/src/components/ai/ChatMessages.tsx MODIFIE (affichage attachments)
connectors-front/src/lib/api.ts MODIFIE (uploadChatAttachment + attachmentIds)
connectors-front/src/routes/chat/[id]/index.tsx MODIFIE (attachmentIds + conversationId)
~/propositions/01-02-2026-00-00-upload-fichiers-chat-ai.md CREE