wip: video image frames

This commit is contained in:
Chad Bailey
2024-03-18 22:14:02 +00:00
parent 6d3c52ae81
commit 6c9425d66a
6 changed files with 210 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ from dailyai.pipeline.frames import (
Frame,
TextFrame,
TranscriptionQueueFrame,
VisionFrame
)
from abc import abstractmethod
@@ -133,6 +134,22 @@ class STTService(AIService):
yield TranscriptionQueueFrame(text, "", str(time.time()))
class VisionService(AIService):
def __init__(self):
super().__init__()
# Renders the image. Returns an Image object.
# TODO-CB: return type
@abstractmethod
async def run_vision(self, prompt: str, image: bytes):
pass
async def process_frame(self, frame: Frame) -> AsyncGenerator[Frame, None]:
if isinstance(frame, VisionFrame):
async for frame in self.run_vision(frame.prompt, frame.image):
yield frame
class FrameLogger(AIService):
def __init__(self, prefix="Frame", **kwargs):
super().__init__(**kwargs)