services: add missing * keyword separator
This commit is contained in:
@@ -14,10 +14,11 @@ class AsyncFrameProcessor(FrameProcessor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
loop: asyncio.AbstractEventLoop | None = None,
|
loop: asyncio.AbstractEventLoop | None = None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
super().__init__(name, loop, **kwargs)
|
super().__init__(name=name, loop=loop, **kwargs)
|
||||||
|
|
||||||
self._create_push_task()
|
self._create_push_task()
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class FrameProcessor:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
loop: asyncio.AbstractEventLoop | None = None,
|
loop: asyncio.AbstractEventLoop | None = None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class LLMService(AIService):
|
|||||||
|
|
||||||
|
|
||||||
class TTSService(AIService):
|
class TTSService(AIService):
|
||||||
def __init__(self, aggregate_sentences: bool = True, **kwargs):
|
def __init__(self, *, aggregate_sentences: bool = True, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self._aggregate_sentences: bool = aggregate_sentences
|
self._aggregate_sentences: bool = aggregate_sentences
|
||||||
self._current_sentence: str = ""
|
self._current_sentence: str = ""
|
||||||
@@ -180,6 +180,7 @@ class STTService(AIService):
|
|||||||
"""STTService is a base class for speech-to-text services."""
|
"""STTService is a base class for speech-to-text services."""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
*,
|
||||||
min_volume: float = 0.6,
|
min_volume: float = 0.6,
|
||||||
max_silence_secs: float = 0.3,
|
max_silence_secs: float = 0.3,
|
||||||
max_buffer_secs: float = 1.5,
|
max_buffer_secs: float = 1.5,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class AnthropicLLMService(LLMService):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
model: str = "claude-3-opus-20240229",
|
model: str = "claude-3-opus-20240229",
|
||||||
max_tokens: int = 1024):
|
max_tokens: int = 1024):
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
@@ -18,11 +17,10 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
InterimTranscriptionFrame,
|
InterimTranscriptionFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
|
||||||
SystemFrame,
|
SystemFrame,
|
||||||
TranscriptionFrame)
|
TranscriptionFrame)
|
||||||
from pipecat.processors.frame_processor import FrameDirection
|
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
|
from loguru import logger
|
||||||
|
|
||||||
@@ -96,6 +94,7 @@ class DeepgramTTSService(TTSService):
|
|||||||
|
|
||||||
class DeepgramSTTService(AsyncAIService):
|
class DeepgramSTTService(AsyncAIService):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
*,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
url: str = "",
|
url: str = "",
|
||||||
live_options: LiveOptions = LiveOptions(
|
live_options: LiveOptions = LiveOptions(
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ except ModuleNotFoundError as e:
|
|||||||
|
|
||||||
class FireworksLLMService(BaseOpenAILLMService):
|
class FireworksLLMService(BaseOpenAILLMService):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
*,
|
||||||
model: str = "accounts/fireworks/models/firefunction-v1",
|
model: str = "accounts/fireworks/models/firefunction-v1",
|
||||||
base_url: str = "https://api.fireworks.ai/inference/v1"):
|
base_url: str = "https://api.fireworks.ai/inference/v1"):
|
||||||
super().__init__(model, base_url)
|
super().__init__(model, base_url)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class GoogleLLMService(LLMService):
|
|||||||
franca for all LLM services, so that it is easy to switch between different LLMs.
|
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)
|
super().__init__(**kwargs)
|
||||||
gai.configure(api_key=api_key)
|
gai.configure(api_key=api_key)
|
||||||
self._client = gai.GenerativeModel(model)
|
self._client = gai.GenerativeModel(model)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ def detect_device():
|
|||||||
class MoondreamService(VisionService):
|
class MoondreamService(VisionService):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
model="vikhyatk/moondream2",
|
model="vikhyatk/moondream2",
|
||||||
revision="2024-04-02",
|
revision="2024-04-02",
|
||||||
use_cpu=False
|
use_cpu=False
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ from pipecat.services.openai import BaseOpenAILLMService
|
|||||||
|
|
||||||
class OLLamaLLMService(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")
|
super().__init__(model=model, base_url=base_url, api_key="ollama")
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class BaseOpenAILLMService(LLMService):
|
|||||||
calls from the LLM.
|
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)
|
super().__init__(**kwargs)
|
||||||
self._model: str = model
|
self._model: str = model
|
||||||
self._client = self.create_client(api_key=api_key, base_url=base_url, **kwargs)
|
self._client = self.create_client(api_key=api_key, base_url=base_url, **kwargs)
|
||||||
@@ -236,8 +236,8 @@ class BaseOpenAILLMService(LLMService):
|
|||||||
|
|
||||||
class OpenAILLMService(BaseOpenAILLMService):
|
class OpenAILLMService(BaseOpenAILLMService):
|
||||||
|
|
||||||
def __init__(self, model="gpt-4o", **kwargs):
|
def __init__(self, *, model: str = "gpt-4o", **kwargs):
|
||||||
super().__init__(model, **kwargs)
|
super().__init__(model=model, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class OpenAIImageGenService(ImageGenService):
|
class OpenAIImageGenService(ImageGenService):
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class OpenPipeLLMService(BaseOpenAILLMService):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
model: str = "gpt-4o",
|
model: str = "gpt-4o",
|
||||||
api_key: str | None = None,
|
api_key: str | None = None,
|
||||||
base_url: str | None = None,
|
base_url: str | None = None,
|
||||||
@@ -33,9 +34,9 @@ class OpenPipeLLMService(BaseOpenAILLMService):
|
|||||||
tags: Dict[str, str] | None = None,
|
tags: Dict[str, str] | None = None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
model,
|
model=model,
|
||||||
api_key,
|
api_key=api_key,
|
||||||
base_url,
|
base_url=base_url,
|
||||||
openpipe_api_key=openpipe_api_key,
|
openpipe_api_key=openpipe_api_key,
|
||||||
openpipe_base_url=openpipe_base_url,
|
openpipe_base_url=openpipe_base_url,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class WhisperSTTService(STTService):
|
|||||||
"""Class to transcribe audio with a locally-downloaded Whisper model"""
|
"""Class to transcribe audio with a locally-downloaded Whisper model"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
model: Model = Model.DISTIL_MEDIUM_EN,
|
*,
|
||||||
|
model: str | Model = Model.DISTIL_MEDIUM_EN,
|
||||||
device: str = "auto",
|
device: str = "auto",
|
||||||
compute_type: str = "default",
|
compute_type: str = "default",
|
||||||
no_speech_prob: float = 0.4,
|
no_speech_prob: float = 0.4,
|
||||||
@@ -51,7 +52,7 @@ class WhisperSTTService(STTService):
|
|||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self._device: str = device
|
self._device: str = device
|
||||||
self._compute_type = compute_type
|
self._compute_type = compute_type
|
||||||
self._model_name: Model = model
|
self._model_name: str | Model = model
|
||||||
self._no_speech_prob = no_speech_prob
|
self._no_speech_prob = no_speech_prob
|
||||||
self._model: WhisperModel | None = None
|
self._model: WhisperModel | None = None
|
||||||
self._load()
|
self._load()
|
||||||
@@ -64,7 +65,7 @@ class WhisperSTTService(STTService):
|
|||||||
this model is being run, it will take time to download."""
|
this model is being run, it will take time to download."""
|
||||||
logger.debug("Loading Whisper model...")
|
logger.debug("Loading Whisper model...")
|
||||||
self._model = WhisperModel(
|
self._model = WhisperModel(
|
||||||
self._model_name.value,
|
self._model_name.value if isinstance(self._model_name, Enum) else self._model_name,
|
||||||
device=self._device,
|
device=self._device,
|
||||||
compute_type=self._compute_type)
|
compute_type=self._compute_type)
|
||||||
logger.debug("Loaded Whisper model")
|
logger.debug("Loaded Whisper model")
|
||||||
|
|||||||
Reference in New Issue
Block a user