Merge pull request #182 from pipecat-ai/aleix/expo-se-dialin-ready
transports(daily): expose dialin-ready and handle timeouts
This commit is contained in:
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Exposed `on_dialin_ready` for Daily transport SIP endpoint handling. This
|
||||||
|
notifies when the Daily room SIP endpoints are ready. This allows integrating
|
||||||
|
with third-party services like Twilio.
|
||||||
|
|
||||||
- Exposed Daily transport `on_app_message` event.
|
- Exposed Daily transport `on_app_message` event.
|
||||||
|
|
||||||
- Added Daily transport `on_call_state_updated` event.
|
- Added Daily transport `on_call_state_updated` event.
|
||||||
@@ -27,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Daily tranport `dialin-ready` doesn't not block anymore and it now handles
|
||||||
|
timeouts.
|
||||||
|
|
||||||
- Fixed AzureLLMService.
|
- Fixed AzureLLMService.
|
||||||
|
|
||||||
## [0.0.23] - 2024-05-23
|
## [0.0.23] - 2024-05-23
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ annotated-types==0.7.0
|
|||||||
# via pydantic
|
# via pydantic
|
||||||
anthropic==0.25.9
|
anthropic==0.25.9
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
anyio==4.3.0
|
anyio==4.4.0
|
||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# httpx
|
# httpx
|
||||||
@@ -40,9 +40,9 @@ click==8.1.7
|
|||||||
# via flask
|
# via flask
|
||||||
coloredlogs==15.0.1
|
coloredlogs==15.0.1
|
||||||
# via onnxruntime
|
# via onnxruntime
|
||||||
ctranslate2==4.3.0
|
ctranslate2==4.2.1
|
||||||
# via faster-whisper
|
# via faster-whisper
|
||||||
daily-python==0.8.0
|
daily-python==0.9.0
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
distro==1.9.0
|
distro==1.9.0
|
||||||
# via
|
# via
|
||||||
@@ -88,7 +88,7 @@ google-api-core[grpc]==2.19.0
|
|||||||
# google-ai-generativelanguage
|
# google-ai-generativelanguage
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
# google-generativeai
|
# google-generativeai
|
||||||
google-api-python-client==2.130.0
|
google-api-python-client==2.131.0
|
||||||
# via google-generativeai
|
# via google-generativeai
|
||||||
google-auth==2.29.0
|
google-auth==2.29.0
|
||||||
# via
|
# via
|
||||||
@@ -127,7 +127,7 @@ httpx==0.27.0
|
|||||||
# openai
|
# openai
|
||||||
httpx-sse==0.4.0
|
httpx-sse==0.4.0
|
||||||
# via fal-client
|
# via fal-client
|
||||||
huggingface-hub==0.23.1
|
huggingface-hub==0.23.2
|
||||||
# via
|
# via
|
||||||
# faster-whisper
|
# faster-whisper
|
||||||
# timm
|
# timm
|
||||||
@@ -236,12 +236,12 @@ pyasn1-modules==0.4.0
|
|||||||
# via google-auth
|
# via google-auth
|
||||||
pyaudio==0.2.14
|
pyaudio==0.2.14
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
pydantic==2.7.1
|
pydantic==2.7.2
|
||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# google-generativeai
|
# google-generativeai
|
||||||
# openai
|
# openai
|
||||||
pydantic-core==2.18.2
|
pydantic-core==2.18.3
|
||||||
# via pydantic
|
# via pydantic
|
||||||
pyht==0.0.28
|
pyht==0.0.28
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ annotated-types==0.7.0
|
|||||||
# via pydantic
|
# via pydantic
|
||||||
anthropic==0.25.9
|
anthropic==0.25.9
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
anyio==4.3.0
|
anyio==4.4.0
|
||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# httpx
|
# httpx
|
||||||
@@ -40,9 +40,9 @@ click==8.1.7
|
|||||||
# via flask
|
# via flask
|
||||||
coloredlogs==15.0.1
|
coloredlogs==15.0.1
|
||||||
# via onnxruntime
|
# via onnxruntime
|
||||||
ctranslate2==4.3.0
|
ctranslate2==4.2.1
|
||||||
# via faster-whisper
|
# via faster-whisper
|
||||||
daily-python==0.8.0
|
daily-python==0.9.0
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
distro==1.9.0
|
distro==1.9.0
|
||||||
# via
|
# via
|
||||||
@@ -87,7 +87,7 @@ google-api-core[grpc]==2.19.0
|
|||||||
# google-ai-generativelanguage
|
# google-ai-generativelanguage
|
||||||
# google-api-python-client
|
# google-api-python-client
|
||||||
# google-generativeai
|
# google-generativeai
|
||||||
google-api-python-client==2.130.0
|
google-api-python-client==2.131.0
|
||||||
# via google-generativeai
|
# via google-generativeai
|
||||||
google-auth==2.29.0
|
google-auth==2.29.0
|
||||||
# via
|
# via
|
||||||
@@ -126,7 +126,7 @@ httpx==0.27.0
|
|||||||
# openai
|
# openai
|
||||||
httpx-sse==0.4.0
|
httpx-sse==0.4.0
|
||||||
# via fal-client
|
# via fal-client
|
||||||
huggingface-hub==0.23.1
|
huggingface-hub==0.23.2
|
||||||
# via
|
# via
|
||||||
# faster-whisper
|
# faster-whisper
|
||||||
# timm
|
# timm
|
||||||
@@ -204,12 +204,12 @@ pyasn1-modules==0.4.0
|
|||||||
# via google-auth
|
# via google-auth
|
||||||
pyaudio==0.2.14
|
pyaudio==0.2.14
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
pydantic==2.7.1
|
pydantic==2.7.2
|
||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# google-generativeai
|
# google-generativeai
|
||||||
# openai
|
# openai
|
||||||
pydantic-core==2.18.2
|
pydantic-core==2.18.3
|
||||||
# via pydantic
|
# via pydantic
|
||||||
pyht==0.0.28
|
pyht==0.0.28
|
||||||
# via pipecat-ai (pyproject.toml)
|
# via pipecat-ai (pyproject.toml)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ Website = "https://pipecat.ai"
|
|||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
anthropic = [ "anthropic~=0.25.7" ]
|
anthropic = [ "anthropic~=0.25.7" ]
|
||||||
azure = [ "azure-cognitiveservices-speech~=1.37.0" ]
|
azure = [ "azure-cognitiveservices-speech~=1.37.0" ]
|
||||||
daily = [ "daily-python~=0.8.0" ]
|
daily = [ "daily-python~=0.9.0" ]
|
||||||
examples = [ "python-dotenv~=1.0.0", "flask~=3.0.3", "flask_cors~=4.0.1" ]
|
examples = [ "python-dotenv~=1.0.0", "flask~=3.0.3", "flask_cors~=4.0.1" ]
|
||||||
fal = [ "fal-client~=0.4.0" ]
|
fal = [ "fal-client~=0.4.0" ]
|
||||||
google = [ "google-generativeai~=0.5.3" ]
|
google = [ "google-generativeai~=0.5.3" ]
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class DailyTranscriptionSettings(BaseModel):
|
|||||||
class DailyParams(TransportParams):
|
class DailyParams(TransportParams):
|
||||||
api_url: str = "https://api.daily.co"
|
api_url: str = "https://api.daily.co"
|
||||||
api_key: str = ""
|
api_key: str = ""
|
||||||
dialin_settings: DailyDialinSettings = DailyDialinSettings()
|
dialin_settings: DailyDialinSettings | None = None
|
||||||
transcription_enabled: bool = False
|
transcription_enabled: bool = False
|
||||||
transcription_settings: DailyTranscriptionSettings = DailyTranscriptionSettings()
|
transcription_settings: DailyTranscriptionSettings = DailyTranscriptionSettings()
|
||||||
|
|
||||||
@@ -673,6 +673,7 @@ class DailyTransport(BaseTransport):
|
|||||||
self._register_event_handler("on_left")
|
self._register_event_handler("on_left")
|
||||||
self._register_event_handler("on_app_message")
|
self._register_event_handler("on_app_message")
|
||||||
self._register_event_handler("on_call_state_updated")
|
self._register_event_handler("on_call_state_updated")
|
||||||
|
self._register_event_handler("on_dialin_ready")
|
||||||
self._register_event_handler("on_dialout_connected")
|
self._register_event_handler("on_dialout_connected")
|
||||||
self._register_event_handler("on_dialout_stopped")
|
self._register_event_handler("on_dialout_stopped")
|
||||||
self._register_event_handler("on_dialout_error")
|
self._register_event_handler("on_dialout_error")
|
||||||
@@ -759,6 +760,9 @@ class DailyTransport(BaseTransport):
|
|||||||
self.on_call_state_updated(state)
|
self.on_call_state_updated(state)
|
||||||
|
|
||||||
async def _handle_dialin_ready(self, sip_endpoint: str):
|
async def _handle_dialin_ready(self, sip_endpoint: str):
|
||||||
|
if not self._params.dialin_settings:
|
||||||
|
return
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {self._params.api_key}",
|
"Authorization": f"Bearer {self._params.api_key}",
|
||||||
@@ -772,19 +776,24 @@ class DailyTransport(BaseTransport):
|
|||||||
|
|
||||||
url = f"{self._params.api_url}/dialin/pinlessCallUpdate"
|
url = f"{self._params.api_url}/dialin/pinlessCallUpdate"
|
||||||
|
|
||||||
async with session.post(url, headers=headers, data=data) as r:
|
try:
|
||||||
if r.status != 200:
|
async with session.post(url, headers=headers, data=data, timeout=10) as r:
|
||||||
text = await r.text()
|
if r.status != 200:
|
||||||
logger.error(
|
text = await r.text()
|
||||||
f"Unable to handle dialin-ready event (status: {r.status}, error: {text})")
|
logger.error(
|
||||||
return
|
f"Unable to handle dialin-ready event (status: {r.status}, error: {text})")
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug("dialin-ready event handled successfully")
|
logger.debug("Event dialin-ready was handled successfully")
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
logger.error(f"Timeout handling dialin-ready event ({url})")
|
||||||
|
except BaseException as e:
|
||||||
|
logger.error(f"Error handling dialin-ready event ({url}): {e}")
|
||||||
|
|
||||||
def _on_dialin_ready(self, sip_endpoint):
|
def _on_dialin_ready(self, sip_endpoint):
|
||||||
future = asyncio.run_coroutine_threadsafe(
|
if self._params.dialin_settings:
|
||||||
self._handle_dialin_ready(sip_endpoint), self._loop)
|
asyncio.run_coroutine_threadsafe(self._handle_dialin_ready(sip_endpoint), self._loop)
|
||||||
future.result()
|
self.on_dialin_ready(sip_endpoint)
|
||||||
|
|
||||||
def _on_dialout_connected(self, data):
|
def _on_dialout_connected(self, data):
|
||||||
self.on_dialout_connected(data)
|
self.on_dialout_connected(data)
|
||||||
@@ -836,6 +845,9 @@ class DailyTransport(BaseTransport):
|
|||||||
def on_call_state_updated(self, state):
|
def on_call_state_updated(self, state):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def on_dialin_ready(self, sip_endpoint):
|
||||||
|
pass
|
||||||
|
|
||||||
def on_dialout_connected(self, data):
|
def on_dialout_connected(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user