services: moved request_image_frame() to LLMService

This commit is contained in:
Aleix Conchillo Flaqué
2024-08-17 23:59:38 -07:00
parent 6520f20ffe
commit ef0d0531fa
2 changed files with 5 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ from pipecat.frames.frames import (
TTSSpeakFrame,
TTSVoiceUpdateFrame,
TextFrame,
UserImageRequestFrame,
VisionImageRawFrame
)
from pipecat.processors.async_frame_processor import AsyncFrameProcessor
@@ -143,6 +144,10 @@ class LLMService(AIService):
elif None in self._start_callbacks.keys():
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):
def __init__(

View File

@@ -240,10 +240,6 @@ class AnthropicLLMService(LLMService):
if 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:
return int(len(re.split(r'[^\w]+', text)) * 1.3)