Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up tests #192

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/foundational/08-bots-arguing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import asyncio
import logging
import os
from pipecat.pipeline.aggregators import SentenceAggregator
from pipecat.processors.aggregators import SentenceAggregator
from pipecat.pipeline.pipeline import Pipeline

from pipecat.transports.daily_transport import DailyTransport
from pipecat.services.azure_ai_services import AzureLLMService, AzureTTSService
from pipecat.services.elevenlabs_ai_services import ElevenLabsTTSService
from pipecat.services.fal_ai_services import FalImageGenService
from pipecat.pipeline.frames import AudioFrame, EndFrame, ImageFrame, LLMMessagesFrame, TextFrame
from pipecat.frames.frames import AudioFrame, EndFrame, ImageFrame, LLMMessagesFrame, TextFrame

from runner import configure

Expand Down
4 changes: 2 additions & 2 deletions examples/foundational/websocket-server/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import aiohttp
import logging
import os
from pipecat.pipeline.frame_processor import FrameProcessor
from pipecat.pipeline.frames import TextFrame, TranscriptionFrame
from pipeline.processors.frame_processor import FrameProcessor
from pipecat.frames.frames import TextFrame, TranscriptionFrame
from pipecat.pipeline.pipeline import Pipeline
from pipecat.services.elevenlabs_ai_services import ElevenLabsTTSService
from pipecat.transports.websocket_transport import WebsocketTransport
Expand Down
2 changes: 1 addition & 1 deletion src/pipecat/frames/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class UserStoppedSpeakingFrame(ControlFrame):
@dataclass
class TTSStartedFrame(ControlFrame):
"""Used to indicate the beginning of a TTS response. Following
AudioRawFrames are part of the TTS response until an TTSEndFrame. These
AudioRawFrames are part of the TTS response until an TTSStoppedFrame. These
frames can be used for aggregating audio frames in a transport to optimize
the size of frames sent to the session, without needing to control this in
the TTS service.
Expand Down
5 changes: 2 additions & 3 deletions src/pipecat/pipeline/merge_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List
from pipecat.pipeline.frames import EndFrame, EndPipeFrame
from pipecat.frames.frames import EndFrame
from pipecat.pipeline.pipeline import Pipeline


Expand All @@ -16,8 +16,7 @@ async def run_pipeline(self):
while True:
frame = await pipeline.sink.get()
if isinstance(
frame, EndFrame) or isinstance(
frame, EndPipeFrame):
frame, EndFrame):
break
await self.sink.put(frame)

Expand Down
2 changes: 1 addition & 1 deletion src/pipecat/processors/aggregators/gated.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GatedAggregator(FrameProcessor):
Yields gate-opening frame before any accumulated frames, then ensuing frames
until and not including the gate-closed frame.

>>> from pipecat.pipeline.frames import ImageFrame
>>> from pipecat.frames.frames import ImageFrame

>>> async def print_frames(aggregator, frame):
... async for frame in aggregator.process_frame(frame):
Expand Down
2 changes: 1 addition & 1 deletion src/pipecat/processors/aggregators/vision_image_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VisionImageFrameAggregator(FrameProcessor):
"""This aggregator waits for a consecutive TextFrame and an
ImageFrame. After the ImageFrame arrives it will output a VisionImageFrame.

>>> from pipecat.pipeline.frames import ImageFrame
>>> from pipecat.frames.frames import ImageFrame

>>> async def print_frames(aggregator, frame):
... async for frame in aggregator.process_frame(frame):
Expand Down
2 changes: 1 addition & 1 deletion src/pipecat/serializers/abstract_frame_serializer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import abstractmethod

from pipecat.pipeline.frames import Frame
from pipecat.frames.frames import Frame


class FrameSerializer:
Expand Down
6 changes: 3 additions & 3 deletions src/pipecat/serializers/protobuf_serializer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import dataclasses
from typing import Text
from pipecat.pipeline.frames import AudioFrame, Frame, TextFrame, TranscriptionFrame
import pipecat.pipeline.protobufs.frames_pb2 as frame_protos
from pipecat.frames.frames import AudioRawFrame, Frame, TextFrame, TranscriptionFrame
import pipecat.frames.protobufs.frames_pb2 as frame_protos
from pipecat.serializers.abstract_frame_serializer import FrameSerializer


class ProtobufFrameSerializer(FrameSerializer):
SERIALIZABLE_TYPES = {
TextFrame: "text",
AudioFrame: "audio",
AudioRawFrame: "audio",
TranscriptionFrame: "transcription"
}

Expand Down
2 changes: 1 addition & 1 deletion src/pipecat/transports/services/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from typing import Any, Callable, Mapping

