feat(voice): specialize prompt for Isfahan Industrial Parks, emit source excerpts, and bound generation
- Specialize voice assistant identity and agent system prompt for «شرکت شهرکهای صنعتی اصفهان» (English instructions with Persian proper names) - Emit bounded chunk text excerpts (up to 2000 chars) and identify primary_source in realtime sources events - Bound OpenAI output generation via OPENAI_REALTIME_MAX_OUTPUT_TOKENS and add answer_limited event - Handle old-turn search cancellation safely on turn supersession - Add end-to-end search tracing pipeline and diagnostic CLI - Add database organization title and settings update script
This commit is contained in:
@@ -10,6 +10,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
class OpenAIInputSettings(BaseModel):
|
||||
"""Bounded operator configuration for committed-turn ASR and server VAD."""
|
||||
model_config = dict(frozen=True, extra='forbid', hide_input_in_errors=True)
|
||||
openai_realtime_max_output_tokens: int = Field(default=256, ge=1, le=4096, strict=True)
|
||||
openai_realtime_reasoning_effort: Literal['low', 'medium'] | None = None
|
||||
openai_realtime_asr_model: Literal['whisper-1', 'gpt-transcribe'] = 'whisper-1'
|
||||
openai_realtime_asr_language: Literal['fa', 'en'] | None = 'fa'
|
||||
@@ -21,6 +22,13 @@ class OpenAIInputSettings(BaseModel):
|
||||
openai_realtime_vad_silence_duration_ms: int = Field(default=500, ge=100, le=2000)
|
||||
openai_realtime_noise_reduction: Literal['near_field', 'far_field'] | None = None
|
||||
|
||||
@field_validator('openai_realtime_max_output_tokens', mode='before')
|
||||
@classmethod
|
||||
def generation_limit(cls, value):
|
||||
if isinstance(value, str) and value.isascii() and value.isdecimal():
|
||||
return int(value)
|
||||
return value
|
||||
|
||||
@field_validator('openai_realtime_asr_language', 'openai_realtime_noise_reduction',
|
||||
'openai_realtime_reasoning_effort', mode='before')
|
||||
@classmethod
|
||||
@@ -198,6 +206,7 @@ class VoiceSettings(OpenAIInputSettings, BaseSettings):
|
||||
profile = dict(provider=self.provider, model=self.selected_model, voice=self.selected_voice,
|
||||
input_sample_rate=16000 if self.provider == 'gemini' else 24000, output_sample_rate=24000)
|
||||
if self.provider == 'openai':
|
||||
profile['max_output_tokens'] = self.openai_realtime_max_output_tokens
|
||||
profile['audio_input'] = self.audio_input()
|
||||
profile['reasoning'] = self.reasoning(self.selected_model)
|
||||
from app.infrastructure.realtime import POLICY
|
||||
|
||||
Reference in New Issue
Block a user