nice-room-70150
10/29/2025, 6:07 AMtall-airline-16756
10/29/2025, 6:07 AMtall-airline-16756
10/29/2025, 6:07 AMdef _send_frame_to_moondream(self, frame):
try:
rgb_frame = frame.convert(proto_video.VideoBufferType.RGB24)
image = Image.frombytes("RGB", (rgb_frame.width, rgb_frame.height), rgb_frame.data.tobytes())
caption = self._md_model.caption(image).get("caption")
return caption
except Exception as exc:
logger.error("Error sending frame to Moondream: %s", exc)
return None
async def on_user_turn_completed(self, turn_ctx, new_message):
if self._latest_frame:
caption = self._send_frame_to_moondream(self._latest_frame)
if caption:
new_message.content.append(f"[Image description: {caption}]")
self._latest_frame = None # Clear frame after use
This way, the image won’t be stored in the context window at all. If you have any questions or would like me to walk you through more examples, just let me know—I’m here to help!
Sources: complex-agents/vision/README.md | README.md