Skip to main content

Weave with TypeScript Quickstart Guide

You can use W&B Weave with Typescript to:
  • Log and debug language model inputs, outputs, and traces
  • Build rigorous, apples-to-apples evaluations for language model use cases
  • Organize all the information generated across the LLM workflow, from experimentation to evaluations to production
For more information, see the Weave documentation.

Function tracking

To use Weave in your Typescript code, initialize a new Weave project and add the weave.op wrapper to the functions you want to track. After adding weave.op and calling the function, visit the W&B dashboard to see it tracked within your project. We automatically track your code - check the code tab in the UI!
The following example shows how basic function tracking works.

OpenAI integration

Weave automatically tracks all OpenAI calls, including:
  • Token usage
  • API costs
  • Request/response pairs
  • Model configurations
In addition to OpenAI, Weave supports automatic logging of other LLM providers, such as Anthropic and Mistral. For the full list, see LLM Providers in the Integrations documentation.

Nested function tracking

Weave allows you to track complex workflows by combining multiple tracked functions and LLM calls while preserving the entire execution trace. The benefits of this include:
  • Full visibility into your application’s logic flow
  • Easy debugging of complex chains of operations
  • Performance optimization opportunities

Dataset management

You can create and manage datasets with Weave using the weave.Dataset class. Similar to Weave Models, weave.Dataset helps:
  • Track and version your data
  • Organize test cases
  • Share datasets between team members
  • Power systematic evaluations

Evaluation framework

Weave supports evaluation-driven development with the Evaluation class. Evaluations help you reliably iterate on your GenAI application. The Evaluation class does the following:
  • Assesses Model performance on a Dataset
  • Applies custom scoring functions
  • Generates detailed performance reports
  • Enables comparison between model versions
You can find a complete evaluation tutorial at http://wandb.me/weave_eval_tut
The following main function runs all demonstrations: