feat: support uploaded images in debug voice preview
Allow paste/drag temporary image assets so vision turns work without a live camera frame. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,6 +49,21 @@ def image_data_uri(frame: UserImageRawFrame) -> str:
|
||||
return f"data:image/jpeg;base64,{encoded}"
|
||||
|
||||
|
||||
def image_frame_from_jpeg(data: bytes) -> UserImageRawFrame:
|
||||
"""Decode one normalized uploaded JPEG into Pipecat's raw image frame."""
|
||||
|
||||
try:
|
||||
image = Image.open(BytesIO(data)).convert("RGB")
|
||||
image.load()
|
||||
except (OSError, ValueError) as exc:
|
||||
raise ValueError("上传图片无法解码") from exc
|
||||
return UserImageRawFrame(
|
||||
image=image.tobytes(),
|
||||
size=image.size,
|
||||
format="RGB",
|
||||
)
|
||||
|
||||
|
||||
async def analyze_image_with_vision_model(
|
||||
cfg: AssistantConfig,
|
||||
frame: UserImageRawFrame,
|
||||
|
||||
Reference in New Issue
Block a user