先决条件
replicate 库。要安装 Replicate 客户端,请运行以下命令:
示例
下面的 Agent 将使用 Replicate 来生成用户请求的图像或视频。cookbook/tools/replicate_tool.py
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
export REPLICATE_API_TOKEN=***
replicate 库。要安装 Replicate 客户端,请运行以下命令:
pip install -U replicate
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.replicate import ReplicateTools
"""创建专门用于 Replicate AI 内容生成的 Agent"""
image_agent = Agent(
name="Image Generator Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[ReplicateTools(model="luma/photon-flash")],
description="You are an AI agent that can generate images using the Replicate API.",
instructions=[
"When the user asks you to create an image, use the `generate_media` tool to create the image.",
"Return the URL as raw to the user.",
"Don't convert image URL to markdown or anything else.",
],
markdown=True,
debug_mode=True,
show_tool_calls=True,
)
image_agent.print_response("Generate an image of a horse in the dessert.")
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
api_key | str | None | 如果您想手动提供 Replicate API 密钥。 |
model | str | minimax/video-01 | 要使用的 Replicate 模型。在 Replicate 平台上了解更多信息。 |
| 函数 | 说明 |
|---|---|
generate_media | 从提示生成图像或视频。输出取决于模型。 |