Refactor project structure and enhance backend integration
- Expanded package inclusion in `pyproject.toml` to support new modules. - Introduced new `adapters` and `protocol` packages for better organization. - Added backend adapter implementations for control plane integration. - Updated main application imports to reflect new package structure. - Removed deprecated core components and adjusted documentation accordingly. - Enhanced architecture documentation to clarify the new runtime and integration layers.
This commit is contained in:
1
engine/runtime/pipeline/__init__.py
Normal file
1
engine/runtime/pipeline/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Runtime pipeline package."""
|
||||
13
engine/runtime/pipeline/asr_flow.py
Normal file
13
engine/runtime/pipeline/asr_flow.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""ASR flow helpers extracted from the duplex pipeline.
|
||||
|
||||
This module is intentionally lightweight for phase-wise migration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from providers.common.base import ASRResult
|
||||
|
||||
|
||||
def is_final_result(result: ASRResult) -> bool:
|
||||
"""Return whether an ASR result is final."""
|
||||
return bool(result.is_final)
|
||||
6
engine/runtime/pipeline/constants.py
Normal file
6
engine/runtime/pipeline/constants.py
Normal file
@@ -0,0 +1,6 @@
|
||||
"""Shared constants for the runtime duplex pipeline."""
|
||||
|
||||
TRACK_AUDIO_IN = "audio_in"
|
||||
TRACK_AUDIO_OUT = "audio_out"
|
||||
TRACK_CONTROL = "control"
|
||||
PCM_FRAME_BYTES = 640 # 16k mono pcm_s16le, 20ms
|
||||
2764
engine/runtime/pipeline/duplex.py
Normal file
2764
engine/runtime/pipeline/duplex.py
Normal file
File diff suppressed because it is too large
Load Diff
12
engine/runtime/pipeline/events_out.py
Normal file
12
engine/runtime/pipeline/events_out.py
Normal file
@@ -0,0 +1,12 @@
|
||||
"""Output-event shaping helpers for the runtime pipeline."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
def assistant_text_delta_event(text: str, **extra: Any) -> Dict[str, Any]:
|
||||
"""Build a normalized assistant text delta payload."""
|
||||
payload: Dict[str, Any] = {"type": "assistant.text.delta", "text": str(text)}
|
||||
payload.update(extra)
|
||||
return payload
|
||||
8
engine/runtime/pipeline/interrupts.py
Normal file
8
engine/runtime/pipeline/interrupts.py
Normal file
@@ -0,0 +1,8 @@
|
||||
"""Interruption-related helpers extracted from the duplex pipeline."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def should_interrupt(min_duration_ms: int, detected_ms: int) -> bool:
|
||||
"""Decide whether interruption conditions are met."""
|
||||
return int(detected_ms) >= max(0, int(min_duration_ms))
|
||||
13
engine/runtime/pipeline/llm_flow.py
Normal file
13
engine/runtime/pipeline/llm_flow.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""LLM flow helpers extracted from the duplex pipeline.
|
||||
|
||||
This module is intentionally lightweight for phase-wise migration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from providers.common.base import LLMStreamEvent
|
||||
|
||||
|
||||
def is_done_event(event: LLMStreamEvent) -> bool:
|
||||
"""Return whether an LLM stream event signals completion."""
|
||||
return str(event.type) == "done"
|
||||
13
engine/runtime/pipeline/tooling.py
Normal file
13
engine/runtime/pipeline/tooling.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""Tooling helpers extracted from the duplex pipeline."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def normalize_tool_name(name: Any, aliases: dict[str, str]) -> str:
|
||||
"""Normalize tool name with alias mapping."""
|
||||
normalized = str(name or "").strip()
|
||||
if not normalized:
|
||||
return ""
|
||||
return aliases.get(normalized, normalized)
|
||||
15
engine/runtime/pipeline/tts_flow.py
Normal file
15
engine/runtime/pipeline/tts_flow.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""TTS flow helpers extracted from the duplex pipeline.
|
||||
|
||||
This module is intentionally lightweight for phase-wise migration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from providers.common.base import TTSChunk
|
||||
|
||||
|
||||
def chunk_duration_ms(chunk: TTSChunk) -> float:
|
||||
"""Estimate chunk duration in milliseconds for pcm16 mono."""
|
||||
if chunk.sample_rate <= 0:
|
||||
return 0.0
|
||||
return (len(chunk.audio) / 2.0 / float(chunk.sample_rate)) * 1000.0
|
||||
Reference in New Issue
Block a user