feat(assistant): #91 etapes enrichies (sous-sections Reflechon/Sources, chevrons, indicateur anime, suppression barre de chargement)
CI / lint (push) Successful in 1m23s
CI / security (push) Successful in 58s
CI / test (push) Successful in 2m43s
CI / build (push) Successful in 55s
CI / e2e (push) Successful in 11m8s

This commit is contained in:
2026-09-15 22:53:15 -04:00
parent 431fb5626d
commit f630771150
13 changed files with 477 additions and 80 deletions
+32 -1
View File
@@ -333,10 +333,41 @@ def _effective_model(provider: str | None, requested: str | None) -> str:
return PROVIDERS.get(provider, {}).get("model", "") or ""
def _tool_sources(rec) -> list[dict[str, str]]:
"""Compact web sources of a tool result (rendered as links in the UI).
Only the web tools produce sources: ``web_search`` returns ranked results,
``fetch_url`` a single page. Everything else yields an empty list so the
SSE payload stays small.
"""
data = rec.result if isinstance(rec.result, dict) else {}
name = rec.name or ""
sources: list[dict[str, str]] = []
if name == "web_search":
for item in (data.get("results") or [])[:8]:
if not isinstance(item, dict):
continue
url = item.get("url") or ""
if not url:
continue
sources.append({"title": item.get("title") or url, "url": url})
elif name == "fetch_url":
url = data.get("url") or ""
if url:
sources.append({"title": data.get("title") or url, "url": url})
return sources
def _tool_event_sse(rec) -> str:
"""Serialize one executed tool call as an SSE ``tool`` event."""
payload = json.dumps(
{"name": rec.name, "ok": rec.ok, "arguments": rec.arguments, "step": rec.step},
{
"name": rec.name,
"ok": rec.ok,
"arguments": rec.arguments,
"step": rec.step,
"sources": _tool_sources(rec),
},
ensure_ascii=False,
)
return f"event: tool\ndata: {payload}\n\n"
+6 -2
View File
@@ -84,6 +84,10 @@ def tool_step_label(name: str, arguments: dict[str, Any] | None = None) -> dict[
def thought_step_label(text: str) -> dict[str, Any]:
"""Step descriptor for one intermediate reasoning note of the model."""
"""Step descriptor for one intermediate reasoning note of the model.
The note is shown expanded under a “Thought” sub-section in the UI, so it
is kept long enough to be readable (truncation is the safety net).
"""
cleaned = " ".join((text or "").split())
return {"key": "thought", "params": {"value": cleaned[:400]}}
return {"key": "thought", "params": {"value": cleaned[:1200]}}
+18 -1
View File
@@ -150,12 +150,29 @@ def web_search(ctx, params: WebSearchInput) -> dict[str, Any]:
"score": item.get("score"),
}
)
return {
unresponsive = [
name for entry in (data.get("unresponsive_engines") or [])
for name in ([entry[0]] if isinstance(entry, (list, tuple)) and entry else [entry])
if isinstance(name, str)
]
payload: dict[str, Any] = {
"query": query,
"engine": "searxng",
"results": results,
"count": len(results),
}
if unresponsive:
payload["unresponsive_engines"] = unresponsive[:8]
if not results:
# An instance whose upstream engines are all blocked (CAPTCHA / rate
# limit) answers 200 with an empty list. Without an explicit hint the
# model retries the same search until it burns its tool quota.
payload["warning"] = (
"Aucun résultat : les moteurs de recherche de l'instance SearXNG sont "
f"indisponibles ({', '.join(unresponsive[:5]) or 'inconnus'}). "
"Ne relance pas la même recherche — dis-le à l'utilisateur."
)
return payload
@tool(