feat: persist photos and enrich conversation history
This commit is contained in:
@@ -30,8 +30,8 @@ def _require(value: str, label: str) -> str:
|
||||
raise ValueError(f"缺少模型资源配置: {label}")
|
||||
|
||||
|
||||
def image_data_uri(frame: UserImageRawFrame) -> str:
|
||||
"""Encode one Pipecat camera frame for a vision chat-completion request."""
|
||||
def image_jpeg_bytes(frame: UserImageRawFrame) -> bytes:
|
||||
"""Encode one Pipecat camera frame as a storage- and model-ready JPEG."""
|
||||
if not frame.format:
|
||||
raise ValueError("摄像头图片帧缺少 format,无法编码给视觉模型")
|
||||
buffer = BytesIO()
|
||||
@@ -40,7 +40,12 @@ def image_data_uri(frame: UserImageRawFrame) -> str:
|
||||
format="JPEG",
|
||||
quality=85,
|
||||
)
|
||||
encoded = base64.b64encode(buffer.getvalue()).decode("utf-8")
|
||||
return buffer.getvalue()
|
||||
|
||||
|
||||
def image_data_uri(frame: UserImageRawFrame) -> str:
|
||||
"""Encode one Pipecat camera frame for a vision chat-completion request."""
|
||||
encoded = base64.b64encode(image_jpeg_bytes(frame)).decode("utf-8")
|
||||
return f"data:image/jpeg;base64,{encoded}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user