Weave
Integrate Kern with Weave by WandB to send traces and gain insights into your agent's performance.
Integrating Kern with Weave by WandB
Weave by Weights & Biases (WandB) provides a powerful platform for logging and visualizing model calls. By integrating Kern with Weave, you can track and analyze your agent's performance and behavior.
Prerequisites
-
Install Weave
Ensure you have the Weave package installed:
1uv pip install weave -
Authentication Go to WandB and copy your API key
1export WANDB_API_KEY=<your-api-key>
Logging Model Calls with Weave
This example demonstrates how to use Weave to log model calls.
1import weave2from kern.agent import Agent3from kern.models.openai import OpenAIResponses45# Initialize Weave with your project name6weave.init("kern")78# Create and configure the agent9agent = Agent(model=OpenAIResponses(id="gpt-5.2"), markdown=True, debug_mode=True)1011# Define a function to run the agent, decorated with weave.op()12@weave.op()13def run(content: str):14 return agent.run(content)1516# Use the function to log a model call17run("Share a 2 sentence horror story")Notes
- Environment Variables: Ensure your environment variable is correctly set for the WandB API key.
- Initialization: Call
weave.init("project-name")to initialize Weave with your project name. - Decorators: Use
@weave.op()to decorate functions you want to log with Weave.
By following these steps, you can effectively integrate Kern with Weave, enabling comprehensive logging and visualization of your AI agents' model calls.