diff --git a/src/pipecat/processors/async_frame_processor.py b/src/pipecat/processors/async_frame_processor.py index db805f924..24c016867 100644 --- a/src/pipecat/processors/async_frame_processor.py +++ b/src/pipecat/processors/async_frame_processor.py @@ -14,10 +14,11 @@ class AsyncFrameProcessor(FrameProcessor): def __init__( self, + *, name: str | None = None, loop: asyncio.AbstractEventLoop | None = None, **kwargs): - super().__init__(name, loop, **kwargs) + super().__init__(name=name, loop=loop, **kwargs) self._create_push_task() diff --git a/src/pipecat/processors/frame_processor.py b/src/pipecat/processors/frame_processor.py index e9c8e30c1..18c03f169 100644 --- a/src/pipecat/processors/frame_processor.py +++ b/src/pipecat/processors/frame_processor.py @@ -66,6 +66,7 @@ class FrameProcessor: def __init__( self, + *, name: str | None = None, loop: asyncio.AbstractEventLoop | None = None, **kwargs): diff --git a/src/pipecat/services/ai_services.py b/src/pipecat/services/ai_services.py index e3667a85c..06e4b3ebe 100644 --- a/src/pipecat/services/ai_services.py +++ b/src/pipecat/services/ai_services.py @@ -118,7 +118,7 @@ class LLMService(AIService): class TTSService(AIService): - def __init__(self, aggregate_sentences: bool = True, **kwargs): + def __init__(self, *, aggregate_sentences: bool = True, **kwargs): super().__init__(**kwargs) self._aggregate_sentences: bool = aggregate_sentences self._current_sentence: str = "" @@ -180,6 +180,7 @@ class STTService(AIService): """STTService is a base class for speech-to-text services.""" def __init__(self, + *, min_volume: float = 0.6, max_silence_secs: float = 0.3, max_buffer_secs: float = 1.5, diff --git a/src/pipecat/services/anthropic.py b/src/pipecat/services/anthropic.py index ca32f0451..3868617eb 100644 --- a/src/pipecat/services/anthropic.py +++ b/src/pipecat/services/anthropic.py @@ -41,6 +41,7 @@ class AnthropicLLMService(LLMService): def __init__( self, + *, api_key: str, model: str = "claude-3-opus-20240229", max_tokens: int = 1024): diff --git a/src/pipecat/services/deepgram.py b/src/pipecat/services/deepgram.py index 4ccd8c50f..59d323c33 100644 --- a/src/pipecat/services/deepgram.py +++ b/src/pipecat/services/deepgram.py @@ -5,7 +5,6 @@ # import aiohttp -import asyncio import time from typing import AsyncGenerator @@ -18,11 +17,10 @@ from pipecat.frames.frames import ( Frame, InterimTranscriptionFrame, StartFrame, - StartInterruptionFrame, SystemFrame, TranscriptionFrame) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.ai_services import AIService, AsyncAIService, TTSService +from pipecat.services.ai_services import AsyncAIService, TTSService from loguru import logger @@ -96,6 +94,7 @@ class DeepgramTTSService(TTSService): class DeepgramSTTService(AsyncAIService): def __init__(self, + *, api_key: str, url: str = "", live_options: LiveOptions = LiveOptions( diff --git a/src/pipecat/services/fireworks.py b/src/pipecat/services/fireworks.py index 2c1020be5..7fa4d64e8 100644 --- a/src/pipecat/services/fireworks.py +++ b/src/pipecat/services/fireworks.py @@ -19,6 +19,7 @@ except ModuleNotFoundError as e: class FireworksLLMService(BaseOpenAILLMService): def __init__(self, + *, model: str = "accounts/fireworks/models/firefunction-v1", base_url: str = "https://api.fireworks.ai/inference/v1"): super().__init__(model, base_url) diff --git a/src/pipecat/services/google.py b/src/pipecat/services/google.py index c558ca283..da83e9274 100644 --- a/src/pipecat/services/google.py +++ b/src/pipecat/services/google.py @@ -42,7 +42,7 @@ class GoogleLLMService(LLMService): franca for all LLM services, so that it is easy to switch between different LLMs. """ - def __init__(self, api_key: str, model: str = "gemini-1.5-flash-latest", **kwargs): + def __init__(self, *, api_key: str, model: str = "gemini-1.5-flash-latest", **kwargs): super().__init__(**kwargs) gai.configure(api_key=api_key) self._client = gai.GenerativeModel(model) diff --git a/src/pipecat/services/moondream.py b/src/pipecat/services/moondream.py index 2c105c92d..cff8d3172 100644 --- a/src/pipecat/services/moondream.py +++ b/src/pipecat/services/moondream.py @@ -46,6 +46,7 @@ def detect_device(): class MoondreamService(VisionService): def __init__( self, + *, model="vikhyatk/moondream2", revision="2024-04-02", use_cpu=False diff --git a/src/pipecat/services/ollama.py b/src/pipecat/services/ollama.py index 5de16dc07..8fa3fc2de 100644 --- a/src/pipecat/services/ollama.py +++ b/src/pipecat/services/ollama.py @@ -9,5 +9,5 @@ from pipecat.services.openai import BaseOpenAILLMService class OLLamaLLMService(BaseOpenAILLMService): - def __init__(self, model: str = "llama2", base_url: str = "http://localhost:11434/v1"): + def __init__(self, *, model: str = "llama2", base_url: str = "http://localhost:11434/v1"): super().__init__(model=model, base_url=base_url, api_key="ollama") diff --git a/src/pipecat/services/openai.py b/src/pipecat/services/openai.py index 1e7cd070b..345c76043 100644 --- a/src/pipecat/services/openai.py +++ b/src/pipecat/services/openai.py @@ -67,7 +67,7 @@ class BaseOpenAILLMService(LLMService): calls from the LLM. """ - def __init__(self, model: str, api_key=None, base_url=None, **kwargs): + def __init__(self, *, model: str, api_key=None, base_url=None, **kwargs): super().__init__(**kwargs) self._model: str = model self._client = self.create_client(api_key=api_key, base_url=base_url, **kwargs) @@ -236,8 +236,8 @@ class BaseOpenAILLMService(LLMService): class OpenAILLMService(BaseOpenAILLMService): - def __init__(self, model="gpt-4o", **kwargs): - super().__init__(model, **kwargs) + def __init__(self, *, model: str = "gpt-4o", **kwargs): + super().__init__(model=model, **kwargs) class OpenAIImageGenService(ImageGenService): diff --git a/src/pipecat/services/openpipe.py b/src/pipecat/services/openpipe.py index de9d9fcfa..ada7824fb 100644 --- a/src/pipecat/services/openpipe.py +++ b/src/pipecat/services/openpipe.py @@ -25,6 +25,7 @@ class OpenPipeLLMService(BaseOpenAILLMService): def __init__( self, + *, model: str = "gpt-4o", api_key: str | None = None, base_url: str | None = None, @@ -33,9 +34,9 @@ class OpenPipeLLMService(BaseOpenAILLMService): tags: Dict[str, str] | None = None, **kwargs): super().__init__( - model, - api_key, - base_url, + model=model, + api_key=api_key, + base_url=base_url, openpipe_api_key=openpipe_api_key, openpipe_base_url=openpipe_base_url, **kwargs) diff --git a/src/pipecat/services/whisper.py b/src/pipecat/services/whisper.py index 9cd3150dc..5ef06f135 100644 --- a/src/pipecat/services/whisper.py +++ b/src/pipecat/services/whisper.py @@ -42,7 +42,8 @@ class WhisperSTTService(STTService): """Class to transcribe audio with a locally-downloaded Whisper model""" def __init__(self, - model: Model = Model.DISTIL_MEDIUM_EN, + *, + model: str | Model = Model.DISTIL_MEDIUM_EN, device: str = "auto", compute_type: str = "default", no_speech_prob: float = 0.4, @@ -51,7 +52,7 @@ class WhisperSTTService(STTService): super().__init__(**kwargs) self._device: str = device self._compute_type = compute_type - self._model_name: Model = model + self._model_name: str | Model = model self._no_speech_prob = no_speech_prob self._model: WhisperModel | None = None self._load() @@ -64,7 +65,7 @@ class WhisperSTTService(STTService): this model is being run, it will take time to download.""" logger.debug("Loading Whisper model...") self._model = WhisperModel( - self._model_name.value, + self._model_name.value if isinstance(self._model_name, Enum) else self._model_name, device=self._device, compute_type=self._compute_type) logger.debug("Loaded Whisper model")