services: moved request_image_frame() to LLMService
This commit is contained in:
@@ -22,6 +22,7 @@ from pipecat.frames.frames import (
|
|||||||
TTSSpeakFrame,
|
TTSSpeakFrame,
|
||||||
TTSVoiceUpdateFrame,
|
TTSVoiceUpdateFrame,
|
||||||
TextFrame,
|
TextFrame,
|
||||||
|
UserImageRequestFrame,
|
||||||
VisionImageRawFrame
|
VisionImageRawFrame
|
||||||
)
|
)
|
||||||
from pipecat.processors.async_frame_processor import AsyncFrameProcessor
|
from pipecat.processors.async_frame_processor import AsyncFrameProcessor
|
||||||
@@ -143,6 +144,10 @@ class LLMService(AIService):
|
|||||||
elif None in self._start_callbacks.keys():
|
elif None in self._start_callbacks.keys():
|
||||||
return await self._start_callbacks[None](self, context, function_name)
|
return await self._start_callbacks[None](self, context, function_name)
|
||||||
|
|
||||||
|
async def request_image_frame(self, user_id: str, *, text_content: str | None = None):
|
||||||
|
await self.push_frame(UserImageRequestFrame(user_id=user_id, context=text_content),
|
||||||
|
FrameDirection.UPSTREAM)
|
||||||
|
|
||||||
|
|
||||||
class TTSService(AIService):
|
class TTSService(AIService):
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|||||||
@@ -240,10 +240,6 @@ class AnthropicLLMService(LLMService):
|
|||||||
if context:
|
if context:
|
||||||
await self._process_context(context)
|
await self._process_context(context)
|
||||||
|
|
||||||
async def request_image_frame(self, user_id: str, *, text_content: str = None):
|
|
||||||
await self.push_frame(UserImageRequestFrame(user_id=user_id, context=text_content),
|
|
||||||
FrameDirection.UPSTREAM)
|
|
||||||
|
|
||||||
def _estimate_tokens(self, text: str) -> int:
|
def _estimate_tokens(self, text: str) -> int:
|
||||||
return int(len(re.split(r'[^\w]+', text)) * 1.3)
|
return int(len(re.split(r'[^\w]+', text)) * 1.3)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user