- Add internal reuse_last_evidence tool for continuing existing topic without repeated retrieval - Expand OpenAI output capacity to 120s / 5,760,000 bytes and add delivery fairness - Coalesce adjacent user ASR transcript deltas to prevent client control queue overflow - Add server-side OPENAI_REALTIME_SPEED configuration and update style to v4 - Add extensive unit and integration regressions for evidence reuse, capacity, and fairness
27 lines
1.5 KiB
Python
27 lines
1.5 KiB
Python
"""Selected voice transport construction shared by the API and operator smoke."""
|
|
import asyncio
|
|
from app.infrastructure.gemini_live import GeminiLiveAdapter, connect_gemini
|
|
from app.infrastructure.realtime import RealtimeAdapter, connect as connect_openai
|
|
|
|
|
|
async def create_adapter(config, limits):
|
|
config.require_voice()
|
|
if config.provider == 'gemini' and limits.output_capacity_profile != 'standard':
|
|
raise ValueError('OpenAI output capacity cannot be used for Gemini')
|
|
input_settings = None
|
|
if config.provider == 'openai':
|
|
from app.modules.voice.configuration import OpenAIInputSettings
|
|
input_settings = OpenAIInputSettings.model_validate({
|
|
key: getattr(config, key) for key in OpenAIInputSettings.model_fields})
|
|
input_settings.reasoning(config.selected_model)
|
|
connect = connect_gemini if config.provider == 'gemini' else connect_openai
|
|
transport = await asyncio.wait_for(connect(config.selected_key.get_secret_value(),
|
|
config.selected_model, config.selected_proxy, limits), limits.connect_timeout_seconds)
|
|
try:
|
|
adapter = GeminiLiveAdapter if config.provider == 'gemini' else RealtimeAdapter
|
|
return adapter(transport, model=config.selected_model, voice=config.selected_voice, settings=limits,
|
|
**({'input_settings': input_settings} if config.provider == 'openai' else {}))
|
|
except BaseException:
|
|
await asyncio.wait_for(transport.close(), limits.send_timeout_seconds)
|
|
raise
|