> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Weave

> 将 Agno 与 WandB 的 Weave 集成，以发送跟踪信息并深入了解您的代理性能。

## 集成 Agno 与 WandB 的 Weave

[Weights & Biases (WandB) 的 Weave](https://weave-docs.wandb.ai/) 提供了一个强大的平台用于记录和可视化模型调用。通过将 Agno 与 Weave 集成，您可以跟踪和分析您的代理性能和行为。

## 先决条件

1. **安装 Weave**

   确保您已安装 Weave 包：

   ```bash theme={null}
   pip install weave
   ```

2. **身份验证**
   访问 [WandB](https://wandb.ai) 并复制您的 API 密钥
   ```bash theme={null}
   export WANDB_API_KEY=<your-api-key>
   ```

## 使用 Weave 记录模型调用

此示例演示如何使用 Weave 来记录模型调用。

```python theme={null}
import weave
from agno.agent import Agent
from agno.models.openai import OpenAIChat

# 使用您的项目名称初始化 Weave
weave.init("agno")

# 创建并配置代理
agent = Agent(model=OpenAIChat(id="gpt-4o"), markdown=True, debug_mode=True)

# 定义一个运行代理的函数，并用 weave.op() 进行装饰
@weave.op()
def run(content: str):
    return agent.run(content)

# 使用该函数记录一个模型调用
run("分享一个两句话的恐怖故事")
```

## 注意事项

* **环境变量**: 确保您的环境变量已正确设置 WandB API 密钥。
* **初始化**: 调用 `weave.init("project-name")` 以您的项目名称初始化 Weave。
* **装饰器**: 使用 `@weave.op()` 来装饰您希望用 Weave 记录的函数。

通过遵循这些步骤，您可以有效地将 Agno 与 Weave 集成，从而实现对您 AI 代理模型调用的全面记录和可视化。
