weave_op.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your API keys
4
Run the example
Save the code above as
weave_op.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Wrap an Agno agent run in a @weave.op() decorator to log calls to a Weave project.
"""
Weave Integration
=================
Demonstrates logging Agno model calls with Weave.
"""
import weave
from agno.agent import Agent
from agno.models.openai import OpenAIChat
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
weave.init("agno")
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(model=OpenAIChat(id="gpt-4o"), markdown=True, debug_mode=True)
@weave.op()
def run(content: str):
return agent.run(content)
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
run("Share a 2 sentence horror story")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno openai weave
Export your API keys
export OPENAI_API_KEY="your_openai_api_key_here"
export WANDB_API_KEY="your_wandb_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:WANDB_API_KEY="your_wandb_api_key_here"
Run the example
weave_op.py, then run:python weave_op.py
Was this page helpful?