mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
fix: changes to update pipecat version to 0.0.100 (#122)
* feat: add stt evals * add smart turn as provider * chore: remove deprecations * chore: format files * fix: remove deprecated UserIdleProcessor * fix: remove deprecated TranscriptProcessor * chore: update pipecat submodule * feat: add evals visualisation * fix: trigger llm generation on client connected and pipeline started * chore: update pipecat * chore: update pipecat submodule * Add tests * fix: slow loading of workflow page * chore: update pipecat submodule * Show version after release * Fixes #99 * fix: provider check for websocket connection * Fixes #107 * Fix #96 * chore: fix documentation * fix: cloudonix campaign call error --------- Co-authored-by: Sabiha Khan <sabihak89@gmail.com>
This commit is contained in:
parent
a4367bd83b
commit
911c5ed416
104 changed files with 16919 additions and 597 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import Any, Dict
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, Optional
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
|
@ -28,6 +28,87 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
|||
START_CALL_SYSTEM_PROMPT = "start_call_system_prompt"
|
||||
END_CALL_SYSTEM_PROMPT = "end_call_system_prompt"
|
||||
|
||||
# Default workflow definition for mocking database WorkflowModel
|
||||
DEFAULT_WORKFLOW_DEFINITION = {
|
||||
"nodes": [
|
||||
{
|
||||
"id": "1",
|
||||
"type": "startCall",
|
||||
"position": {"x": 0, "y": 0},
|
||||
"data": {
|
||||
"name": "Start",
|
||||
"prompt": START_CALL_SYSTEM_PROMPT,
|
||||
"is_start": True,
|
||||
"allow_interrupt": False,
|
||||
"add_global_prompt": False,
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"type": "endCall",
|
||||
"position": {"x": 0, "y": 200},
|
||||
"data": {
|
||||
"name": "End",
|
||||
"prompt": END_CALL_SYSTEM_PROMPT,
|
||||
"is_end": True,
|
||||
"allow_interrupt": False,
|
||||
"add_global_prompt": False,
|
||||
},
|
||||
},
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "1-2",
|
||||
"source": "1",
|
||||
"target": "2",
|
||||
"data": {"label": "End", "condition": "End the call"},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class MockWorkflowModel:
|
||||
"""Mock database WorkflowModel for testing.
|
||||
|
||||
This mimics the structure of the database WorkflowModel, not the parsed WorkflowGraph.
|
||||
Use this when mocking db_client.get_workflow() responses.
|
||||
"""
|
||||
|
||||
workflow_id: int = 1
|
||||
organization_id: int = 1
|
||||
workflow_configurations: Dict[str, Any] = field(default_factory=dict)
|
||||
workflow_definition_with_fallback: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
def __post_init__(self):
|
||||
if not self.workflow_definition_with_fallback:
|
||||
self.workflow_definition_with_fallback = DEFAULT_WORKFLOW_DEFINITION.copy()
|
||||
|
||||
|
||||
@dataclass
|
||||
class MockWorkflowRun:
|
||||
"""Mock database WorkflowRun for testing.
|
||||
|
||||
Use this when mocking db_client.get_workflow_run() responses.
|
||||
"""
|
||||
|
||||
is_completed: bool = False
|
||||
initial_context: Dict[str, Any] = field(default_factory=dict)
|
||||
gathered_context: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class MockUserConfig:
|
||||
"""Mock user configuration for testing.
|
||||
|
||||
Use this when mocking db_client.get_user_configurations() responses.
|
||||
"""
|
||||
|
||||
stt: Optional[Any] = None
|
||||
tts: Optional[Any] = None
|
||||
llm: Optional[Any] = None
|
||||
embeddings: Optional[Any] = None
|
||||
|
||||
|
||||
class MockTransportProcessor(FrameProcessor):
|
||||
"""
|
||||
|
|
@ -41,7 +122,7 @@ class MockTransportProcessor(FrameProcessor):
|
|||
|
||||
Args:
|
||||
emit_bot_speaking: If True, also emits BotSpeakingFrame on TTSAudioRawFrame
|
||||
which is needed for UserIdleProcessor to start conversation tracking. Default True.
|
||||
which is needed for user idle tracking to start conversation tracking. Default True.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
|
@ -63,7 +144,7 @@ class MockTransportProcessor(FrameProcessor):
|
|||
BotStartedSpeakingFrame(), direction=FrameDirection.UPSTREAM
|
||||
)
|
||||
elif isinstance(frame, TTSAudioRawFrame):
|
||||
# Emit BotSpeakingFrame - this is what triggers the UserIdleProcessor
|
||||
# Emit BotSpeakingFrame - this is what triggers user idle tracking
|
||||
# to start conversation tracking
|
||||
if self._emit_bot_speaking:
|
||||
await self.push_frame(BotSpeakingFrame())
|
||||
|
|
@ -101,6 +182,24 @@ def mock_engine():
|
|||
return engine
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_workflow_model():
|
||||
"""Create a mock WorkflowModel for testing database responses."""
|
||||
return MockWorkflowModel()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_workflow_run():
|
||||
"""Create a mock WorkflowRun for testing database responses."""
|
||||
return MockWorkflowRun()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_user_config():
|
||||
"""Create a mock user configuration for testing."""
|
||||
return MockUserConfig()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_tools():
|
||||
"""Create sample mock tools for testing."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue