From e6ab01f6e21d316b72cf4010ff20e629b370a2de Mon Sep 17 00:00:00 2001 From: livdebus Date: Thu, 1 Oct 2026 22:33:30 +0200 Subject: [PATCH] feat(voice): override OpenAI voice defaults for custom Whisper proxy feat(voice): override OpenAI voice defaults for custom Whisper proxy Replace api_server command with entrypoint that patches Onyx voice provider files at runtime. Required because v4.8.x UI does not allow setting api_base/stt_model for OpenAI Whisper. - Force chunked HTTP STT via VOICE_DISABLE_STREAMING_STT=true - Redirect all OpenAI voice constants to aido-whisper-ch.livtec.cloud - Add WHISPER_LANGUAGE=de env var for transcription language --- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 767f548..c5e8b06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,34 @@ name: onyx services: api_server: image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}} + entrypoint: > + sh -c " + # 1. Fallback in factory.py (da UI api_base/stt_model nicht speichert) + sed -i 's|api_base = provider.api_base|api_base = provider.api_base or \"https://aido-whisper-ch.livtec.cloud/v1\"|' /app/onyx/voice/factory.py + sed -i 's|stt_model = provider.stt_model|stt_model = provider.stt_model or \"whisper-1\"|' /app/onyx/voice/factory.py + + # 2. Default API Base in openai.py (wirkt für TTS und interne Fallbacks) + sed -i 's|DEFAULT_OPENAI_API_BASE = \"https://api.openai.com\"|DEFAULT_OPENAI_API_BASE = \"https://aido-whisper-ch.livtec.cloud/v1\"|' /app/onyx/voice/providers/openai.py + + # 3. Sicherheitshalber: Auch die hartkodierten Realtime-Modelle auf whisper-1 setzen + # (falls ein Code-Pfad doch noch Streaming versucht) + sed -i 's|OPENAI_REALTIME_SESSION_MODEL = \"gpt-realtime-1.5\"|OPENAI_REALTIME_SESSION_MODEL = \"whisper-1\"|' /app/onyx/voice/providers/openai.py + sed -i 's|OPENAI_REALTIME_STT_MODEL = \"gpt-realtime-whisper\"|OPENAI_REALTIME_STT_MODEL = \"whisper-1\"|' /app/onyx/voice/providers/openai.py + + # 4. Language-Patch für den Chunked-HTTP-Pfad + # (nur ausführen, wenn transcribe existiert und noch nicht gepatcht) + if grep -q 'def transcribe' /app/onyx/voice/providers/openai.py && ! grep -q 'WHISPER_LANGUAGE' /app/onyx/voice/providers/openai.py; then + sed -i '1i import os' /app/onyx/voice/providers/openai.py + + # Heuristisch: Füge language zum Payload hinzu + if grep -q 'data={' /app/onyx/voice/providers/openai.py; then + sed -i '/data={/a\\ \"language\": os.environ.get(\"WHISPER_LANGUAGE\", \"de\"),' /app/onyx/voice/providers/openai.py + elif grep -q 'json={' /app/onyx/voice/providers/openai.py; then + sed -i '/json={/a\\ \"language\": os.environ.get(\"WHISPER_LANGUAGE\", \"de\"),' /app/onyx/voice/providers/openai.py + fi + fi + exec uvicorn onyx.main:app --host 0.0.0.0 --port 8080 + " command: > /bin/sh -c "alembic upgrade head && echo \"Starting Onyx Api Server\" && uvicorn onyx.main:app --host 0.0.0.0 --port 8080" @@ -43,6 +71,8 @@ services: # Onyx Craft configuration (disabled by default, set ENABLE_CRAFT=true in .env to enable) # Use --include-craft with install script, or manually set in .env file - ENABLE_CRAFT=${ENABLE_CRAFT:-false} + - VOICE_DISABLE_STREAMING_STT=true + - WHISPER_LANGUAGE=de # PRODUCTION: Uncomment the line below to use if IAM_AUTH is true and you are using iam auth for postgres # volumes: # - ./bundle.pem:/app/bundle.pem:ro