Merge pull request #1486 from CerebriumAI/feature/ultravox

Feature/ultravox - bug fixes
This commit is contained in:
milo157
2025-04-01 00:03:26 +02:00
committed by GitHub
parent 2fb9aa4d76
commit ed387e876a
4 changed files with 19 additions and 13 deletions

View File

@@ -34,7 +34,7 @@ logger.add(sys.stderr, level="DEBUG")
# Want to initialize the ultravox processor since it takes time to load the model and dont # Want to initialize the ultravox processor since it takes time to load the model and dont
# want to load it every time the pipeline is run # want to load it every time the pipeline is run
ultravox_processor = UltravoxSTTService( ultravox_processor = UltravoxSTTService(
model_size="fixie-ai/ultravox-v0_4_1-llama-3_1-8b", model_name="fixie-ai/ultravox-v0_5-llama-3_1-8b",
hf_token=os.getenv("HF_TOKEN"), hf_token=os.getenv("HF_TOKEN"),
) )

View File

@@ -17,6 +17,13 @@ from loguru import logger
from pipecat.frames.frames import ( from pipecat.frames.frames import (
AudioRawFrame, AudioRawFrame,
LLMFullResponseEndFrame,
LLMFullResponseStartFrame,
LLMTextFrame,
TranscriptionFrame,
TextFrame,
StartFrame,
EndFrame,
CancelFrame, CancelFrame,
EndFrame, EndFrame,
ErrorFrame, ErrorFrame,
@@ -177,7 +184,7 @@ class UltravoxSTTService(AIService):
to generate text transcriptions. to generate text transcriptions.
Args: Args:
model_size: The Ultravox model to use (ModelSize enum or string) model_name: The Ultravox model to use (ModelSize enum or string)
hf_token: Hugging Face token for model access hf_token: Hugging Face token for model access
temperature: Sampling temperature for generation temperature: Sampling temperature for generation
max_tokens: Maximum tokens to generate max_tokens: Maximum tokens to generate
@@ -194,7 +201,7 @@ class UltravoxSTTService(AIService):
def __init__( def __init__(
self, self,
*, *,
model_size: str = "fixie-ai/ultravox-v0_4_1-llama-3_1-8b", model_name: str = "fixie-ai/ultravox-v0_5-llama-3_1-8b",
hf_token: Optional[str] = None, hf_token: Optional[str] = None,
temperature: float = 0.7, temperature: float = 0.7,
max_tokens: int = 100, max_tokens: int = 100,
@@ -211,7 +218,6 @@ class UltravoxSTTService(AIService):
logger.warning("No Hugging Face token provided. Model may not load correctly.") logger.warning("No Hugging Face token provided. Model may not load correctly.")
# Initialize model # Initialize model
model_name = model_size if isinstance(model_size, str) else model_size.value
self._model = UltravoxModel(model_name=model_name) self._model = UltravoxModel(model_name=model_name)
# Initialize service state # Initialize service state
@@ -356,10 +362,10 @@ class UltravoxSTTService(AIService):
await self.start_ttfb_metrics() await self.start_ttfb_metrics()
await self.start_processing_metrics() await self.start_processing_metrics()
async for response in self.model.generate( async for response in self._model.generate(
messages=[{"role": "user", "content": "<|audio|>\n"}], messages=[{"role": "user", "content": "<|audio|>\n"}],
temperature=self.temperature, temperature=self._temperature,
max_tokens=self.max_tokens, max_tokens=self._max_tokens,
audio=audio_float32, audio=audio_float32,
): ):
# Stop TTFB metrics after first response # Stop TTFB metrics after first response

View File

@@ -133,6 +133,6 @@ async def test_run_piper_tts_error(aiohttp_client):
up_frames = frames_received[1] up_frames = frames_received[1]
assert isinstance(up_frames[0], ErrorFrame), "Must receive an ErrorFrame for 404" assert isinstance(up_frames[0], ErrorFrame), "Must receive an ErrorFrame for 404"
assert "status: 404" in up_frames[0].error, ( assert (
"ErrorFrame should contain details about the 404" "status: 404" in up_frames[0].error
) ), "ErrorFrame should contain details about the 404"

View File

@@ -86,9 +86,9 @@ class TestUserIdleProcessor(unittest.IsolatedAsyncioTestCase):
expected_down_frames=expected_down_frames, expected_down_frames=expected_down_frames,
) )
assert not callback_called.is_set(), ( assert (
"Idle callback was called even though bot speaking frames reset the timer" not callback_called.is_set()
) ), "Idle callback was called even though bot speaking frames reset the timer"
async def test_idle_retry_callback(self): async def test_idle_retry_callback(self):
"""Test that retry count increases until user activity resets it.""" """Test that retry count increases until user activity resets it."""