代码
from pathlib import Path
from agno.agent import Agent
from agno.media import Image
from agno.models.openai import OpenAIChat
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
agent_id="image-to-text",
name="图片转文字代理",
markdown=True,
debug_mode=True,
show_tool_calls=True,
instructions=[
"你是一个可以根据图像生成文字描述的 AI 代理。",
"你必须返回一个描述图像的文本响应。",
],
)
image_path = Path(__file__).parent.joinpath("sample.jpg")
agent.print_response(
"写一个关于这张图片的 3 句小说故事",
images=[Image(filepath=image_path)],
stream=True,
)