From e6267e29fa2d6dbe4b3da3a1e00608924f9055d3 Mon Sep 17 00:00:00 2001 From: Sabiha Khan Date: Thu, 7 May 2026 09:58:17 +0530 Subject: [PATCH] fix: format issue in pre-pr drift check --- api/logging_config.py | 2 +- api/routes/agent_stream.py | 2 +- api/routes/telephony.py | 2 +- api/routes/webrtc_signaling.py | 4 +-- api/services/looptalk/audio_streamer.py | 1 - .../looptalk/core/pipeline_builder.py | 8 ++--- api/services/looptalk/internal_serializer.py | 1 - api/services/looptalk/internal_transport.py | 4 +-- api/services/looptalk/orchestrator.py | 4 +-- api/services/smart_turn/app.py | 3 +- .../smart_turn/websocket_smart_turn.py | 1 - .../telephony/providers/ari/strategies.py | 1 - .../telephony/providers/ari/transport.py | 8 ++--- .../telephony/providers/cloudonix/routes.py | 2 +- .../providers/cloudonix/strategies.py | 2 +- .../providers/cloudonix/transport.py | 8 ++--- .../telephony/providers/plivo/routes.py | 2 +- .../telephony/providers/plivo/transport.py | 8 ++--- .../telephony/providers/telnyx/provider.py | 4 +-- .../telephony/providers/telnyx/routes.py | 2 +- .../telephony/providers/telnyx/transport.py | 8 ++--- .../telephony/providers/twilio/routes.py | 2 +- .../telephony/providers/twilio/strategies.py | 1 - .../telephony/providers/twilio/transport.py | 8 ++--- .../telephony/providers/vobiz/routes.py | 2 +- .../telephony/providers/vobiz/transport.py | 8 ++--- .../telephony/providers/vonage/routes.py | 2 +- .../telephony/providers/vonage/transport.py | 7 ++-- api/services/workflow/pipecat_engine.py | 9 ++--- .../workflow/pipecat_engine_callbacks.py | 1 - .../pipecat_engine_context_summarizer.py | 4 +-- .../workflow/pipecat_engine_custom_tools.py | 14 ++++---- .../pipecat_engine_variable_extractor.py | 4 +-- api/services/workflow/qa/analysis.py | 2 +- api/services/workflow/qa/node_summary.py | 2 +- api/services/workflow/qa/tracing.py | 3 +- api/tasks/run_integrations.py | 4 +-- api/tasks/s3_upload.py | 2 +- .../integrations/_run_pipeline_helpers.py | 5 +-- api/tests/integrations/test_run_pipeline.py | 4 +-- .../test_run_pipeline_text_greeting.py | 8 ++--- api/tests/test_custom_tools.py | 15 ++++---- .../test_custom_tools_context_integration.py | 6 ++-- .../test_pipecat_engine_context_update.py | 20 +++++------ api/tests/test_pipecat_engine_end_call.py | 34 +++++++++---------- ...cat_engine_node_switch_with_user_speech.py | 8 ++--- api/tests/test_pipecat_engine_tool_calls.py | 10 +++--- .../test_pipecat_engine_transition_mute.py | 14 ++++---- ...test_pipecat_engine_variable_extraction.py | 14 ++++---- api/tests/test_pipeline_cancellation.py | 1 - api/tests/test_recording_router_processor.py | 16 ++++----- api/tests/test_text_and_audio_playback.py | 32 ++++++++--------- ...t_tts_endframe_with_audio_write_failure.py | 14 ++++---- api/tests/test_unregistered_function_call.py | 2 +- api/tests/test_user_idle_handler.py | 8 ++--- .../test_user_muting_during_bot_speech.py | 14 ++++---- api/tests/test_voicemail_detector.py | 4 +-- 57 files changed, 187 insertions(+), 194 deletions(-) diff --git a/api/logging_config.py b/api/logging_config.py index bd4649f..3e4f443 100644 --- a/api/logging_config.py +++ b/api/logging_config.py @@ -3,6 +3,7 @@ import os import sys import loguru +from pipecat.utils.run_context import run_id_var from api.constants import ( ENVIRONMENT, @@ -15,7 +16,6 @@ from api.constants import ( ) from api.enums import Environment from api.utils.worker import get_worker_id, is_worker_process -from pipecat.utils.run_context import run_id_var # Track if logging has been initialized _logging_initialized = False diff --git a/api/routes/agent_stream.py b/api/routes/agent_stream.py index 2debe7a..b593a31 100644 --- a/api/routes/agent_stream.py +++ b/api/routes/agent_stream.py @@ -17,13 +17,13 @@ from typing import Optional from fastapi import APIRouter, WebSocket from loguru import logger +from pipecat.utils.run_context import set_current_org_id, set_current_run_id from starlette.websockets import WebSocketDisconnect from api.db import db_client from api.enums import CallType, WorkflowRunState from api.services.quota_service import check_dograh_quota_by_user_id from api.services.telephony import registry as telephony_registry -from pipecat.utils.run_context import set_current_org_id, set_current_run_id router = APIRouter(prefix="/agent-stream") diff --git a/api/routes/telephony.py b/api/routes/telephony.py index b21ce05..3b14406 100644 --- a/api/routes/telephony.py +++ b/api/routes/telephony.py @@ -15,6 +15,7 @@ from fastapi import ( WebSocket, ) from loguru import logger +from pipecat.utils.run_context import set_current_run_id from pydantic import BaseModel from starlette.websockets import WebSocketDisconnect @@ -43,7 +44,6 @@ from api.utils.telephony_helper import ( numbers_match, parse_webhook_request, ) -from pipecat.utils.run_context import set_current_run_id router = APIRouter(prefix="/telephony") diff --git a/api/routes/webrtc_signaling.py b/api/routes/webrtc_signaling.py index 04eee4b..4246b0b 100644 --- a/api/routes/webrtc_signaling.py +++ b/api/routes/webrtc_signaling.py @@ -24,6 +24,8 @@ from aiortc import RTCIceServer from aiortc.sdp import candidate_from_sdp from fastapi import APIRouter, Depends, HTTPException, WebSocket, WebSocketDisconnect from loguru import logger +from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection +from pipecat.utils.run_context import set_current_org_id, set_current_run_id from starlette.websockets import WebSocketState from api.constants import ENVIRONMENT @@ -43,8 +45,6 @@ from api.services.pipecat.ws_sender_registry import ( unregister_ws_sender, ) from api.services.quota_service import check_dograh_quota -from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection -from pipecat.utils.run_context import set_current_org_id, set_current_run_id router = APIRouter(prefix="/ws") diff --git a/api/services/looptalk/audio_streamer.py b/api/services/looptalk/audio_streamer.py index 8221c4d..0acdb22 100644 --- a/api/services/looptalk/audio_streamer.py +++ b/api/services/looptalk/audio_streamer.py @@ -9,7 +9,6 @@ import asyncio from typing import Dict, Set from loguru import logger - from pipecat.audio.utils import mix_audio from pipecat.frames.frames import ( Frame, diff --git a/api/services/looptalk/core/pipeline_builder.py b/api/services/looptalk/core/pipeline_builder.py index ee11613..77e634f 100644 --- a/api/services/looptalk/core/pipeline_builder.py +++ b/api/services/looptalk/core/pipeline_builder.py @@ -3,6 +3,10 @@ from typing import Any, Dict from loguru import logger +from pipecat.pipeline.pipeline import Pipeline +from pipecat.processors.aggregators.llm_response_universal import ( + LLMContextAggregatorPair, +) from api.db.db_client import DBClient from api.services.looptalk.audio_streamer import get_or_create_audio_streamer @@ -23,10 +27,6 @@ from api.services.pipecat.service_factory import ( from api.services.workflow.dto import ReactFlowDTO from api.services.workflow.pipecat_engine import PipecatEngine from api.services.workflow.workflow import WorkflowGraph -from pipecat.pipeline.pipeline import Pipeline -from pipecat.processors.aggregators.llm_response_universal import ( - LLMContextAggregatorPair, -) class LoopTalkPipelineBuilder: diff --git a/api/services/looptalk/internal_serializer.py b/api/services/looptalk/internal_serializer.py index 75d89ea..6a94a40 100644 --- a/api/services/looptalk/internal_serializer.py +++ b/api/services/looptalk/internal_serializer.py @@ -7,7 +7,6 @@ """Internal frame serializer for agent-to-agent communication.""" from loguru import logger - from pipecat.frames.frames import ( Frame, InputAudioRawFrame, diff --git a/api/services/looptalk/internal_transport.py b/api/services/looptalk/internal_transport.py index 756b499..00bfc93 100644 --- a/api/services/looptalk/internal_transport.py +++ b/api/services/looptalk/internal_transport.py @@ -11,8 +11,6 @@ import time from typing import Dict, Optional, Tuple from loguru import logger - -from api.services.looptalk.internal_serializer import InternalFrameSerializer from pipecat.frames.frames import ( CancelFrame, EndFrame, @@ -29,6 +27,8 @@ from pipecat.transports.base_input import BaseInputTransport from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams +from api.services.looptalk.internal_serializer import InternalFrameSerializer + class InternalInputTransport(BaseInputTransport): """Input side of internal transport for agent-to-agent communication.""" diff --git a/api/services/looptalk/orchestrator.py b/api/services/looptalk/orchestrator.py index d4c969a..d51e9da 100644 --- a/api/services/looptalk/orchestrator.py +++ b/api/services/looptalk/orchestrator.py @@ -6,6 +6,8 @@ from pathlib import Path from typing import Any, Dict, Optional from loguru import logger +from pipecat.pipeline.task import PipelineTask +from pipecat.utils.run_context import set_current_run_id from api.db.db_client import DBClient from api.services.looptalk.internal_transport import ( @@ -13,8 +15,6 @@ from api.services.looptalk.internal_transport import ( InternalTransportManager, ) from api.services.pipecat.transport_setup import create_internal_transport -from pipecat.pipeline.task import PipelineTask -from pipecat.utils.run_context import set_current_run_id from .core.pipeline_builder import LoopTalkPipelineBuilder from .core.recording_manager import RecordingManager diff --git a/api/services/smart_turn/app.py b/api/services/smart_turn/app.py index 66ccf5a..6bbd0ab 100644 --- a/api/services/smart_turn/app.py +++ b/api/services/smart_turn/app.py @@ -21,9 +21,8 @@ from fastapi import ( status, ) from fastapi.websockets import WebSocketState -from scipy.io import wavfile - from pipecat.audio.turn.smart_turn.local_smart_turn_v2 import LocalSmartTurnAnalyzerV2 +from scipy.io import wavfile LOG_LEVEL = ( logging.DEBUG diff --git a/api/services/smart_turn/websocket_smart_turn.py b/api/services/smart_turn/websocket_smart_turn.py index 4220d3c..82a7e6f 100644 --- a/api/services/smart_turn/websocket_smart_turn.py +++ b/api/services/smart_turn/websocket_smart_turn.py @@ -20,7 +20,6 @@ from typing import Any, Dict, Optional import numpy as np import websockets from loguru import logger - from pipecat.audio.turn.smart_turn.base_smart_turn import ( BaseSmartTurn, SmartTurnTimeoutException, diff --git a/api/services/telephony/providers/ari/strategies.py b/api/services/telephony/providers/ari/strategies.py index 4e02c8e..288110f 100644 --- a/api/services/telephony/providers/ari/strategies.py +++ b/api/services/telephony/providers/ari/strategies.py @@ -6,7 +6,6 @@ This module contains the business logic for Asterisk ARI call operations. from typing import Any, Dict from loguru import logger - from pipecat.serializers.call_strategies import HangupStrategy, TransferStrategy diff --git a/api/services/telephony/providers/ari/transport.py b/api/services/telephony/providers/ari/transport.py index 3f9ceb2..58efea5 100644 --- a/api/services/telephony/providers/ari/transport.py +++ b/api/services/telephony/providers/ari/transport.py @@ -1,15 +1,15 @@ """ARI (Asterisk) transport factory.""" from fastapi import WebSocket - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import AsteriskFrameSerializer from .strategies import ARIBridgeSwapStrategy, ARIHangupStrategy diff --git a/api/services/telephony/providers/cloudonix/routes.py b/api/services/telephony/providers/cloudonix/routes.py index 6f39831..cd4758a 100644 --- a/api/services/telephony/providers/cloudonix/routes.py +++ b/api/services/telephony/providers/cloudonix/routes.py @@ -8,6 +8,7 @@ import json from fastapi import APIRouter, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from api.db import db_client from api.services.telephony.factory import get_telephony_provider_for_run @@ -15,7 +16,6 @@ from api.services.telephony.status_processor import ( StatusCallbackRequest, _process_status_update, ) -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/cloudonix/strategies.py b/api/services/telephony/providers/cloudonix/strategies.py index 1fa4fad..b64cf6d 100644 --- a/api/services/telephony/providers/cloudonix/strategies.py +++ b/api/services/telephony/providers/cloudonix/strategies.py @@ -3,9 +3,9 @@ from typing import Any, Dict from loguru import logger +from pipecat.serializers.call_strategies import HangupStrategy from api.services.telephony.providers.cloudonix.provider import CLOUDONIX_API_BASE_URL -from pipecat.serializers.call_strategies import HangupStrategy class CloudonixHangupStrategy(HangupStrategy): diff --git a/api/services/telephony/providers/cloudonix/transport.py b/api/services/telephony/providers/cloudonix/transport.py index 33d58ef..cd91518 100644 --- a/api/services/telephony/providers/cloudonix/transport.py +++ b/api/services/telephony/providers/cloudonix/transport.py @@ -1,15 +1,15 @@ """Cloudonix transport factory.""" from fastapi import WebSocket - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import CloudonixFrameSerializer from .strategies import CloudonixHangupStrategy diff --git a/api/services/telephony/providers/plivo/routes.py b/api/services/telephony/providers/plivo/routes.py index 6fad8c3..be1ecd7 100644 --- a/api/services/telephony/providers/plivo/routes.py +++ b/api/services/telephony/providers/plivo/routes.py @@ -9,6 +9,7 @@ from typing import Optional from fastapi import APIRouter, Header, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from starlette.responses import HTMLResponse from api.db import db_client @@ -18,7 +19,6 @@ from api.services.telephony.status_processor import ( _process_status_update, ) from api.utils.common import get_backend_endpoints -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/plivo/transport.py b/api/services/telephony/providers/plivo/transport.py index ce60f42..039c562 100644 --- a/api/services/telephony/providers/plivo/transport.py +++ b/api/services/telephony/providers/plivo/transport.py @@ -1,15 +1,15 @@ """Plivo transport factory.""" from fastapi import WebSocket - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import PlivoFrameSerializer diff --git a/api/services/telephony/providers/telnyx/provider.py b/api/services/telephony/providers/telnyx/provider.py index 72e87d7..d127dfa 100644 --- a/api/services/telephony/providers/telnyx/provider.py +++ b/api/services/telephony/providers/telnyx/provider.py @@ -9,7 +9,7 @@ import random from typing import TYPE_CHECKING, Any, Dict, List, Optional import aiohttp -from fastapi import HTTPException +from fastapi import HTTPException, WebSocketDisconnect from loguru import logger from api.enums import WorkflowRunMode @@ -22,8 +22,6 @@ from api.services.telephony.base import ( from api.utils.common import get_backend_endpoints from api.utils.telephony_address import normalize_telephony_address -from fastapi import WebSocketDisconnect - if TYPE_CHECKING: from fastapi import WebSocket diff --git a/api/services/telephony/providers/telnyx/routes.py b/api/services/telephony/providers/telnyx/routes.py index 23df07e..0947b14 100644 --- a/api/services/telephony/providers/telnyx/routes.py +++ b/api/services/telephony/providers/telnyx/routes.py @@ -8,6 +8,7 @@ import json from fastapi import APIRouter, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from api.db import db_client from api.services.telephony.factory import get_telephony_provider_for_run @@ -16,7 +17,6 @@ from api.services.telephony.status_processor import ( StatusCallbackRequest, _process_status_update, ) -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/telnyx/transport.py b/api/services/telephony/providers/telnyx/transport.py index bdb3f47..c2b96f4 100644 --- a/api/services/telephony/providers/telnyx/transport.py +++ b/api/services/telephony/providers/telnyx/transport.py @@ -1,15 +1,15 @@ """Telnyx transport factory.""" from fastapi import WebSocket - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import TelnyxFrameSerializer diff --git a/api/services/telephony/providers/twilio/routes.py b/api/services/telephony/providers/twilio/routes.py index 11fca1b..e8ac939 100644 --- a/api/services/telephony/providers/twilio/routes.py +++ b/api/services/telephony/providers/twilio/routes.py @@ -9,6 +9,7 @@ from typing import Optional from fastapi import APIRouter, Header, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from starlette.responses import HTMLResponse from api.db import db_client @@ -18,7 +19,6 @@ from api.services.telephony.status_processor import ( _process_status_update, ) from api.utils.common import get_backend_endpoints -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/twilio/strategies.py b/api/services/telephony/providers/twilio/strategies.py index 003eb33..e80e1a6 100644 --- a/api/services/telephony/providers/twilio/strategies.py +++ b/api/services/telephony/providers/twilio/strategies.py @@ -8,7 +8,6 @@ from typing import Any, Dict import aiohttp from loguru import logger - from pipecat.serializers.call_strategies import HangupStrategy, TransferStrategy diff --git a/api/services/telephony/providers/twilio/transport.py b/api/services/telephony/providers/twilio/transport.py index 823e05c..d3a4937 100644 --- a/api/services/telephony/providers/twilio/transport.py +++ b/api/services/telephony/providers/twilio/transport.py @@ -1,15 +1,15 @@ """Twilio transport factory.""" from fastapi import WebSocket - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import TwilioFrameSerializer from .strategies import TwilioConferenceStrategy, TwilioHangupStrategy diff --git a/api/services/telephony/providers/vobiz/routes.py b/api/services/telephony/providers/vobiz/routes.py index d39946c..4fffe5b 100644 --- a/api/services/telephony/providers/vobiz/routes.py +++ b/api/services/telephony/providers/vobiz/routes.py @@ -10,6 +10,7 @@ from typing import Optional from fastapi import APIRouter, Header, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from starlette.responses import HTMLResponse from api.db import db_client @@ -24,7 +25,6 @@ from api.utils.common import get_backend_endpoints from api.utils.telephony_helper import ( parse_webhook_request, ) -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/vobiz/transport.py b/api/services/telephony/providers/vobiz/transport.py index 1a4b781..46ac392 100644 --- a/api/services/telephony/providers/vobiz/transport.py +++ b/api/services/telephony/providers/vobiz/transport.py @@ -7,15 +7,15 @@ Vobiz uses Plivo-compatible WebSocket protocol: from fastapi import WebSocket from loguru import logger - -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import VobizFrameSerializer diff --git a/api/services/telephony/providers/vonage/routes.py b/api/services/telephony/providers/vonage/routes.py index dff1bba..a4cca35 100644 --- a/api/services/telephony/providers/vonage/routes.py +++ b/api/services/telephony/providers/vonage/routes.py @@ -9,6 +9,7 @@ from typing import Optional from fastapi import APIRouter, Request from loguru import logger +from pipecat.utils.run_context import set_current_run_id from api.db import db_client from api.services.telephony.factory import get_telephony_provider_for_run @@ -16,7 +17,6 @@ from api.services.telephony.status_processor import ( StatusCallbackRequest, _process_status_update, ) -from pipecat.utils.run_context import set_current_run_id router = APIRouter() diff --git a/api/services/telephony/providers/vonage/transport.py b/api/services/telephony/providers/vonage/transport.py index 7183702..0fae27f 100644 --- a/api/services/telephony/providers/vonage/transport.py +++ b/api/services/telephony/providers/vonage/transport.py @@ -1,13 +1,14 @@ """Vonage transport factory.""" -from api.services.pipecat.audio_config import AudioConfig -from api.services.pipecat.audio_mixer import build_audio_out_mixer -from api.services.telephony.factory import load_credentials_for_transport from pipecat.transports.websocket.fastapi import ( FastAPIWebsocketParams, FastAPIWebsocketTransport, ) +from api.services.pipecat.audio_config import AudioConfig +from api.services.pipecat.audio_mixer import build_audio_out_mixer +from api.services.telephony.factory import load_credentials_for_transport + from .serializers import VonageFrameSerializer diff --git a/api/services/workflow/pipecat_engine.py b/api/services/workflow/pipecat_engine.py index fc84595..b4f00cb 100644 --- a/api/services/workflow/pipecat_engine.py +++ b/api/services/workflow/pipecat_engine.py @@ -1,9 +1,5 @@ from typing import TYPE_CHECKING, Awaitable, Callable, Optional, Union -from api.db import db_client -from api.services.pipecat.audio_playback import play_audio -from api.services.workflow.disposition_mapper import apply_disposition_mapping -from api.services.workflow.workflow import Node, WorkflowGraph from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.frames.frames import ( BotStartedSpeakingFrame, @@ -19,6 +15,11 @@ from pipecat.services.llm_service import FunctionCallParams from pipecat.services.settings import LLMSettings from pipecat.utils.enums import EndTaskReason +from api.db import db_client +from api.services.pipecat.audio_playback import play_audio +from api.services.workflow.disposition_mapper import apply_disposition_mapping +from api.services.workflow.workflow import Node, WorkflowGraph + if TYPE_CHECKING: from pipecat.frames.frames import Frame from pipecat.services.anthropic.llm import AnthropicLLMService diff --git a/api/services/workflow/pipecat_engine_callbacks.py b/api/services/workflow/pipecat_engine_callbacks.py index 83990bf..87ff06e 100644 --- a/api/services/workflow/pipecat_engine_callbacks.py +++ b/api/services/workflow/pipecat_engine_callbacks.py @@ -14,7 +14,6 @@ import re from typing import TYPE_CHECKING from loguru import logger - from pipecat.frames.frames import ( LLMMessagesAppendFrame, ) diff --git a/api/services/workflow/pipecat_engine_context_summarizer.py b/api/services/workflow/pipecat_engine_context_summarizer.py index 1ea9f47..abfa7b2 100644 --- a/api/services/workflow/pipecat_engine_context_summarizer.py +++ b/api/services/workflow/pipecat_engine_context_summarizer.py @@ -6,8 +6,6 @@ from typing import TYPE_CHECKING, Optional from loguru import logger from opentelemetry import trace - -from api.services.pipecat.tracing_config import ensure_tracing from pipecat.frames.frames import LLMContextSummaryRequestFrame from pipecat.utils.context.llm_context_summarization import ( LLMContextSummarizationUtil, @@ -15,6 +13,8 @@ from pipecat.utils.context.llm_context_summarization import ( ) from pipecat.utils.tracing.service_attributes import add_llm_span_attributes +from api.services.pipecat.tracing_config import ensure_tracing + if TYPE_CHECKING: from api.services.workflow.pipecat_engine import PipecatEngine diff --git a/api/services/workflow/pipecat_engine_custom_tools.py b/api/services/workflow/pipecat_engine_custom_tools.py index 91922b8..f4b5a2b 100644 --- a/api/services/workflow/pipecat_engine_custom_tools.py +++ b/api/services/workflow/pipecat_engine_custom_tools.py @@ -13,6 +13,13 @@ import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional from loguru import logger +from pipecat.adapters.schemas.function_schema import FunctionSchema +from pipecat.frames.frames import ( + FunctionCallResultProperties, + TTSSpeakFrame, +) +from pipecat.services.llm_service import FunctionCallParams +from pipecat.utils.enums import EndTaskReason from api.db import db_client from api.enums import ToolCategory, WorkflowRunMode @@ -25,13 +32,6 @@ from api.services.workflow.tools.custom_tool import ( execute_http_tool, tool_to_function_schema, ) -from pipecat.adapters.schemas.function_schema import FunctionSchema -from pipecat.frames.frames import ( - FunctionCallResultProperties, - TTSSpeakFrame, -) -from pipecat.services.llm_service import FunctionCallParams -from pipecat.utils.enums import EndTaskReason if TYPE_CHECKING: from api.services.workflow.pipecat_engine import PipecatEngine diff --git a/api/services/workflow/pipecat_engine_variable_extractor.py b/api/services/workflow/pipecat_engine_variable_extractor.py index 53996cd..2853403 100644 --- a/api/services/workflow/pipecat_engine_variable_extractor.py +++ b/api/services/workflow/pipecat_engine_variable_extractor.py @@ -5,12 +5,12 @@ from typing import TYPE_CHECKING, Any, List from loguru import logger from opentelemetry import trace +from pipecat.processors.aggregators.llm_context import LLMContext +from pipecat.utils.tracing.service_attributes import add_llm_span_attributes from api.services.gen_ai.json_parser import parse_llm_json from api.services.pipecat.tracing_config import ensure_tracing from api.services.workflow.dto import ExtractionVariableDTO -from pipecat.processors.aggregators.llm_context import LLMContext -from pipecat.utils.tracing.service_attributes import add_llm_span_attributes if TYPE_CHECKING: from api.services.workflow.pipecat_engine import PipecatEngine diff --git a/api/services/workflow/qa/analysis.py b/api/services/workflow/qa/analysis.py index b0a171e..0afb2e1 100644 --- a/api/services/workflow/qa/analysis.py +++ b/api/services/workflow/qa/analysis.py @@ -4,6 +4,7 @@ import json from typing import Any from loguru import logger +from pipecat.processors.aggregators.llm_context import LLMContext from api.db.models import WorkflowRunModel from api.services.gen_ai.json_parser import parse_llm_json @@ -26,7 +27,6 @@ from api.services.workflow.qa.tracing import ( setup_langfuse_parent_context, ) from api.utils.template_renderer import render_template -from pipecat.processors.aggregators.llm_context import LLMContext async def _run_llm_inference( diff --git a/api/services/workflow/qa/node_summary.py b/api/services/workflow/qa/node_summary.py index 5896f4c..aaeb7d3 100644 --- a/api/services/workflow/qa/node_summary.py +++ b/api/services/workflow/qa/node_summary.py @@ -3,6 +3,7 @@ from typing import Any from loguru import logger +from pipecat.processors.aggregators.llm_context import LLMContext from api.db import db_client from api.db.models import WorkflowRunModel @@ -10,7 +11,6 @@ from api.services.pipecat.service_factory import create_llm_service_from_provide from api.services.workflow.dto import NodeType, QANodeData from api.services.workflow.qa.llm_config import resolve_llm_config from api.services.workflow.qa.tracing import create_node_summary_trace -from pipecat.processors.aggregators.llm_context import LLMContext NODE_SUMMARY_SYSTEM_PROMPT = ( "You are analyzing a voice AI agent script. This is only a part of a larger script. " diff --git a/api/services/workflow/qa/tracing.py b/api/services/workflow/qa/tracing.py index d3a5ff1..58a0843 100644 --- a/api/services/workflow/qa/tracing.py +++ b/api/services/workflow/qa/tracing.py @@ -78,7 +78,6 @@ def add_qa_span_to_trace( return try: from opentelemetry import trace as otel_trace - from pipecat.utils.tracing.service_attributes import add_llm_span_attributes tracer = otel_trace.get_tracer("pipecat") @@ -122,9 +121,9 @@ def create_node_summary_trace( try: from opentelemetry import trace as otel_trace from opentelemetry.context import Context + from pipecat.utils.tracing.service_attributes import add_llm_span_attributes from api.services.pipecat.tracing_config import ensure_tracing - from pipecat.utils.tracing.service_attributes import add_llm_span_attributes if not ensure_tracing(): return None diff --git a/api/tasks/run_integrations.py b/api/tasks/run_integrations.py index da87413..d73a39b 100644 --- a/api/tasks/run_integrations.py +++ b/api/tasks/run_integrations.py @@ -5,6 +5,8 @@ from typing import Any, Dict, Optional import httpx from loguru import logger +from pipecat.utils.enums import EndTaskReason +from pipecat.utils.run_context import set_current_org_id, set_current_run_id from pydantic import ValidationError from api.constants import BACKEND_API_ENDPOINT @@ -21,8 +23,6 @@ from api.services.workflow.dto import ( from api.services.workflow.qa import run_per_node_qa_analysis from api.utils.credential_auth import build_auth_header from api.utils.template_renderer import render_template -from pipecat.utils.enums import EndTaskReason -from pipecat.utils.run_context import set_current_org_id, set_current_run_id def _should_skip_qa( diff --git a/api/tasks/s3_upload.py b/api/tasks/s3_upload.py index c18a9b3..b2086c0 100644 --- a/api/tasks/s3_upload.py +++ b/api/tasks/s3_upload.py @@ -2,12 +2,12 @@ import os from typing import Optional from loguru import logger +from pipecat.utils.run_context import set_current_run_id from api.db import db_client from api.services.pricing.workflow_run_cost import calculate_workflow_run_cost from api.services.storage import get_current_storage_backend, storage_fs from api.tasks.run_integrations import run_integrations_post_workflow_run -from pipecat.utils.run_context import set_current_run_id async def upload_voicemail_audio_to_s3( diff --git a/api/tests/integrations/_run_pipeline_helpers.py b/api/tests/integrations/_run_pipeline_helpers.py index cacbf50..0591c09 100644 --- a/api/tests/integrations/_run_pipeline_helpers.py +++ b/api/tests/integrations/_run_pipeline_helpers.py @@ -29,11 +29,12 @@ from contextlib import ExitStack, contextmanager from typing import Any from unittest.mock import AsyncMock, patch -from api.db.models import OrganizationModel, UserModel -from api.enums import WorkflowRunMode from pipecat.frames.frames import Frame from pipecat.observers.base_observer import BaseObserver from pipecat.processors.frame_processor import FrameDirection, FrameProcessor + +from api.db.models import OrganizationModel, UserModel +from api.enums import WorkflowRunMode from pipecat.tests import MockLLMService, MockTTSService USER_CONFIGURATION: dict[str, Any] = { diff --git a/api/tests/integrations/test_run_pipeline.py b/api/tests/integrations/test_run_pipeline.py index 8a8da88..9a87aa1 100644 --- a/api/tests/integrations/test_run_pipeline.py +++ b/api/tests/integrations/test_run_pipeline.py @@ -17,6 +17,8 @@ completion flag, and ``gathered_context`` entries. import asyncio import pytest +from pipecat.tests.mock_transport import MockTransport +from pipecat.transports.base_transport import TransportParams from api.enums import WorkflowRunMode, WorkflowRunState from api.services.pipecat.audio_config import create_audio_config @@ -25,8 +27,6 @@ from api.tests.integrations._run_pipeline_helpers import ( create_workflow_run_rows, patch_run_pipeline_externals, ) -from pipecat.tests.mock_transport import MockTransport -from pipecat.transports.base_transport import TransportParams WORKFLOW_DEFINITION = { "nodes": [ diff --git a/api/tests/integrations/test_run_pipeline_text_greeting.py b/api/tests/integrations/test_run_pipeline_text_greeting.py index 5003515..0da7bf8 100644 --- a/api/tests/integrations/test_run_pipeline_text_greeting.py +++ b/api/tests/integrations/test_run_pipeline_text_greeting.py @@ -28,6 +28,10 @@ deterministic and the synthesised audio length is short. import asyncio import pytest +from pipecat.frames.frames import TranscriptionFrame +from pipecat.tests.mock_transport import MockTransport +from pipecat.transports.base_transport import TransportParams +from pipecat.utils.time import time_now_iso8601 from api.enums import WorkflowRunMode, WorkflowRunState from api.services.pipecat.audio_config import create_audio_config @@ -36,11 +40,7 @@ from api.tests.integrations._run_pipeline_helpers import ( create_workflow_run_rows, patch_run_pipeline_externals, ) -from pipecat.frames.frames import TranscriptionFrame from pipecat.tests import MockLLMService, MockTTSService -from pipecat.tests.mock_transport import MockTransport -from pipecat.transports.base_transport import TransportParams -from pipecat.utils.time import time_now_iso8601 GREETING_TEXT = ( "Thanks for calling Happy Feet, this is Sarah. How can I help you today?" diff --git a/api/tests/test_custom_tools.py b/api/tests/test_custom_tools.py index b534902..693afc7 100644 --- a/api/tests/test_custom_tools.py +++ b/api/tests/test_custom_tools.py @@ -12,12 +12,6 @@ from typing import Any, Dict from unittest.mock import AsyncMock, Mock, patch import pytest - -from api.services.workflow.pipecat_engine_custom_tools import get_function_schema -from api.services.workflow.tools.custom_tool import ( - execute_http_tool, - tool_to_function_schema, -) from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.frames.frames import ( FunctionCallInProgressFrame, @@ -31,6 +25,12 @@ from pipecat.frames.frames import ( from pipecat.pipeline.pipeline import Pipeline from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.services.llm_service import FunctionCallParams + +from api.services.workflow.pipecat_engine_custom_tools import get_function_schema +from api.services.workflow.tools.custom_tool import ( + execute_http_tool, + tool_to_function_schema, +) from pipecat.tests import MockLLMService, run_test @@ -721,9 +721,10 @@ class TestCustomToolManagerUnit: async def test_get_tool_schemas_returns_correct_format(self): """Test that get_tool_schemas returns FunctionSchema objects.""" # Create a mock engine + from pipecat.adapters.schemas.function_schema import FunctionSchema + from api.services.workflow.pipecat_engine import PipecatEngine from api.services.workflow.pipecat_engine_custom_tools import CustomToolManager - from pipecat.adapters.schemas.function_schema import FunctionSchema mock_engine = Mock() mock_engine._workflow_run_id = 1 diff --git a/api/tests/test_custom_tools_context_integration.py b/api/tests/test_custom_tools_context_integration.py index 8e6ddb5..db060fb 100644 --- a/api/tests/test_custom_tools_context_integration.py +++ b/api/tests/test_custom_tools_context_integration.py @@ -9,15 +9,15 @@ This module tests the full flow of: from unittest.mock import AsyncMock, patch import pytest +from pipecat.adapters.schemas.function_schema import FunctionSchema +from pipecat.adapters.schemas.tools_schema import ToolsSchema +from pipecat.processors.aggregators.llm_context import LLMContext from api.services.workflow.pipecat_engine_custom_tools import ( CustomToolManager, get_function_schema, ) from api.tests.conftest import MockToolModel -from pipecat.adapters.schemas.function_schema import FunctionSchema -from pipecat.adapters.schemas.tools_schema import ToolsSchema -from pipecat.processors.aggregators.llm_context import LLMContext def _update_llm_context(context, system_message, functions): diff --git a/api/tests/test_pipecat_engine_context_update.py b/api/tests/test_pipecat_engine_context_update.py index 34d3138..e22a575 100644 --- a/api/tests/test_pipecat_engine_context_update.py +++ b/api/tests/test_pipecat_engine_context_update.py @@ -18,14 +18,6 @@ from typing import List from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.workflow import WorkflowGraph -from api.tests.conftest import ( - AGENT_SYSTEM_PROMPT, - END_CALL_SYSTEM_PROMPT, - START_CALL_SYSTEM_PROMPT, -) from pipecat.frames.frames import LLMContextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -35,13 +27,21 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMAssistantAggregatorParams, LLMContextAggregatorPair, ) +from pipecat.tests.mock_transport import MockTransport +from pipecat.transports.base_transport import TransportParams + +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.workflow import WorkflowGraph +from api.tests.conftest import ( + AGENT_SYSTEM_PROMPT, + END_CALL_SYSTEM_PROMPT, + START_CALL_SYSTEM_PROMPT, +) from pipecat.tests import ( ContextCapturingMockLLM, MockLLMService, MockTTSService, ) -from pipecat.tests.mock_transport import MockTransport -from pipecat.transports.base_transport import TransportParams async def run_pipeline_and_capture_context( diff --git a/api/tests/test_pipecat_engine_end_call.py b/api/tests/test_pipecat_engine_end_call.py index e1ff101..a0f8ac1 100644 --- a/api/tests/test_pipecat_engine_end_call.py +++ b/api/tests/test_pipecat_engine_end_call.py @@ -23,6 +23,23 @@ from typing import Any, Dict, List from unittest.mock import AsyncMock, patch import pytest +from pipecat.frames.frames import Frame, LLMContextFrame +from pipecat.pipeline.pipeline import Pipeline +from pipecat.pipeline.runner import PipelineRunner +from pipecat.pipeline.task import PipelineParams, PipelineTask +from pipecat.processors.aggregators.llm_context import LLMContext +from pipecat.processors.aggregators.llm_response_universal import ( + LLMAssistantAggregatorParams, + LLMContextAggregatorPair, + LLMUserAggregatorParams, +) +from pipecat.tests.mock_transport import MockTransport +from pipecat.transports.base_transport import TransportParams +from pipecat.turns.user_mute import ( + CallbackUserMuteStrategy, + MuteUntilFirstBotCompleteUserMuteStrategy, +) +from pipecat.utils.enums import EndTaskReason from api.enums import ToolCategory from api.services.workflow.dto import ( @@ -42,24 +59,7 @@ from api.services.workflow.pipecat_engine_variable_extractor import ( ) from api.services.workflow.workflow import WorkflowGraph from api.tests.conftest import END_CALL_SYSTEM_PROMPT, START_CALL_SYSTEM_PROMPT -from pipecat.frames.frames import Frame, LLMContextFrame -from pipecat.pipeline.pipeline import Pipeline -from pipecat.pipeline.runner import PipelineRunner -from pipecat.pipeline.task import PipelineParams, PipelineTask -from pipecat.processors.aggregators.llm_context import LLMContext -from pipecat.processors.aggregators.llm_response_universal import ( - LLMAssistantAggregatorParams, - LLMContextAggregatorPair, - LLMUserAggregatorParams, -) from pipecat.tests import MockLLMService, MockTTSService -from pipecat.tests.mock_transport import MockTransport -from pipecat.transports.base_transport import TransportParams -from pipecat.turns.user_mute import ( - CallbackUserMuteStrategy, - MuteUntilFirstBotCompleteUserMuteStrategy, -) -from pipecat.utils.enums import EndTaskReason class EndCallTestHelper: diff --git a/api/tests/test_pipecat_engine_node_switch_with_user_speech.py b/api/tests/test_pipecat_engine_node_switch_with_user_speech.py index 5e29b4f..a19843b 100644 --- a/api/tests/test_pipecat_engine_node_switch_with_user_speech.py +++ b/api/tests/test_pipecat_engine_node_switch_with_user_speech.py @@ -15,9 +15,6 @@ import asyncio from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import ( Frame, FunctionCallResultFrame, @@ -36,7 +33,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams from pipecat.turns.user_mute import ( @@ -52,6 +48,10 @@ from pipecat.turns.user_stop import ( from pipecat.turns.user_turn_strategies import UserTurnStrategies from pipecat.utils.time import time_now_iso8601 +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + class UserSpeechInjector(FrameProcessor): """Processor that injects user speaking frames on FunctionCallResultFrame. diff --git a/api/tests/test_pipecat_engine_tool_calls.py b/api/tests/test_pipecat_engine_tool_calls.py index 07d73a3..aef2df6 100644 --- a/api/tests/test_pipecat_engine_tool_calls.py +++ b/api/tests/test_pipecat_engine_tool_calls.py @@ -9,10 +9,6 @@ from typing import Any, Dict, List from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.workflow import WorkflowGraph -from api.tests.conftest import END_CALL_SYSTEM_PROMPT from pipecat.frames.frames import LLMContextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -22,10 +18,14 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMAssistantAggregatorParams, LLMContextAggregatorPair, ) -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.workflow import WorkflowGraph +from api.tests.conftest import END_CALL_SYSTEM_PROMPT +from pipecat.tests import MockLLMService, MockTTSService + async def run_pipeline_with_tool_calls( workflow: WorkflowGraph, diff --git a/api/tests/test_pipecat_engine_transition_mute.py b/api/tests/test_pipecat_engine_transition_mute.py index 844612e..3cc5220 100644 --- a/api/tests/test_pipecat_engine_transition_mute.py +++ b/api/tests/test_pipecat_engine_transition_mute.py @@ -13,12 +13,6 @@ import asyncio from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.pipecat_engine_variable_extractor import ( - VariableExtractionManager, -) -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import LLMContextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -29,7 +23,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams from pipecat.turns.user_mute import ( @@ -38,6 +31,13 @@ from pipecat.turns.user_mute import ( MuteUntilFirstBotCompleteUserMuteStrategy, ) +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.pipecat_engine_variable_extractor import ( + VariableExtractionManager, +) +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + async def _build_engine_and_pipeline( workflow: WorkflowGraph, diff --git a/api/tests/test_pipecat_engine_variable_extraction.py b/api/tests/test_pipecat_engine_variable_extraction.py index 63ba808..29581d7 100644 --- a/api/tests/test_pipecat_engine_variable_extraction.py +++ b/api/tests/test_pipecat_engine_variable_extraction.py @@ -16,12 +16,6 @@ from typing import Any, Dict, List from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.pipecat_engine_variable_extractor import ( - VariableExtractionManager, -) -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import LLMContextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -31,10 +25,16 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMAssistantAggregatorParams, LLMContextAggregatorPair, ) -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.pipecat_engine_variable_extractor import ( + VariableExtractionManager, +) +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + class TestVariableExtractionDuringTransitions: """Test that variable extraction is triggered for the correct node during transitions.""" diff --git a/api/tests/test_pipeline_cancellation.py b/api/tests/test_pipeline_cancellation.py index 932e4d7..053c59f 100644 --- a/api/tests/test_pipeline_cancellation.py +++ b/api/tests/test_pipeline_cancellation.py @@ -2,7 +2,6 @@ import asyncio import pytest from loguru import logger - from pipecat.frames.frames import ( EndTaskFrame, Frame, diff --git a/api/tests/test_recording_router_processor.py b/api/tests/test_recording_router_processor.py index 5ef2057..c86e6b4 100644 --- a/api/tests/test_recording_router_processor.py +++ b/api/tests/test_recording_router_processor.py @@ -12,6 +12,14 @@ and inspect what arrives downstream. from typing import Optional import pytest +from pipecat.frames.frames import ( + LLMFullResponseEndFrame, + LLMTextFrame, + TTSAudioRawFrame, + TTSStartedFrame, + TTSStoppedFrame, + TTSTextFrame, +) from api.services.pipecat.recording_audio_cache import RecordingAudio from api.services.pipecat.recording_router_processor import ( @@ -21,14 +29,6 @@ from api.services.workflow.pipecat_engine_context_composer import ( RECORDING_MARKER, TTS_MARKER, ) -from pipecat.frames.frames import ( - LLMFullResponseEndFrame, - LLMTextFrame, - TTSAudioRawFrame, - TTSStartedFrame, - TTSStoppedFrame, - TTSTextFrame, -) from pipecat.tests import run_test # --------------------------------------------------------------------------- diff --git a/api/tests/test_text_and_audio_playback.py b/api/tests/test_text_and_audio_playback.py index e6a31f7..a950c9b 100644 --- a/api/tests/test_text_and_audio_playback.py +++ b/api/tests/test_text_and_audio_playback.py @@ -11,21 +11,6 @@ from typing import Any, Dict, List from unittest.mock import AsyncMock, Mock, patch import pytest - -from api.services.pipecat.recording_audio_cache import RecordingAudio -from api.services.workflow.dto import ( - EdgeDataDTO, - EndCallNodeData, - EndCallRFNode, - Position, - ReactFlowDTO, - RFEdgeDTO, - StartCallNodeData, - StartCallRFNode, -) -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.pipecat_engine_custom_tools import CustomToolManager -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import ( Frame, LLMContextFrame, @@ -42,10 +27,25 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMAssistantAggregatorParams, LLMContextAggregatorPair, ) -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams +from api.services.pipecat.recording_audio_cache import RecordingAudio +from api.services.workflow.dto import ( + EdgeDataDTO, + EndCallNodeData, + EndCallRFNode, + Position, + ReactFlowDTO, + RFEdgeDTO, + StartCallNodeData, + StartCallRFNode, +) +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.pipecat_engine_custom_tools import CustomToolManager +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + # ─── Constants ────────────────────────────────────────────────── START_PROMPT = "Start Call System Prompt" diff --git a/api/tests/test_tts_endframe_with_audio_write_failure.py b/api/tests/test_tts_endframe_with_audio_write_failure.py index c237cdf..56f9ac6 100644 --- a/api/tests/test_tts_endframe_with_audio_write_failure.py +++ b/api/tests/test_tts_endframe_with_audio_write_failure.py @@ -32,12 +32,6 @@ import asyncio from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.pipecat_engine_variable_extractor import ( - VariableExtractionManager, -) -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import LLMContextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -48,7 +42,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams from pipecat.turns.user_mute import ( @@ -57,6 +50,13 @@ from pipecat.turns.user_mute import ( ) from pipecat.utils.enums import EndTaskReason +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.pipecat_engine_variable_extractor import ( + VariableExtractionManager, +) +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + async def create_test_pipeline_with_failing_transport( workflow: WorkflowGraph, diff --git a/api/tests/test_unregistered_function_call.py b/api/tests/test_unregistered_function_call.py index 4cd8931..24ed9a1 100644 --- a/api/tests/test_unregistered_function_call.py +++ b/api/tests/test_unregistered_function_call.py @@ -1,7 +1,6 @@ """Tests for LLM behavior when calling an unregistered function.""" import pytest - from pipecat.frames.frames import ( FunctionCallInProgressFrame, FunctionCallResultFrame, @@ -13,6 +12,7 @@ from pipecat.frames.frames import ( ) from pipecat.pipeline.pipeline import Pipeline from pipecat.processors.aggregators.llm_context import LLMContext + from pipecat.tests import MockLLMService, run_test diff --git a/api/tests/test_user_idle_handler.py b/api/tests/test_user_idle_handler.py index 916878d..47d8eee 100644 --- a/api/tests/test_user_idle_handler.py +++ b/api/tests/test_user_idle_handler.py @@ -13,9 +13,6 @@ import asyncio from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import ( BotStoppedSpeakingFrame, Frame, @@ -35,7 +32,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams from pipecat.turns.user_mute import ( @@ -47,6 +43,10 @@ from pipecat.turns.user_stop import ExternalUserTurnStopStrategy from pipecat.turns.user_turn_strategies import UserTurnStrategies from pipecat.utils.time import time_now_iso8601 +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + class UserSpeechInjector(FrameProcessor): """Processor that injects user speaking frames after the bot finishes speaking. diff --git a/api/tests/test_user_muting_during_bot_speech.py b/api/tests/test_user_muting_during_bot_speech.py index 17c0f65..b055385 100644 --- a/api/tests/test_user_muting_during_bot_speech.py +++ b/api/tests/test_user_muting_during_bot_speech.py @@ -15,12 +15,6 @@ from typing import List from unittest.mock import AsyncMock, patch import pytest - -from api.services.workflow.pipecat_engine import PipecatEngine -from api.services.workflow.pipecat_engine_variable_extractor import ( - VariableExtractionManager, -) -from api.services.workflow.workflow import WorkflowGraph from pipecat.frames.frames import ( BotStartedSpeakingFrame, BotStoppedSpeakingFrame, @@ -41,7 +35,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.tests import MockLLMService, MockTTSService from pipecat.tests.mock_transport import MockTransport from pipecat.transports.base_transport import TransportParams from pipecat.turns.user_mute import ( @@ -51,6 +44,13 @@ from pipecat.turns.user_mute import ( from pipecat.turns.user_turn_strategies import ExternalUserTurnStrategies from pipecat.utils.time import time_now_iso8601 +from api.services.workflow.pipecat_engine import PipecatEngine +from api.services.workflow.pipecat_engine_variable_extractor import ( + VariableExtractionManager, +) +from api.services.workflow.workflow import WorkflowGraph +from pipecat.tests import MockLLMService, MockTTSService + class BotSpeakingObserverProcessor(FrameProcessor): """Observer that records mute status when bot speaking events flow upstream. diff --git a/api/tests/test_voicemail_detector.py b/api/tests/test_voicemail_detector.py index f2e5141..0677c29 100644 --- a/api/tests/test_voicemail_detector.py +++ b/api/tests/test_voicemail_detector.py @@ -8,7 +8,6 @@ incoming speech as CONVERSATION or VOICEMAIL and how the main LLM responds. import asyncio import pytest - from pipecat.extensions.voicemail.voicemail_detector import VoicemailDetector from pipecat.frames.frames import ( EndTaskFrame, @@ -27,7 +26,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.tests import MockLLMService from pipecat.turns.user_start import ( TranscriptionUserTurnStartStrategy, VADUserTurnStartStrategy, @@ -38,6 +36,8 @@ from pipecat.turns.user_stop import ( from pipecat.turns.user_turn_strategies import UserTurnStrategies from pipecat.utils.time import time_now_iso8601 +from pipecat.tests import MockLLMService + class FrameInjector(FrameProcessor): """Simple processor that can inject frames into the pipeline."""