dv-pipecat-ai 0.0.75.dev883__py3-none-any.whl → 0.0.82.dev19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dv-pipecat-ai might be problematic. Click here for more details.
- {dv_pipecat_ai-0.0.75.dev883.dist-info → dv_pipecat_ai-0.0.82.dev19.dist-info}/METADATA +8 -3
- {dv_pipecat_ai-0.0.75.dev883.dist-info → dv_pipecat_ai-0.0.82.dev19.dist-info}/RECORD +121 -80
- pipecat/adapters/base_llm_adapter.py +44 -6
- pipecat/adapters/services/anthropic_adapter.py +302 -2
- pipecat/adapters/services/aws_nova_sonic_adapter.py +40 -2
- pipecat/adapters/services/bedrock_adapter.py +40 -2
- pipecat/adapters/services/gemini_adapter.py +276 -6
- pipecat/adapters/services/open_ai_adapter.py +88 -7
- pipecat/adapters/services/open_ai_realtime_adapter.py +39 -1
- pipecat/audio/dtmf/__init__.py +0 -0
- pipecat/audio/dtmf/dtmf-0.wav +0 -0
- pipecat/audio/dtmf/dtmf-1.wav +0 -0
- pipecat/audio/dtmf/dtmf-2.wav +0 -0
- pipecat/audio/dtmf/dtmf-3.wav +0 -0
- pipecat/audio/dtmf/dtmf-4.wav +0 -0
- pipecat/audio/dtmf/dtmf-5.wav +0 -0
- pipecat/audio/dtmf/dtmf-6.wav +0 -0
- pipecat/audio/dtmf/dtmf-7.wav +0 -0
- pipecat/audio/dtmf/dtmf-8.wav +0 -0
- pipecat/audio/dtmf/dtmf-9.wav +0 -0
- pipecat/audio/dtmf/dtmf-pound.wav +0 -0
- pipecat/audio/dtmf/dtmf-star.wav +0 -0
- pipecat/audio/dtmf/types.py +47 -0
- pipecat/audio/dtmf/utils.py +70 -0
- pipecat/audio/filters/aic_filter.py +199 -0
- pipecat/audio/utils.py +9 -7
- pipecat/extensions/ivr/__init__.py +0 -0
- pipecat/extensions/ivr/ivr_navigator.py +452 -0
- pipecat/frames/frames.py +156 -43
- pipecat/pipeline/llm_switcher.py +76 -0
- pipecat/pipeline/parallel_pipeline.py +3 -3
- pipecat/pipeline/service_switcher.py +144 -0
- pipecat/pipeline/task.py +68 -28
- pipecat/pipeline/task_observer.py +10 -0
- pipecat/processors/aggregators/dtmf_aggregator.py +2 -2
- pipecat/processors/aggregators/llm_context.py +277 -0
- pipecat/processors/aggregators/llm_response.py +48 -15
- pipecat/processors/aggregators/llm_response_universal.py +840 -0
- pipecat/processors/aggregators/openai_llm_context.py +3 -3
- pipecat/processors/dtmf_aggregator.py +0 -2
- pipecat/processors/filters/stt_mute_filter.py +0 -2
- pipecat/processors/frame_processor.py +18 -11
- pipecat/processors/frameworks/rtvi.py +17 -10
- pipecat/processors/metrics/sentry.py +2 -0
- pipecat/runner/daily.py +137 -36
- pipecat/runner/run.py +1 -1
- pipecat/runner/utils.py +7 -7
- pipecat/serializers/asterisk.py +145 -0
- pipecat/serializers/exotel.py +1 -1
- pipecat/serializers/plivo.py +1 -1
- pipecat/serializers/telnyx.py +1 -1
- pipecat/serializers/twilio.py +1 -1
- pipecat/services/__init__.py +2 -2
- pipecat/services/anthropic/llm.py +113 -28
- pipecat/services/asyncai/tts.py +4 -0
- pipecat/services/aws/llm.py +82 -8
- pipecat/services/aws/tts.py +0 -10
- pipecat/services/aws_nova_sonic/aws.py +5 -0
- pipecat/services/azure/llm.py +77 -1
- pipecat/services/cartesia/tts.py +28 -16
- pipecat/services/cerebras/llm.py +15 -10
- pipecat/services/deepgram/stt.py +8 -0
- pipecat/services/deepseek/llm.py +13 -8
- pipecat/services/elevenlabs/__init__.py +2 -0
- pipecat/services/elevenlabs/stt.py +351 -0
- pipecat/services/fireworks/llm.py +13 -8
- pipecat/services/fish/tts.py +8 -6
- pipecat/services/gemini_multimodal_live/gemini.py +5 -0
- pipecat/services/gladia/config.py +7 -1
- pipecat/services/gladia/stt.py +23 -15
- pipecat/services/google/llm.py +159 -59
- pipecat/services/google/llm_openai.py +18 -3
- pipecat/services/grok/llm.py +2 -1
- pipecat/services/llm_service.py +38 -3
- pipecat/services/mem0/memory.py +2 -1
- pipecat/services/mistral/llm.py +5 -6
- pipecat/services/nim/llm.py +2 -1
- pipecat/services/openai/base_llm.py +88 -26
- pipecat/services/openai/image.py +6 -1
- pipecat/services/openai_realtime_beta/openai.py +5 -2
- pipecat/services/openpipe/llm.py +6 -8
- pipecat/services/perplexity/llm.py +13 -8
- pipecat/services/playht/tts.py +9 -6
- pipecat/services/rime/tts.py +1 -1
- pipecat/services/sambanova/llm.py +18 -13
- pipecat/services/sarvam/tts.py +415 -10
- pipecat/services/speechmatics/stt.py +4 -4
- pipecat/services/tavus/video.py +1 -1
- pipecat/services/tts_service.py +15 -5
- pipecat/services/vistaar/llm.py +2 -5
- pipecat/transports/base_input.py +32 -19
- pipecat/transports/base_output.py +39 -5
- pipecat/transports/daily/__init__.py +0 -0
- pipecat/transports/daily/transport.py +2371 -0
- pipecat/transports/daily/utils.py +410 -0
- pipecat/transports/livekit/__init__.py +0 -0
- pipecat/transports/livekit/transport.py +1042 -0
- pipecat/transports/network/fastapi_websocket.py +12 -546
- pipecat/transports/network/small_webrtc.py +12 -922
- pipecat/transports/network/webrtc_connection.py +9 -595
- pipecat/transports/network/websocket_client.py +12 -481
- pipecat/transports/network/websocket_server.py +12 -487
- pipecat/transports/services/daily.py +9 -2334
- pipecat/transports/services/helpers/daily_rest.py +12 -396
- pipecat/transports/services/livekit.py +12 -975
- pipecat/transports/services/tavus.py +12 -757
- pipecat/transports/smallwebrtc/__init__.py +0 -0
- pipecat/transports/smallwebrtc/connection.py +612 -0
- pipecat/transports/smallwebrtc/transport.py +936 -0
- pipecat/transports/tavus/__init__.py +0 -0
- pipecat/transports/tavus/transport.py +770 -0
- pipecat/transports/websocket/__init__.py +0 -0
- pipecat/transports/websocket/client.py +494 -0
- pipecat/transports/websocket/fastapi.py +559 -0
- pipecat/transports/websocket/server.py +500 -0
- pipecat/transports/whatsapp/__init__.py +0 -0
- pipecat/transports/whatsapp/api.py +345 -0
- pipecat/transports/whatsapp/client.py +364 -0
- {dv_pipecat_ai-0.0.75.dev883.dist-info → dv_pipecat_ai-0.0.82.dev19.dist-info}/WHEEL +0 -0
- {dv_pipecat_ai-0.0.75.dev883.dist-info → dv_pipecat_ai-0.0.82.dev19.dist-info}/licenses/LICENSE +0 -0
- {dv_pipecat_ai-0.0.75.dev883.dist-info → dv_pipecat_ai-0.0.82.dev19.dist-info}/top_level.txt +0 -0
|
@@ -34,6 +34,7 @@ from pipecat.frames.frames import (
|
|
|
34
34
|
FunctionCallFromLLM,
|
|
35
35
|
InputAudioRawFrame,
|
|
36
36
|
InterimTranscriptionFrame,
|
|
37
|
+
LLMContextFrame,
|
|
37
38
|
LLMFullResponseEndFrame,
|
|
38
39
|
LLMFullResponseStartFrame,
|
|
39
40
|
LLMTextFrame,
|
|
@@ -322,6 +323,10 @@ class AWSNovaSonicLLMService(LLMService):
|
|
|
322
323
|
|
|
323
324
|
if isinstance(frame, OpenAILLMContextFrame):
|
|
324
325
|
await self._handle_context(frame.context)
|
|
326
|
+
elif isinstance(frame, LLMContextFrame):
|
|
327
|
+
raise NotImplementedError(
|
|
328
|
+
"Universal LLMContext is not yet supported for AWS Nova Sonic."
|
|
329
|
+
)
|
|
325
330
|
elif isinstance(frame, InputAudioRawFrame):
|
|
326
331
|
await self._handle_input_audio_frame(frame)
|
|
327
332
|
elif isinstance(frame, BotStoppedSpeakingFrame):
|
pipecat/services/azure/llm.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#
|
|
2
1
|
# Copyright (c) 2024–2025, Daily
|
|
3
2
|
#
|
|
4
3
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
@@ -6,9 +5,14 @@
|
|
|
6
5
|
|
|
7
6
|
"""Azure OpenAI service implementation for the Pipecat AI framework."""
|
|
8
7
|
|
|
8
|
+
from typing import Any, Dict, List, Optional
|
|
9
|
+
|
|
9
10
|
from loguru import logger
|
|
10
11
|
from openai import AsyncAzureOpenAI
|
|
12
|
+
from openai._streaming import AsyncStream
|
|
13
|
+
from openai.types.chat import ChatCompletionChunk, ChatCompletionMessageParam
|
|
11
14
|
|
|
15
|
+
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
|
12
16
|
from pipecat.services.openai.llm import OpenAILLMService
|
|
13
17
|
|
|
14
18
|
|
|
@@ -17,6 +21,16 @@ class AzureLLMService(OpenAILLMService):
|
|
|
17
21
|
|
|
18
22
|
This service extends OpenAILLMService to connect to Azure's OpenAI endpoint while
|
|
19
23
|
maintaining full compatibility with OpenAI's interface and functionality.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
api_key: The API key for accessing Azure OpenAI.
|
|
28
|
+
endpoint: The Azure endpoint URL.
|
|
29
|
+
model: The model identifier to use.
|
|
30
|
+
api_version: Azure API version. Defaults to "2024-09-01-preview".
|
|
31
|
+
reasoning_effort: If provided for reasoning models, sets the effort (e.g. "minimal").
|
|
32
|
+
**kwargs: Additional keyword arguments passed to OpenAILLMService.
|
|
33
|
+
|
|
20
34
|
"""
|
|
21
35
|
|
|
22
36
|
def __init__(
|
|
@@ -26,6 +40,7 @@ class AzureLLMService(OpenAILLMService):
|
|
|
26
40
|
endpoint: str,
|
|
27
41
|
model: str,
|
|
28
42
|
api_version: str = "2024-09-01-preview",
|
|
43
|
+
reasoning_effort: Optional[str] = None,
|
|
29
44
|
**kwargs,
|
|
30
45
|
):
|
|
31
46
|
"""Initialize the Azure LLM service.
|
|
@@ -41,6 +56,7 @@ class AzureLLMService(OpenAILLMService):
|
|
|
41
56
|
# will call create_client() and we need those values there.
|
|
42
57
|
self._endpoint = endpoint
|
|
43
58
|
self._api_version = api_version
|
|
59
|
+
self._reasoning_effort = reasoning_effort
|
|
44
60
|
super().__init__(api_key=api_key, model=model, **kwargs)
|
|
45
61
|
|
|
46
62
|
def create_client(self, api_key=None, base_url=None, **kwargs):
|
|
@@ -62,3 +78,63 @@ class AzureLLMService(OpenAILLMService):
|
|
|
62
78
|
api_version=self._api_version,
|
|
63
79
|
azure_deployment=azure_deployment,
|
|
64
80
|
)
|
|
81
|
+
|
|
82
|
+
def _is_reasoning_model(self) -> bool:
|
|
83
|
+
"""Check if the current model supports reasoning parameters.
|
|
84
|
+
|
|
85
|
+
Based on search results:
|
|
86
|
+
- GPT-5, GPT-5-mini, and GPT-5-nano are reasoning models
|
|
87
|
+
- GPT-5-chat is a standard chat model that doesn't use reasoning by default
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
True if model supports reasoning parameters.
|
|
91
|
+
"""
|
|
92
|
+
model_name_lower = self.model_name.lower()
|
|
93
|
+
|
|
94
|
+
# Reasoning-capable models
|
|
95
|
+
reasoning_models = {"gpt-5-nano", "gpt-5", "gpt-5-mini"}
|
|
96
|
+
return model_name_lower in reasoning_models
|
|
97
|
+
|
|
98
|
+
async def get_chat_completions(
|
|
99
|
+
self, context: OpenAILLMContext, messages: List[ChatCompletionMessageParam]
|
|
100
|
+
) -> AsyncStream[ChatCompletionChunk]:
|
|
101
|
+
"""Get streaming chat completions from Azure OpenAI API.
|
|
102
|
+
|
|
103
|
+
Handles both reasoning and standard models according to Azure AI Foundry documentation.
|
|
104
|
+
Reasoning models use automatic chain of thought and have parameter limitations.
|
|
105
|
+
"""
|
|
106
|
+
params = {
|
|
107
|
+
"model": self.model_name,
|
|
108
|
+
"stream": True,
|
|
109
|
+
"messages": messages,
|
|
110
|
+
"tools": context.tools,
|
|
111
|
+
"tool_choice": context.tool_choice,
|
|
112
|
+
"stream_options": {"include_usage": True},
|
|
113
|
+
"max_tokens": self._settings["max_tokens"],
|
|
114
|
+
"max_completion_tokens": self._settings["max_completion_tokens"],
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if self._is_reasoning_model():
|
|
118
|
+
# Reasoning models generally do NOT support temperature, presence_penalty, top_p
|
|
119
|
+
if self._reasoning_effort:
|
|
120
|
+
params["reasoning_effort"] = self._reasoning_effort
|
|
121
|
+
if self._settings.get("seed"):
|
|
122
|
+
params["seed"] = self._settings["seed"]
|
|
123
|
+
else:
|
|
124
|
+
# Standard models support all parameters
|
|
125
|
+
params.update(
|
|
126
|
+
{
|
|
127
|
+
"frequency_penalty": self._settings["frequency_penalty"],
|
|
128
|
+
"presence_penalty": self._settings["presence_penalty"],
|
|
129
|
+
"seed": self._settings["seed"],
|
|
130
|
+
"temperature": self._settings["temperature"],
|
|
131
|
+
"top_p": self._settings["top_p"],
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Add any extra parameters from settings
|
|
136
|
+
extra_params = self._settings.get("extra", {})
|
|
137
|
+
params.update(extra_params)
|
|
138
|
+
|
|
139
|
+
chunks = await self._client.chat.completions.create(**params)
|
|
140
|
+
return chunks
|
pipecat/services/cartesia/tts.py
CHANGED
|
@@ -10,7 +10,7 @@ import base64
|
|
|
10
10
|
import json
|
|
11
11
|
import uuid
|
|
12
12
|
import warnings
|
|
13
|
-
from typing import AsyncGenerator, List, Optional, Union
|
|
13
|
+
from typing import AsyncGenerator, List, Literal, Optional, Union
|
|
14
14
|
|
|
15
15
|
from loguru import logger
|
|
16
16
|
from pydantic import BaseModel, Field
|
|
@@ -102,7 +102,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|
|
102
102
|
|
|
103
103
|
Parameters:
|
|
104
104
|
language: Language to use for synthesis.
|
|
105
|
-
speed: Voice speed control
|
|
105
|
+
speed: Voice speed control.
|
|
106
106
|
emotion: List of emotion controls.
|
|
107
107
|
|
|
108
108
|
.. deprecated:: 0.0.68
|
|
@@ -110,7 +110,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|
|
110
110
|
"""
|
|
111
111
|
|
|
112
112
|
language: Optional[Language] = Language.EN
|
|
113
|
-
speed: Optional[
|
|
113
|
+
speed: Optional[Literal["slow", "normal", "fast"]] = None
|
|
114
114
|
emotion: Optional[List[str]] = []
|
|
115
115
|
|
|
116
116
|
def __init__(
|
|
@@ -272,11 +272,13 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|
|
272
272
|
voice_config["id"] = self._voice_id
|
|
273
273
|
|
|
274
274
|
if self._settings["emotion"]:
|
|
275
|
-
warnings.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
with warnings.catch_warnings():
|
|
276
|
+
warnings.simplefilter("always")
|
|
277
|
+
warnings.warn(
|
|
278
|
+
"The 'emotion' parameter in __experimental_controls is deprecated and will be removed in a future version.",
|
|
279
|
+
DeprecationWarning,
|
|
280
|
+
stacklevel=2,
|
|
281
|
+
)
|
|
280
282
|
voice_config["__experimental_controls"] = {}
|
|
281
283
|
if self._settings["emotion"]:
|
|
282
284
|
voice_config["__experimental_controls"]["emotion"] = self._settings["emotion"]
|
|
@@ -387,7 +389,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|
|
387
389
|
await self._websocket.send(msg)
|
|
388
390
|
self._context_id = None
|
|
389
391
|
|
|
390
|
-
async def
|
|
392
|
+
async def _process_messages(self):
|
|
391
393
|
async for message in self._get_websocket():
|
|
392
394
|
msg = json.loads(message)
|
|
393
395
|
if not msg or not self.audio_context_available(msg["context_id"]):
|
|
@@ -421,6 +423,14 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|
|
421
423
|
else:
|
|
422
424
|
logger.error(f"{self} error, unknown message type: {msg}")
|
|
423
425
|
|
|
426
|
+
async def _receive_messages(self):
|
|
427
|
+
while True:
|
|
428
|
+
await self._process_messages()
|
|
429
|
+
# Cartesia times out after 5 minutes of innactivity (no keepalive
|
|
430
|
+
# mechanism is available). So, we try to reconnect.
|
|
431
|
+
logger.debug(f"{self} Cartesia connection was disconnected (timeout?), reconnecting")
|
|
432
|
+
await self._connect_websocket()
|
|
433
|
+
|
|
424
434
|
@traced_tts
|
|
425
435
|
async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:
|
|
426
436
|
"""Generate speech from text using Cartesia's streaming API.
|
|
@@ -472,7 +482,7 @@ class CartesiaHttpTTSService(TTSService):
|
|
|
472
482
|
|
|
473
483
|
Parameters:
|
|
474
484
|
language: Language to use for synthesis.
|
|
475
|
-
speed: Voice speed control
|
|
485
|
+
speed: Voice speed control.
|
|
476
486
|
emotion: List of emotion controls.
|
|
477
487
|
|
|
478
488
|
.. deprecated:: 0.0.68
|
|
@@ -480,7 +490,7 @@ class CartesiaHttpTTSService(TTSService):
|
|
|
480
490
|
"""
|
|
481
491
|
|
|
482
492
|
language: Optional[Language] = Language.EN
|
|
483
|
-
speed: Optional[
|
|
493
|
+
speed: Optional[Literal["slow", "normal", "fast"]] = None
|
|
484
494
|
emotion: Optional[List[str]] = Field(default_factory=list)
|
|
485
495
|
|
|
486
496
|
def __init__(
|
|
@@ -600,11 +610,13 @@ class CartesiaHttpTTSService(TTSService):
|
|
|
600
610
|
voice_config = {"mode": "id", "id": self._voice_id}
|
|
601
611
|
|
|
602
612
|
if self._settings["emotion"]:
|
|
603
|
-
warnings.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
613
|
+
with warnings.catch_warnings():
|
|
614
|
+
warnings.simplefilter("always")
|
|
615
|
+
warnings.warn(
|
|
616
|
+
"The 'emotion' parameter in voice.__experimental_controls is deprecated and will be removed in a future version.",
|
|
617
|
+
DeprecationWarning,
|
|
618
|
+
stacklevel=2,
|
|
619
|
+
)
|
|
608
620
|
voice_config["__experimental_controls"] = {"emotion": self._settings["emotion"]}
|
|
609
621
|
|
|
610
622
|
await self.start_ttfb_metrics()
|
pipecat/services/cerebras/llm.py
CHANGED
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
from typing import List
|
|
10
10
|
|
|
11
11
|
from loguru import logger
|
|
12
|
-
from openai.types.chat import ChatCompletionMessageParam
|
|
13
12
|
|
|
14
|
-
from pipecat.
|
|
13
|
+
from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams
|
|
15
14
|
from pipecat.services.openai.llm import OpenAILLMService
|
|
16
15
|
|
|
17
16
|
|
|
@@ -27,7 +26,7 @@ class CerebrasLLMService(OpenAILLMService):
|
|
|
27
26
|
*,
|
|
28
27
|
api_key: str,
|
|
29
28
|
base_url: str = "https://api.cerebras.ai/v1",
|
|
30
|
-
model: str = "
|
|
29
|
+
model: str = "gpt-oss-120b",
|
|
31
30
|
**kwargs,
|
|
32
31
|
):
|
|
33
32
|
"""Initialize the Cerebras LLM service.
|
|
@@ -35,7 +34,7 @@ class CerebrasLLMService(OpenAILLMService):
|
|
|
35
34
|
Args:
|
|
36
35
|
api_key: The API key for accessing Cerebras's API.
|
|
37
36
|
base_url: The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1".
|
|
38
|
-
model: The model identifier to use. Defaults to "
|
|
37
|
+
model: The model identifier to use. Defaults to "gpt-oss-120b".
|
|
39
38
|
**kwargs: Additional keyword arguments passed to OpenAILLMService.
|
|
40
39
|
"""
|
|
41
40
|
super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs)
|
|
@@ -54,25 +53,31 @@ class CerebrasLLMService(OpenAILLMService):
|
|
|
54
53
|
logger.debug(f"Creating Cerebras client with api {base_url}")
|
|
55
54
|
return super().create_client(api_key, base_url, **kwargs)
|
|
56
55
|
|
|
57
|
-
def build_chat_completion_params(
|
|
58
|
-
self, context: OpenAILLMContext, messages: List[ChatCompletionMessageParam]
|
|
59
|
-
) -> dict:
|
|
56
|
+
def build_chat_completion_params(self, params_from_context: OpenAILLMInvocationParams) -> dict:
|
|
60
57
|
"""Build parameters for Cerebras chat completion request.
|
|
61
58
|
|
|
62
59
|
Cerebras supports a subset of OpenAI parameters, focusing on core
|
|
63
60
|
completion settings without advanced features like frequency/presence penalties.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
params_from_context: Parameters, derived from the LLM context, to
|
|
64
|
+
use for the chat completion. Contains messages, tools, and tool
|
|
65
|
+
choice.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Dictionary of parameters for the chat completion request.
|
|
64
69
|
"""
|
|
65
70
|
params = {
|
|
66
71
|
"model": self.model_name,
|
|
67
72
|
"stream": True,
|
|
68
|
-
"messages": messages,
|
|
69
|
-
"tools": context.tools,
|
|
70
|
-
"tool_choice": context.tool_choice,
|
|
71
73
|
"seed": self._settings["seed"],
|
|
72
74
|
"temperature": self._settings["temperature"],
|
|
73
75
|
"top_p": self._settings["top_p"],
|
|
74
76
|
"max_completion_tokens": self._settings["max_completion_tokens"],
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
# Messages, tools, tool_choice
|
|
80
|
+
params.update(params_from_context)
|
|
81
|
+
|
|
77
82
|
params.update(self._settings["extra"])
|
|
78
83
|
return params
|
pipecat/services/deepgram/stt.py
CHANGED
|
@@ -276,6 +276,14 @@ class DeepgramSTTService(STTService):
|
|
|
276
276
|
async def _disconnect(self):
|
|
277
277
|
if self._connection.is_connected:
|
|
278
278
|
self.logger.debug("Disconnecting from Deepgram")
|
|
279
|
+
# Deepgram swallows asyncio.CancelledError internally which prevents
|
|
280
|
+
# proper cancellation propagation. This issue was found with
|
|
281
|
+
# parallel pipelines where `CancelFrame` was not awaited for to
|
|
282
|
+
# finish in all branches and it was pushed downstream reaching the
|
|
283
|
+
# end of the pipeline, which caused `cleanup()` to be called while
|
|
284
|
+
# Deepgram disconnection was still finishing and therefore
|
|
285
|
+
# preventing the task cancellation that occurs during `cleanup()`.
|
|
286
|
+
# GH issue: https://github.com/deepgram/deepgram-python-sdk/issues/570
|
|
279
287
|
await self._connection.finish()
|
|
280
288
|
|
|
281
289
|
async def start_metrics(self):
|
pipecat/services/deepseek/llm.py
CHANGED
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
from typing import List
|
|
10
10
|
|
|
11
11
|
from loguru import logger
|
|
12
|
-
from openai.types.chat import ChatCompletionMessageParam
|
|
13
12
|
|
|
14
|
-
from pipecat.
|
|
13
|
+
from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams
|
|
15
14
|
from pipecat.services.openai.llm import OpenAILLMService
|
|
16
15
|
|
|
17
16
|
|
|
@@ -54,19 +53,22 @@ class DeepSeekLLMService(OpenAILLMService):
|
|
|
54
53
|
logger.debug(f"Creating DeepSeek client with api {base_url}")
|
|
55
54
|
return super().create_client(api_key, base_url, **kwargs)
|
|
56
55
|
|
|
57
|
-
def _build_chat_completion_params(
|
|
58
|
-
self, context: OpenAILLMContext, messages: List[ChatCompletionMessageParam]
|
|
59
|
-
) -> dict:
|
|
56
|
+
def _build_chat_completion_params(self, params_from_context: OpenAILLMInvocationParams) -> dict:
|
|
60
57
|
"""Build parameters for DeepSeek chat completion request.
|
|
61
58
|
|
|
62
59
|
DeepSeek doesn't support some OpenAI parameters like seed and max_completion_tokens.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
params_from_context: Parameters, derived from the LLM context, to
|
|
63
|
+
use for the chat completion. Contains messages, tools, and tool
|
|
64
|
+
choice.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Dictionary of parameters for the chat completion request.
|
|
63
68
|
"""
|
|
64
69
|
params = {
|
|
65
70
|
"model": self.model_name,
|
|
66
71
|
"stream": True,
|
|
67
|
-
"messages": messages,
|
|
68
|
-
"tools": context.tools,
|
|
69
|
-
"tool_choice": context.tool_choice,
|
|
70
72
|
"stream_options": {"include_usage": True},
|
|
71
73
|
"frequency_penalty": self._settings["frequency_penalty"],
|
|
72
74
|
"presence_penalty": self._settings["presence_penalty"],
|
|
@@ -75,5 +77,8 @@ class DeepSeekLLMService(OpenAILLMService):
|
|
|
75
77
|
"max_tokens": self._settings["max_tokens"],
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
# Messages, tools, tool_choice
|
|
81
|
+
params.update(params_from_context)
|
|
82
|
+
|
|
78
83
|
params.update(self._settings["extra"])
|
|
79
84
|
return params
|