chatflow.media
This module implements utility classes for formatting/printing agent messages.
- class agentopera.chatflow.media.PilImage(image: Image)[source]
Bases:
Image
image class based on PIL.
this class provides functions to create, convert and operate images, and can be used to exchange image data in the message system.
Example
Loading an image from a URL:
from agentopera.media import Image from PIL import Image as PILImage import aiohttp import asyncio async def from_url(url: str) -> Image: async with aiohttp.ClientSession() as session: async with session.get(url) as response: content = await response.read() return Image.from_pil(PILImage.open(BytesIO(content))) image = asyncio.run(from_url("https://example.com/image"))
- classmethod from_base64(base64_str: str) Image [source]
create image object from base64 encoded string
- property data_uri: str
get data uri of image