This is an interactive notebook. You can run it locally or use the following links:
@weave.op. Tracing helps you inspect the inputs, outputs, and intermediate steps of LLM calls so you can debug and improve your applications. This tutorial targets developers who are new to Weave and want a minimal end-to-end example.
🔑 Prerequisites
Before you can begin tracing in Weave, complete the following prerequisites. These steps install the required SDKs, authenticate you with W&B and OpenAI, and initialize a project to send traces to.- Install the Weave SDK and log in with your API key.
- Install the OpenAI SDK and log in with your API key.
- Initialize your W&B project.
🐝 Run your first trace
The following code sample shows how to capture and visualize a trace in Weave using the@weave.op decorator. It defines a function called extract_fruit that sends a prompt to OpenAI’s GPT-4o to extract structured data (fruit, color, and flavor) from a sentence. By decorating the function with @weave.op, Weave automatically tracks the function execution, including inputs, outputs, and intermediate steps. When you call the function with a sample sentence, Weave saves the full trace and makes it viewable in the Weave UI.