Skip to main content

LangWatch Python SDK, for monitoring your LLMs

Project description

LangWatch Python SDK ๐Ÿ

A Python SDK to monitor and observe your LLM applications using LangWatch.

[!CAUTION] This SDK is currently being developed and is not yet ready for production use. Please use the legacy SDK until this notice is removed.

Migration progress

Legend

  • โœ…: Complete
  • ๐Ÿšง: Migration in progress
  • โŒ: Pending migration
  • โšฐ: Deprecated
  • ๐Ÿ—‘๏ธ: Removed

Migration progress

Feature Status Tested Description
endpoint โœ… ๐Ÿ”„
api_key โœ… ๐Ÿ”„
enabled ๐Ÿ—‘๏ธ ๐Ÿ”„
sampling_rate โœ… ๐Ÿ”„
logger โœ… ๐Ÿ”„
trace โœ… ๐Ÿ”„
span โœ… ๐Ÿ”„
get_current_trace โœ… ๐Ÿ”„
get_current_span โœ… ๐Ÿ”„
create_span ๐Ÿ—‘๏ธ ๐Ÿ”„ This was marked for deprecation, and has been deprecated.
capture_rag ๐Ÿ—‘๏ธ ๐Ÿ”„ This was marked for deprecation, and has been deprecated.
langchain โœ… ๐Ÿ”„
dspy โœ… ๐Ÿ”„
login โŒ ๐Ÿ”„
evaluations โœ… ๐Ÿ”„
guardrails โœ… ๐Ÿ”„
openai โœ… ๐Ÿ”„
litellm โœ… ๐Ÿ”„
ContextSpan โœ… ๐Ÿ”„
ContextSpan.update โœ… ๐Ÿ”„
ContextSpan.add_evaluation โœ… ๐Ÿ”„
ContextSpan.evaluate โœ… ๐Ÿ”„
ContextSpan.async_evaluate โœ… ๐Ÿ”„
ContextSpan.end โœ… ๐Ÿ”„
ContextTrace โœ… ๐Ÿ”„
ContextTrace.update โœ… ๐Ÿ”„
ContextTrace.add_evaluation โœ… ๐Ÿ”„
ContextTrace.evaluate โœ… ๐Ÿ”„
ContextTrace.async_evaluate โœ… ๐Ÿ”„
ContextTrace.deferred_send_spans ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.send_spans ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.append_span ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.get_parent_id ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.get_current_span โœ… ๐Ÿ”„
ContextTrace.set_current_span ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.reset_current_span ๐Ÿ—‘๏ธ ๐Ÿ”„
ContextTrace.get_langchain_callback โœ… ๐Ÿ”„
ContextTrace.autotrack_openai_calls โœ… ๐Ÿ”„
ContextTrace.autotrack_litellm_calls โœ… ๐Ÿ”„
ContextTrace.autotrack_dspy โœ… ๐Ÿ”„
ContextTrace.share โœ… ๐Ÿ”„
ContextTrace.unshare โœ… ๐Ÿ”„

Installation

pip install langwatch==0.3.0rc1

Usage

Set the following environment variables:

  • LANGWATCH_API_KEY: Your LangWatch API key.
  • LANGWATCH_ENDPOINT: Your LangWatch endpoint, this is only required if you are using a self-hosted LangWatch instance.
import langwatch
import os
from openai import OpenAI

@langwatch.trace()
def main():
    client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
    langwatch.get_current_trace().autotrack_openai_calls(client)

    # Any calls to OpenAI will now be tracked by LangWatch

Contributing

We welcome contributions to LangWatch! Here's how you can help:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run the tests (pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Please make sure to update tests as appropriate and follow our coding standards.

Support

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

langwatch-0.2.0rc6.tar.gz (996.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langwatch-0.2.0rc6-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

File details

Details for the file langwatch-0.2.0rc6.tar.gz.

File metadata

  • Download URL: langwatch-0.2.0rc6.tar.gz
  • Upload date:
  • Size: 996.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for langwatch-0.2.0rc6.tar.gz
Algorithm Hash digest
SHA256 6a7aff41f85ab6efd164202795456adece19aab5725d5373afb8ecd5f32bbb3c
MD5 88cd3f23ca83f3ac393364124ac9f50e
BLAKE2b-256 85ca23683feaecf9336deafff4c40bad112082970d83fa8fe0650e591aa4517e

See more details on using hashes here.

File details

Details for the file langwatch-0.2.0rc6-py3-none-any.whl.

File metadata

  • Download URL: langwatch-0.2.0rc6-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for langwatch-0.2.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 3a49736728f9946e8c5cb3654199b549e5cccf77aa71500fc8ea400654113222
MD5 5e5fdbb5f4041b2cc9a5ac921ad47c50
BLAKE2b-256 b9d94672ac1ff729bfebab76e913c81973dd89e26c4074b346edec20bfdaee34

See more details on using hashes here.

Supported by

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