Skip to main content

Weavel Python SDK

Prompt Optimization & Evaluation for LLM Applications

Installation

pip install weavel

Documentation

You can find our full documentation here.

How to use

Option 1: Using OpenAI wrapper

from weavel import WeavelOpenAI as OpenAI

openai = OpenAI()

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, world!"}
    ],
    headers={
      "generation_name": "hello",
    }
)

Option 2: Logging inputs/outputs of LLM calls

from weavel import Weavel
from openai import OpenAI
from pydantic import BaseModel

openai = OpenAI()
# initialize Weavel
weavel = Weavel()

class Answer(BaseModel):
    reasoning: str
    answer: str

question = "What is x if x + 2 = 4?"
response = openai.beta.chat.completions.parse(
    model="gpt-4o-2024-08-06",
    messages=[
        {"role": "system", "content": "You are a math teacher."},
        {"role": "user", "content": question}
    ],
    response_format=Answer
).choices[0].message.parsed

# log the generation
weavel.generation(
    name="solve-math", # optional
    inputs={"question": question},
    outputs=response.model_dump()
)

Option 3 (Advanced Usage): OTEL-compatible trace logging

from weavel import Weavel

weavel = Weavel()

session = weavel.session(user_id = "UNIQUE_USER_ID")

session.message(
    role="user",
    content="Nice to meet you!"
)

session.track(
    name="Main Page Viewed"
)

trace = session.trace(
    name="retrieval_module"
)

trace.log(
    name="google_search"
)

Metadata

Release files for weavel 1.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weavel 1.11.0
File Size Uploaded Provenance Actions
weavel-1.11.0.tar.gz 28.0 kB Without provenance Details for weavel-1.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for weavel 1.11.0
File Interpreter ABI Platform Actions
weavel-1.11.0-py3-none-any.whl Python 3 none any Details for weavel-1.11.0-py3-none-any.whl

Total release size: 60.7 kB

Release files / weavel-1.11.0.tar.gz

Download URL weavel-1.11.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3d9373506a3486ffe54f5ece5813f19a1c37bd7297a7d2e10803da6852a8483c
BLAKE2b-256 checksum
How to use checksums
d6dcc9da0be2ab39a74fc7e95d9c6520ff18c48eb21a4d59d45afd5e702b29d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / weavel-1.11.0-py3-none-any.whl

Download URL weavel-1.11.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a048c28136e0f3bd65de264097c955c76180c2fd072fb662dd1a21f64514b54d
BLAKE2b-256 checksum
How to use checksums
d95677881b451e9ad509c1645eb294cb406df95c554e7a154096ad65984710dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Security for weavel 1.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.11.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page