mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-09 03:44:42 +02:00
Sépare STT en deux : - stt/client/ : commande `stt` (pipx), voix locale (Whisper/Piper) + HUD ; envoie le texte au serveur via api.py (ServerClient → POST /v1/ask). URL serveur paramétrable, pas de cerveau local (suppression du routeur 3 modes). - stt/server/ : STT-server FastAPI (conteneur), /healthz + /v1/ask → LiteLLM (Qwen3/Claude). Déploiement cluster : - k8s/apps/stt/ : Deployment, Service, IngressRoute (stt.lab.local), litellm-ext (Service + Endpoints → 192.168.10.1:4000 pour joindre LiteLLM hors cluster) - k8s/apps-of-apps/apps/stt.yaml : Application ArgoCD (depuis main) - .github/workflows/build-stt-server.yml : build/push image → ghcr.io/alkatrazz24/funk-stt-server Inférence/chat seulement (outils Hermes 'agir sur Funk' = phase ultérieure, API :8080 à spécifier). Vérifié : py_compile client+serveur, YAML manifests, ServerClient. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FmcxGsyXZXogiAHQLjnZT
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
"""STT-server — API FastAPI pour les clients STT.
|
|
|
|
Endpoints :
|
|
GET /healthz → état du service
|
|
POST /v1/ask {text} → {reply} (requête AI, orchestrée vers LiteLLM)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import httpx
|
|
from fastapi import FastAPI, HTTPException
|
|
from pydantic import BaseModel
|
|
|
|
from stt_server import __version__
|
|
from stt_server.brain import ask as brain_ask
|
|
|
|
app = FastAPI(title="STT-server", version=__version__)
|
|
|
|
|
|
class AskRequest(BaseModel):
|
|
text: str
|
|
|
|
|
|
class AskReply(BaseModel):
|
|
reply: str
|
|
|
|
|
|
@app.get("/healthz")
|
|
async def healthz() -> dict:
|
|
return {"status": "ok", "version": __version__}
|
|
|
|
|
|
@app.post("/v1/ask", response_model=AskReply)
|
|
async def v1_ask(req: AskRequest) -> AskReply:
|
|
text = req.text.strip()
|
|
if not text:
|
|
raise HTTPException(status_code=400, detail="text vide")
|
|
try:
|
|
reply = await brain_ask(text)
|
|
except httpx.HTTPError as e:
|
|
raise HTTPException(status_code=502, detail=f"upstream LiteLLM : {e}") from e
|
|
return AskReply(reply=reply)
|
|
|
|
|
|
def run() -> None:
|
|
"""Entrypoint `stt-server` (dev local). En prod : uvicorn via le conteneur."""
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000) # noqa: S104 — service interne au cluster
|