weave.init(). This guide shows Python developers using ChatNVIDIA how to capture traces, wrap their own functions as Ops, and organize experiments with Weave’s Model class so they can debug, iterate on, and compare LLM applications more efficiently.
Tracing
Storing traces of LLM applications in a central database, both during development and in production, helps you debug issues and build a dataset of tricky examples to evaluate against while you improve your application. The following section shows how to enable automatic tracing for ChatNVIDIA calls.- Python
- TypeScript
Weave can automatically capture traces for the ChatNVIDIA Python library.Start capturing by calling After you run this code, Weave captures the ChatNVIDIA call under the project name you specified, where you can inspect the inputs, outputs, and metadata.
weave.init([PROJECT-NAME]) with a project name of your choice.
Track your own ops
- Python
- TypeScript
Wrapping a function with Navigate to Weave and click
@weave.op starts capturing inputs, outputs, and app logic so you can debug how data flows through your app. You can deeply nest ops and build a tree of functions that you want to track. This also starts automatic code versioning as you experiment to capture ad-hoc details that you haven’t committed to Git.Create a function decorated with @weave.op that calls into ChatNVIDIA Python library.In the following example, two functions are wrapped with op. This shows you how intermediate steps, like the retrieval step in a RAG app, affect how your app behaves.get_pokemon_data in the UI to see the inputs and outputs of that step.
Create a Model for easier experimentation
- Python
- TypeScript
Organizing experimentation is difficult when there are many moving pieces. By using the
Model class, you can capture and organize the experimental details of your app like your system prompt or the model you’re using. This helps you organize and compare different iterations of your app.In addition to versioning code and capturing inputs and outputs, Models capture structured parameters that control your application’s behavior, making it straightforward to find what parameters worked best. You can also use Weave Models with serve, and Evaluations.In the following example, you can experiment with model and system_message. Every time you change one of these, you get a new version of GrammarCorrectorModel.
Usage info
The following notes describe what the ChatNVIDIA integration supports. The ChatNVIDIA integration supportsinvoke, stream, and their async variants. It also supports tool use.
Because ChatNVIDIA is meant for use with many types of models, it doesn’t have function calling support.