from daily import (
CallClient,
Daily,
CallClient,
EventHandler,
VirtualCameraDevice,
VirtualMicrophoneDevice,
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/integration_azure_llm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import os
from pipecat.pipeline.openai_frames import OpenAILLMContextFrame
from pipecat.services.azure_ai_services import AzureLLMService
from pipecat.services.openai_llm_context import OpenAILLMContext
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContextFrame
from pipecat.services.azure import AzureLLMService
from pipecat.services.openai import OpenAILLMContext

from openai.types.chat import (
ChatCompletionSystemMessageParam,
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/integration_ollama_llm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import asyncio
from pipecat.pipeline.openai_frames import OpenAILLMContextFrame
from pipecat.services.openai_llm_context import OpenAILLMContext
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContextFrame, OpenAILLMContext

from openai.types.chat import (
ChatCompletionSystemMessageParam,
)
from pipecat.services.ollama_ai_services import OLLamaLLMService
from pipecat.services.ollama import OLLamaLLMService

if __name__ == "__main__":
async def test_chat():
Expand Down
1 change: 1 addition & 0 deletions tests/integration/integration_openai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from typing import List


from pipecat.services.openai import OpenAILLMContextFrame, OpenAILLMContext
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.frames.frames import (
Expand Down
31 changes: 15 additions & 16 deletions tests/test_aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import functools
import unittest

from pipecat.pipeline.aggregators import (
GatedAggregator,
ParallelPipeline,
SentenceAggregator,
StatelessTextTransformer,
)
from pipecat.pipeline.frames import (
AudioFrame,
from pipecat.processors.aggregators.sentence import SentenceAggregator
from pipecat.processors.text_transformer import StatelessTextTransformer
from pipecat.processors.aggregators.gated import GatedAggregator
from pipecat.pipeline.parallel_pipeline import ParallelPipeline

from pipecat.frames.frames import (
AudioRawFrame,
EndFrame,
ImageFrame,
ImageRawFrame,
LLMResponseEndFrame,
LLMResponseStartFrame,
Frame,
Expand Down Expand Up @@ -46,26 +45,26 @@ async def test_sentence_aggregator(self):
async def test_gated_accumulator(self):
gated_aggregator = GatedAggregator(
gate_open_fn=lambda frame: isinstance(
frame, ImageFrame), gate_close_fn=lambda frame: isinstance(
frame, ImageRawFrame), gate_close_fn=lambda frame: isinstance(
frame, LLMResponseStartFrame), start_open=False, )

frames = [
LLMResponseStartFrame(),
TextFrame("Hello, "),
TextFrame("world."),
AudioFrame(b"hello"),
ImageFrame(b"image", (0, 0)),
AudioFrame(b"world"),
AudioRawFrame(b"hello", 1, 1),
ImageRawFrame(b"image", (0, 0)),
AudioRawFrame(b"world", 1, 1),
LLMResponseEndFrame(),
]

expected_output_frames = [
ImageFrame(b"image", (0, 0)),
ImageRawFrame(b"image", (0, 0)),
LLMResponseStartFrame(),
TextFrame("Hello, "),
TextFrame("world."),
AudioFrame(b"hello"),
AudioFrame(b"world"),
AudioRawFrame(b"hello", 1, 1),
AudioRawFrame(b"world", 1, 1),
LLMResponseEndFrame(),
]
for frame in frames:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ai_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import AsyncGenerator

from pipecat.services.ai_services import AIService
from pipecat.pipeline.frames import EndFrame, Frame, TextFrame
from pipecat.frames.frames import EndFrame, Frame, TextFrame


class SimpleAIService(AIService):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import unittest
from unittest.mock import Mock

from pipecat.pipeline.aggregators import SentenceAggregator, StatelessTextTransformer
from pipecat.pipeline.frame_processor import FrameProcessor
from pipecat.pipeline.frames import EndFrame, TextFrame
from pipecat.processors.text_transformer import StatelessTextTransformer
from pipecat.processors.aggregators.sentence import SentenceAggregator
from pipecat.processors.frame_processor import FrameProcessor
from pipecat.frames.frames import EndFrame, TextFrame

from pipecat.pipeline.pipeline import Pipeline

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from pipecat.pipeline.frames import AudioFrame, TextFrame, TranscriptionFrame
from pipecat.frames.frames import AudioFrame, TextFrame, TranscriptionFrame
from pipecat.serializers.protobuf_serializer import ProtobufFrameSerializer


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
from unittest.mock import AsyncMock, patch, Mock

from pipecat.pipeline.frames import AudioFrame, EndFrame, TextFrame, TTSEndFrame, TTSStartFrame
from pipecat.frames.frames import AudioRawFrame, EndFrame, TextFrame, TTSStoppedFrame, TTSStartedFrame
from pipecat.pipeline.pipeline import Pipeline
from pipecat.transports.websocket_transport import WebSocketFrameProcessor, WebsocketTransport

Expand Down Expand Up @@ -52,10 +52,10 @@ async def test_frame_processor(self):
processor = WebSocketFrameProcessor(audio_frame_size=4)

source_frames = [
TTSStartFrame(),
AudioFrame(b"1234"),
AudioFrame(b"5678"),
TTSEndFrame(),
TTSStartedFrame(),
AudioRawFrame(b"1234", 1, 1),
AudioRawFrame(b"5678", 1, 1),
TTSStoppedFrame(),
TextFrame("hello world")
]

Expand All @@ -65,9 +65,9 @@ async def test_frame_processor(self):
frames.append(output_frame)

self.assertEqual(len(frames), 3)
self.assertIsInstance(frames[0], AudioFrame)
self.assertIsInstance(frames[0], AudioRawFrame)
self.assertEqual(frames[0].data, b"1234")
self.assertIsInstance(frames[1], AudioFrame)
self.assertIsInstance(frames[1], AudioRawFrame)
self.assertEqual(frames[1].data, b"5678")
self.assertIsInstance(frames[2], TextFrame)
self.assertEqual(frames[2].text, "hello world")
Expand Down
Loading