How lynchpin1634/middleapi works
MiddleAPI adapts OpenAI-compatible chat clients and GPT-SoVITS: chat requests are proxied to an AI API, whose response text can trigger TTS, while direct speech requests generate or reuse cached audio. Administrators use the Web UI to manage configuration and audio cleanup. The graph preserves the documented audio-list capability, though the sampled backend excerpt shows its page route but not a corresponding list-data endpoint. Connections for sampled code cite its caller; documented UI relationships cite the README.
Main entry points: MiddleAPI.py FastAPI routes · ProxyService.py Chat proxy · GradioUtils.py Gradio client · ConfigUtils.py Config access
Components 22
Web interface
- Home and pages
www/index.html - Settings page
www/settings.html - Audio pages
www/audiolist.html - Cleanup page
www/cleanup.html - Static assets
www/files
API orchestration
- FastAPI routes
MiddleAPI.py - Request models
utils/PydanticUtils.py - Config endpoints
MiddleAPI.py - Audio listing and cleanup
MiddleAPI.py
Speech and proxy
- TTS generation
MiddleAPI.py - Chat proxy
utils/ProxyService.py - Gradio client
utils/GradioUtils.py
Configuration and audio state
- Config access
utils/ConfigUtils.py - YAML configuration
config/config.yaml - Audio cache
Shared utilities
- Response handling
utils/ResponseUtils.py - Text cleanup
utils/TextUtils.py - Logging
utils/LogUtils.py
Other components
- Administrator
- OpenWebUI client
- Compatible AI API
- GPT-SoVITS service
Connections 25
- Administrator → Home and pages: opens
README.md - Home and pages → FastAPI routes: uses UI routes
README.md - Settings page → Config endpoints: manages settings
README.md - Audio pages → Audio listing and cleanup: views audio
README.md - Cleanup page → Audio listing and cleanup: requests cleanup
README.md - FastAPI routes → Static assets: mounts
MiddleAPI.py - OpenWebUI client → FastAPI routes: sends speech requests
README.md - FastAPI routes → Request models: validates with
MiddleAPI.py - FastAPI routes → Response handling: handles errors with
MiddleAPI.py - FastAPI routes → TTS generation: routes speech to
MiddleAPI.py - TTS generation → Audio cache: reads and writes
MiddleAPI.py - TTS generation → Gradio client: requests inference
MiddleAPI.py - Gradio client → Config access: reads parameters
utils/GradioUtils.py - Gradio client → Text cleanup: cleans and maps text
utils/GradioUtils.py - Gradio client → GPT-SoVITS service: calls inference
README.md - FastAPI routes → Chat proxy: delegates chat
MiddleAPI.py - Chat proxy → Compatible AI API: forwards request
utils/ProxyService.py - Chat proxy → FastAPI routes: calls speech endpoint
utils/ProxyService.py - FastAPI routes → Config endpoints: routes config operations
MiddleAPI.py - Config endpoints → Config access: reads and writes
MiddleAPI.py - Config access → YAML configuration: loads and saves
utils/ConfigUtils.py - FastAPI routes → Audio listing and cleanup: routes audio operations
MiddleAPI.py - Audio listing and cleanup → Audio cache: cleans files
MiddleAPI.py - Config access → Logging: logs failures
utils/ConfigUtils.py - Chat proxy → Logging: logs proxy events
utils/ProxyService.py