Add authenticated upload, review, retry and knowledge-selection HTTP flows with bounded JSON processing and frozen OCR policy. Preserve Gemini/OpenAI provider selection and fenced lifecycle semantics; retain FAQ preambles and uncertain vision candidates, and expose opt-in uncalibrated voice transport diagnostics. Include frontend integration examples, aligned contracts and deterministic regressions. Validation: 1767 provider-free tests passed; all 404 PostgreSQL scenarios have passing evidence across the documented runs.
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Supported single-process API entrypoint: python -m app.server."""
|
|
import argparse
|
|
import uvicorn
|
|
from app.infrastructure.voice_websocket import BoundedWebSocketProtocol
|
|
|
|
|
|
from app.modules.voice.settings import RuntimeSettings
|
|
|
|
|
|
def server_config(app='app.main:app', *, host='127.0.0.1', port=8000, settings=None, **kwargs):
|
|
if settings is None:
|
|
settings = RuntimeSettings()
|
|
max_binary = settings.max_binary_message_bytes
|
|
max_control = settings.max_client_control_bytes
|
|
max_size = max(max_binary, max_control)
|
|
audio_budget = min(settings.max_queued_audio_messages, max(1, settings.max_queued_audio_bytes // max_binary))
|
|
queue = max(1, audio_budget - 2) if audio_budget > 2 else 1
|
|
config = uvicorn.Config(app, host=host, port=port, workers=1,
|
|
ws=BoundedWebSocketProtocol, ws_max_size=max_size, ws_max_queue=queue,
|
|
ws_per_message_deflate=False, **kwargs)
|
|
config.ws_settings = settings
|
|
return config
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--host', default='127.0.0.1')
|
|
parser.add_argument('--port', type=int, default=8000)
|
|
args = parser.parse_args()
|
|
uvicorn.Server(server_config(host=args.host, port=args.port)).run()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|