fix(agent-chat): ajouter handler QUERY pour les infos workflow

Le chat listait les workflows mais répondait "Je n'ai pas d'information"
quand l'utilisateur demandait des détails. Le handler QUERY utilise
maintenant SemanticMatcher.find_workflow() + get_workflow_help() pour
retourner description, tags et paramètres supportés.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dom
2026-03-14 16:37:24 +01:00
parent 148321dffd
commit 79c19c5e9d

View File

@@ -530,10 +530,15 @@ def api_chat():
result = {"error": "Pas de workflow spécifié"}
elif intent.intent_type == IntentType.LIST:
# Lister les workflows
# Lister les workflows avec métadonnées enrichies
if matcher:
workflows = [
{"name": wf.name, "description": wf.description}
{
"name": wf.name,
"description": wf.description or "Workflow appris automatiquement",
"tags": wf.tags[:3] if wf.tags else [],
"id": wf.workflow_id,
}
for wf in matcher.get_all_workflows()
]
result = {"workflows": workflows}
@@ -558,6 +563,33 @@ def api_chat():
result = {"history": command_history[-10:]}
action_taken = "history_shown"
elif intent.intent_type == IntentType.QUERY:
# Rechercher des infos sur le workflow demandé
topic = intent.workflow_hint or intent.raw_query
if matcher and topic:
# Tenter de trouver le workflow correspondant
match = matcher.find_workflow(topic, min_confidence=0.3)
if match:
help_text = matcher.get_workflow_help(match.workflow_id)
result = {"answer": help_text}
else:
# Peut-être une question générale sur les workflows dispo
all_wf = matcher.get_all_workflows()
if all_wf:
wf_list = "\n".join(
f"• **{wf.name}**: {wf.description or 'Pas de description'}"
for wf in all_wf[:10]
)
result = {
"answer": f"Je n'ai pas trouvé de workflow '{topic}', "
f"mais voici les workflows disponibles :\n{wf_list}"
}
else:
result = {}
else:
result = {}
action_taken = "query_answered"
elif intent.intent_type == IntentType.HELP:
result = {}
action_taken = "help_shown"