mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-10 08:05:22 +02:00
fix: call_id and stream_id for vobiz pipeline, add workflow run state (#78)
* fix: add workflow run state for pipeline * fix: call and stream id for vobiz pipeline
This commit is contained in:
parent
4640f69f9b
commit
c99bd29ef1
10 changed files with 139 additions and 14 deletions
|
|
@ -7,7 +7,7 @@ from loguru import logger
|
|||
|
||||
from api.db import db_client
|
||||
from api.db.models import QueuedRunModel, WorkflowRunModel
|
||||
from api.enums import OrganizationConfigurationKey
|
||||
from api.enums import OrganizationConfigurationKey, WorkflowRunState
|
||||
from api.services.campaign.rate_limiter import rate_limiter
|
||||
from api.services.telephony.base import TelephonyProvider
|
||||
from api.services.telephony.factory import get_telephony_provider
|
||||
|
|
@ -277,6 +277,7 @@ class CampaignCallDispatcher:
|
|||
await db_client.update_workflow_run(
|
||||
run_id=workflow_run.id,
|
||||
is_completed=True,
|
||||
state=WorkflowRunState.COMPLETED.value,
|
||||
gathered_context={
|
||||
"error": str(e),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from loguru import logger
|
||||
|
||||
from api.db import db_client
|
||||
from api.enums import WorkflowRunState
|
||||
from api.services.campaign.call_dispatcher import campaign_call_dispatcher
|
||||
from api.services.pipecat.audio_config import AudioConfig
|
||||
from api.services.pipecat.audio_transcript_buffers import (
|
||||
|
|
@ -176,6 +177,7 @@ def register_task_event_handler(
|
|||
usage_info=usage_info,
|
||||
gathered_context=gathered_context,
|
||||
is_completed=True,
|
||||
state=WorkflowRunState.COMPLETED.value,
|
||||
)
|
||||
|
||||
# Release concurrent slot for campaign calls
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from pipecat.audio.turn.smart_turn.local_smart_turn_v3 import LocalSmartTurnAnal
|
|||
from pipecat.audio.vad.silero import SileroVADAnalyzer, VADParams
|
||||
from pipecat.serializers.plivo import PlivoFrameSerializer
|
||||
from pipecat.serializers.twilio import TwilioFrameSerializer
|
||||
from pipecat.serializers.vobiz import VobizFrameSerializer
|
||||
from pipecat.serializers.vonage import VonageFrameSerializer
|
||||
from pipecat.transports.base_transport import TransportParams
|
||||
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
|
||||
|
|
@ -256,20 +257,20 @@ async def create_vobiz_transport(
|
|||
|
||||
turn_analyzer = create_turn_analyzer(workflow_run_id, audio_config)
|
||||
|
||||
# Use PlivoFrameSerializer for Vobiz (Plivo-compatible protocol)
|
||||
serializer = PlivoFrameSerializer(
|
||||
# Use VobizFrameSerializer for Vobiz WebSocket protocol
|
||||
serializer = VobizFrameSerializer(
|
||||
stream_id=stream_id,
|
||||
call_id=call_id,
|
||||
auth_id=auth_id,
|
||||
auth_token=auth_token,
|
||||
params=PlivoFrameSerializer.InputParams(
|
||||
plivo_sample_rate=8000, # Vobiz uses MULAW at 8kHz
|
||||
params=VobizFrameSerializer.InputParams(
|
||||
vobiz_sample_rate=8000, # Vobiz uses MULAW at 8kHz
|
||||
sample_rate=audio_config.pipeline_sample_rate,
|
||||
),
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"[run {workflow_run_id}] PlivoFrameSerializer created for Vobiz - "
|
||||
f"[run {workflow_run_id}] VobizFrameSerializer created for Vobiz - "
|
||||
f"transport_rate=8000Hz, pipeline_rate={audio_config.pipeline_sample_rate}Hz"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
Vobiz implementation of the TelephonyProvider interface.
|
||||
"""
|
||||
|
||||
import json
|
||||
import random
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
|
|
@ -292,16 +293,35 @@ class VobizProvider(TelephonyProvider):
|
|||
workflow_run_id: int,
|
||||
) -> None:
|
||||
"""
|
||||
Handle Vobiz WebSocket connection using Plivo-compatible protocol.
|
||||
Handle Vobiz WebSocket connection using Vobiz WebSocket protocol.
|
||||
|
||||
Uses workflow_run_id as stream/call identifiers and delegates
|
||||
message handling to PlivoFrameSerializer.
|
||||
Extracts stream_id and call_id from the start event and delegates
|
||||
message handling to VobizFrameSerializer.
|
||||
"""
|
||||
from api.services.pipecat.run_pipeline import run_pipeline_vobiz
|
||||
|
||||
first_msg = await websocket.receive_text()
|
||||
start_msg = json.loads(first_msg)
|
||||
logger.debug(f"Received the first message: {start_msg}")
|
||||
|
||||
# Validate that this is a start event
|
||||
if start_msg.get("event") != "start":
|
||||
logger.error(f"Expected 'start' event, got: {start_msg.get('event')}")
|
||||
await websocket.close(code=4400, reason="Expected start event")
|
||||
return
|
||||
|
||||
logger.debug(f"Vobiz WebSocket connected for workflow_run {workflow_run_id}")
|
||||
|
||||
try:
|
||||
stream_id = f"vobiz-stream-{workflow_run_id}"
|
||||
call_id = f"vobiz-call-{workflow_run_id}"
|
||||
# Extract stream_id and call_id from the start event
|
||||
start_data = start_msg.get("start", {})
|
||||
stream_id = start_data.get("streamId")
|
||||
call_id = start_data.get("callId")
|
||||
|
||||
if not stream_id or not call_id:
|
||||
logger.error(f"Missing streamId or callId in start event: {start_data}")
|
||||
await websocket.close(code=4400, reason="Missing streamId or callId")
|
||||
return
|
||||
|
||||
logger.info(
|
||||
f"[run {workflow_run_id}] Starting Vobiz WebSocket handler - "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue