services: moved request_image_frame() to LLMService
This commit is contained in:
@@ -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__(
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user