diff --git a/packages/services/voice-agent/src/agent.py b/packages/services/voice-agent/src/agent.py index 4fce32e..3f04de2 100644 --- a/packages/services/voice-agent/src/agent.py +++ b/packages/services/voice-agent/src/agent.py @@ -137,10 +137,17 @@ async def entrypoint(ctx: JobContext) -> None: # Build STT if settings.stt_provider == "openai": from livekit.plugins import openai as openai_plugin + import httpx as _httpx + import openai as _openai + + # OPENAI_BASE_URL may use a self-signed certificate (e.g. proxy) + _http_client = _httpx.AsyncClient(verify=False) + _oai_client = _openai.AsyncOpenAI(http_client=_http_client) stt = openai_plugin.STT( model=settings.openai_stt_model, language=settings.whisper_language, + client=_oai_client, ) else: stt = LocalWhisperSTT( @@ -151,10 +158,16 @@ async def entrypoint(ctx: JobContext) -> None: # Build TTS if settings.tts_provider == "openai": from livekit.plugins import openai as openai_plugin + import httpx as _httpx + import openai as _openai + + _http_client_tts = _httpx.AsyncClient(verify=False) + _oai_client_tts = _openai.AsyncOpenAI(http_client=_http_client_tts) tts = openai_plugin.TTS( model=settings.openai_tts_model, voice=settings.openai_tts_voice, + client=_oai_client_tts, ) else: tts = LocalKokoroTTS( diff --git a/packages/services/voice-agent/src/plugins/agent_llm.py b/packages/services/voice-agent/src/plugins/agent_llm.py index cec7f92..a600068 100644 --- a/packages/services/voice-agent/src/plugins/agent_llm.py +++ b/packages/services/voice-agent/src/plugins/agent_llm.py @@ -100,6 +100,16 @@ class AgentServiceLLMStream(llm.LLMStream): user_text = item.text_content break + if not user_text: + # on_enter/generate_reply may call LLM without a user message; + # look for the developer/system instruction to use as prompt + for item in self._chat_ctx.items: + if getattr(item, "type", None) != "message": + continue + if item.role in ("developer", "system"): + user_text = item.text_content + break + if not user_text: logger.warning("No user message found in chat context") return