from flo_ai.agent import AgentBuilder
from flo_ai.llm import OpenAI
from flo_ai.models import UserMessage, ImageMessageContent, DocumentMessageContent
import base64
agent = (
AgentBuilder()
.with_name('Multi-Modal Assistant')
.with_prompt('You can analyze images and documents.')
.with_llm(OpenAI(model='gpt-4o'))
.build()
)
# Load image
with open('screenshot.png', 'rb') as f:
image_base64 = base64.b64encode(f.read()).decode('utf-8')
# Load document
with open('spec.pdf', 'rb') as f:
doc_base64 = base64.b64encode(f.read()).decode('utf-8')
# Multi-modal conversation
response = await agent.run([
UserMessage(content="I need help with this:"),
UserMessage(
content=ImageMessageContent(
base64=image_base64,
mime_type="image/png"
)
),
UserMessage(
content=DocumentMessageContent(
base64=doc_base64,
mime_type="application/pdf"
)
),
UserMessage(content="Compare the image with the document.")
])