You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks. I've been running dograh self-hosted for a small voice project, and while wiring up a realtime agent I spent some time in api/services/pipecat/service_factory.py. The realtime provider dispatch in create_realtime_llm_service is around 240 lines of if/elif at this point (service_factory.py:1295 through :1538), and it isn't even the only chain in the file; the separate STT/LLM/TTS dispatch ends at :1292 the same way, with raise HTTPException(400, "Invalid LLM provider ...").
Most branches repeat the same three steps: import the Dograh subclass, import that provider's event types, assemble settings. A few do real provider-specific work, like OpenAI's transcription-language pinning (:1344-:1350) and Grok's voice-name normalization (:1380-:1382). That provider-specific part is what a registry entry would keep.
The telephony side already has the pattern: api/services/telephony/registry.py keeps a name-keyed _REGISTRY of ProviderSpec objects (:359), registers each provider at import time (:382-:391), and does sorted lookups (:394-:413). Doing the same for realtime/LLM creation would give the pipecat layer what telephony already has. Adding a provider becomes one spec plus one registration instead of another elif arm.
There's also already a hint that the subclass shape works: api/services/pipecat/realtime/azure_realtime.py:7-:10 mixes DograhOpenAIRealtimeLLMService with pipecat's AzureRealtimeLLMService through multiple inheritance. And you can see the duplication pressure in the realtime subclasses themselves: openai_realtime.py:126-:210 and grok_realtime.py:108-:210 parallel each other on greeting/session-ready state handling and diverge mostly in the session.update payloads.
Each provider module would register a spec whose build closure holds today's branch body verbatim, imports and all. create_realtime_llm_service becomes read config, resolve spec, call build. The shared parts (logging, vertex_location, the unknown-provider 400) stay in the factory so the failure surface doesn't change.
On scope: this is about the dispatch structure only. Branch bodies would move verbatim so provider behavior doesn't change, and the config schema doesn't change either. The STT/LLM/TTS chain has the same problem, but that's a follow-up, not part of a first step.
Three questions:
Is there a reason to keep the chain? Planned deprecations, or plans to handle this differently?
Would you prefer one registry module under api/services/pipecat/, or import-time registration from each provider module the way telephony does it?
If this is interesting, I'm glad to prepare the realtime PR first. Or if the telephony registry is about to be generalized anyway, I'm happy to wait for that shape.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi folks. I've been running dograh self-hosted for a small voice project, and while wiring up a realtime agent I spent some time in
api/services/pipecat/service_factory.py. The realtime provider dispatch increate_realtime_llm_serviceis around 240 lines of if/elif at this point (service_factory.py:1295through:1538), and it isn't even the only chain in the file; the separate STT/LLM/TTS dispatch ends at:1292the same way, withraise HTTPException(400, "Invalid LLM provider ...").Most branches repeat the same three steps: import the Dograh subclass, import that provider's event types, assemble settings. A few do real provider-specific work, like OpenAI's transcription-language pinning (
:1344-:1350) and Grok's voice-name normalization (:1380-:1382). That provider-specific part is what a registry entry would keep.The telephony side already has the pattern:
api/services/telephony/registry.pykeeps a name-keyed_REGISTRYofProviderSpecobjects (:359), registers each provider at import time (:382-:391), and does sorted lookups (:394-:413). Doing the same for realtime/LLM creation would give the pipecat layer what telephony already has. Adding a provider becomes one spec plus one registration instead of anotherelifarm.There's also already a hint that the subclass shape works:
api/services/pipecat/realtime/azure_realtime.py:7-:10mixesDograhOpenAIRealtimeLLMServicewith pipecat'sAzureRealtimeLLMServicethrough multiple inheritance. And you can see the duplication pressure in the realtime subclasses themselves:openai_realtime.py:126-:210andgrok_realtime.py:108-:210parallel each other on greeting/session-ready state handling and diverge mostly in the session.update payloads.A sketch to make it concrete:
Each provider module would register a spec whose
buildclosure holds today's branch body verbatim, imports and all.create_realtime_llm_servicebecomes read config, resolve spec, call build. The shared parts (logging,vertex_location, the unknown-provider 400) stay in the factory so the failure surface doesn't change.On scope: this is about the dispatch structure only. Branch bodies would move verbatim so provider behavior doesn't change, and the config schema doesn't change either. The STT/LLM/TTS chain has the same problem, but that's a follow-up, not part of a first step.
Three questions:
api/services/pipecat/, or import-time registration from each provider module the way telephony does it?All reactions