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.0rc3.tar.gz (991.4 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.0rc3-py3-none-any.whl (54.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc3.tar.gz
  • Upload date:
  • Size: 991.4 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.0rc3.tar.gz
Algorithm Hash digest
SHA256 c97b5d2619372ce33ebe125c97feb815152a7ec7632849be6c05d4c686bbc028
MD5 bf4d9de79838ad549f90359d47d767f6
BLAKE2b-256 7597f5f6cd863c69c4f24ed5f327966d2727d2e4f07b2a9058b8e1ef69bb30fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 54.5 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.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 7aee4a176c065850fc71aa9d02ae29b18a62ffd86b7962cbe8cf3f35055d693b
MD5 18aad43a819bd32cad4045e309123b84
BLAKE2b-256 f1251e38b1ed675ae3eaf5112e029954be68bc4fe966270323eedd9d418cfaec

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