mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-09 01:44:43 +02:00
Qwen3 est un modèle « thinking » : il dépensait tout le budget max_tokens en reasoning_content → content vide, ou partait en raisonnement long → timeout (502 "upstream LiteLLM : " avec message vide). Diagnostic : appel direct LiteLLM en 0.87s mais content="" et tout dans reasoning_content. - brain.py : ajoute le token de contrôle `/no_think` au system prompt (configurable STT_DISABLE_THINKING, défaut true ; inoffensif pour non-Qwen). - brain.py : filet de sécurité — si content vide, récupère reasoning_content au lieu de renvoyer "". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FmcxGsyXZXogiAHQLjnZT
48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
"""Configuration du STT-server — via variables d'environnement (12-factor / k8s)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
class Settings:
|
|
# LiteLLM (s01) — joint en IP directe depuis le cluster (cf. open-webui).
|
|
litellm_url: str = os.getenv(
|
|
"STT_LITELLM_URL", "http://192.168.10.1:4000/v1/chat/completions"
|
|
)
|
|
litellm_key: str = os.getenv("STT_LITELLM_KEY", "lm-studio")
|
|
# Modèle par défaut + alias LiteLLM autorisés (le client peut en demander un par requête)
|
|
model: str = os.getenv("STT_MODEL", "hermes-default")
|
|
allowed_models: list[str] = [
|
|
m.strip()
|
|
for m in os.getenv(
|
|
"STT_ALLOWED_MODELS",
|
|
"hermes-default,qwen3-8b,claude-sonnet-4-6,claude-opus-4-7",
|
|
).split(",")
|
|
if m.strip()
|
|
]
|
|
|
|
system_prompt: str = os.getenv(
|
|
"STT_SYSTEM_PROMPT",
|
|
"Tu es Hermes, l'assistant vocal du homelab Funk. "
|
|
"Réponds toujours en français, de façon concise (2-3 phrases maximum), "
|
|
"sans markdown ni listes.",
|
|
)
|
|
max_tokens: int = int(os.getenv("STT_MAX_TOKENS", "200"))
|
|
temperature: float = float(os.getenv("STT_TEMPERATURE", "0.7"))
|
|
request_timeout: float = float(os.getenv("STT_REQUEST_TIMEOUT", "60"))
|
|
# Qwen3 est un modèle « thinking » → ajoute `/no_think` pour désactiver le raisonnement
|
|
# (sinon content vide / timeout). Inoffensif pour les modèles non-Qwen.
|
|
disable_thinking: bool = os.getenv("STT_DISABLE_THINKING", "true").lower() == "true"
|
|
|
|
# Mémoire long-terme (Qdrant) — dégrade proprement si Qdrant/embeddings injoignables
|
|
memory_longterm: bool = os.getenv("STT_MEMORY_LONGTERM", "true").lower() == "true"
|
|
qdrant_url: str = os.getenv("STT_QDRANT_URL", "http://192.168.10.1:6333")
|
|
qdrant_collection: str = os.getenv("STT_QDRANT_COLLECTION", "stt-memory")
|
|
# Embeddings : instance dédiée nomic-embed-text sur llama-server gpu-01 (:1238, dim 768).
|
|
embed_url: str = os.getenv("STT_EMBED_URL", "http://192.168.10.20:1238/v1/embeddings")
|
|
embed_model: str = os.getenv("STT_EMBED_MODEL", "nomic-embed-text")
|
|
memory_top_k: int = int(os.getenv("STT_MEMORY_TOPK", "3"))
|
|
|
|
|
|
settings = Settings()
|