Skip to main content

A toolkit for building composable interactive data driven applications.

Project description

Weave by Weights & Biases

Open in Colab Stable Version Download Stats Github Checks codecov

Weave is a toolkit for developing Generative AI applications, built by Weights & Biases.


You can use Weave 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

Our goal is to bring rigor, best-practices, and composability to the inherently experimental process of developing Generative AI software, without introducing cognitive overhead.

Documentation

Our documentation site can be found here.

Prerequisites

Quick Start

  1. Install Weave:

    pip install weave
    
  2. Import and initialize:

    import weave
    weave.init("my-project-name")
    
  3. Trace your functions:

    @weave.op()
    def my_function():
        # Your tracked code!
        pass
    

Usage

Tracing

You can trace any function using weave.op() - from api calls to OpenAI, Anthropic, Google AI Studio etc to generation calls from Hugging Face and other open source models to any other validation functions or data transformations in your code you'd like to keep track of.

Decorate all the functions you want to trace, this will generate a trace tree of the inputs and outputs of all your functions:

import weave
weave.init("weave-example")

@weave.op()
def sum_nine(value_one: int):
    return value_one + 9

@weave.op()
def multiply_two(value_two: int):
    return value_two * 2

@weave.op()
def main():
    output = sum_nine(3)
    final_output = multiply_two(output)
    return final_output

main()

Fuller Example

import weave
import json
from openai import OpenAI

@weave.op()
def extract_fruit(sentence: str) -> dict:
    client = OpenAI()

    response = client.chat.completions.create(
    model="gpt-3.5-turbo-1106",
    messages=[
        {
            "role": "system",
            "content": "You will be provided with unstructured data, and your task is to parse it one JSON dictionary with fruit, color and flavor as keys."
        },
        {
            "role": "user",
            "content": sentence
        }
        ],
        temperature=0.7,
        response_format={ "type": "json_object" }
    )
    extracted = response.choices[0].message.content
    return json.loads(extracted)

weave.init('intro-example')

sentence = "There are many fruits that were found on the recently discovered planet Goocrux. There are neoskizzles that grow there, which are purple and taste like candy."

extract_fruit(sentence)

Contributing

Interested in pulling back the hood or contributing? Awesome, before you dive in, here's what you need to know.

We're in the process of 🧹 cleaning up 🧹. This codebase contains a large amount code for the "Weave engine" and "Weave boards", which we've put on pause as we focus on Tracing and Evaluations.

The Weave Tracing code is mostly in: weave/trace and weave/trace_server.

The Weave Evaluations code is mostly in weave/flow.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weave-0.52.7.tar.gz (525.7 kB view details)

Uploaded Source

Built Distribution

weave-0.52.7-py3-none-any.whl (671.1 kB view details)

Uploaded Python 3

File details

Details for the file weave-0.52.7.tar.gz.

File metadata

  • Download URL: weave-0.52.7.tar.gz
  • Upload date:
  • Size: 525.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weave-0.52.7.tar.gz
Algorithm Hash digest
SHA256 49e2409a950c249b28fc8c23f2641bbe88a543447eac8cb9f449ff1970a95307
MD5 813767102b488fb86df32dd1b691bcca
BLAKE2b-256 024c366ebebc2c73d0e7667770e7278e9ea1015b8ebab699bc8dc8b0804a48a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for weave-0.52.7.tar.gz:

Publisher: release.yaml on wandb/weave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file weave-0.52.7-py3-none-any.whl.

File metadata

  • Download URL: weave-0.52.7-py3-none-any.whl
  • Upload date:
  • Size: 671.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weave-0.52.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f019f2017789123acc5b7800190ec5871b5a741e287df30662cce949b45b1950
MD5 949a4f6866045e1bcdde7ae3eca3dda6
BLAKE2b-256 4ea4dc7b057ce719046dae3e2824394ffe325eecdca915384d5851276e7c205d

See more details on using hashes here.

Provenance

The following attestation bundles were made for weave-0.52.7-py3-none-any.whl:

Publisher: release.yaml on wandb/weave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page