services: add missing * keyword separator

This commit is contained in:
Aleix Conchillo Flaqué
2024-07-01 10:17:21 -07:00
parent 9d5c2b9656
commit df4c3e56c4
12 changed files with 23 additions and 16 deletions

View File

@@ -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()

View File

@@ -66,6 +66,7 @@ class FrameProcessor:
def __init__(
self,
*,
name: str | None = None,
loop: asyncio.AbstractEventLoop | None = None,
**kwargs):

View File

@@ -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,

View File

@@ -41,6 +41,7 @@ class AnthropicLLMService(LLMService):
def __init__(
self,
*,
api_key: str,
model: str = "claude-3-opus-20240229",
max_tokens: int = 1024):

View File

@@ -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(

View File

@@ -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)

View File

@@ -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)

View File

@@ -46,6 +46,7 @@ def detect_device():
class MoondreamService(VisionService):
def __init__(
self,
*,
model="vikhyatk/moondream2",
revision="2024-04-02",
use_cpu=False

View File

@@ -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")

View File

@@ -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):

View File

@@ -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)

View File

@@ -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")