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.0rc4.tar.gz (994.7 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.0rc4-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc4.tar.gz
  • Upload date:
  • Size: 994.7 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.0rc4.tar.gz
Algorithm Hash digest
SHA256 28f77556e386b9b882c2311597d7671151151a22ba08e915bfd8994f4f368374
MD5 740c88ee6dc18f8b2c891681a2340278
BLAKE2b-256 afe8a109c348ea598bd320031f138c2c1e75a4cf27d5917911396722baa45a29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc4-py3-none-any.whl
  • Upload date:
  • Size: 54.6 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.0rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 907efa0cbf775ecfbea3a895e4bfa16a86171166c68c11dafac28d12867e9bf3
MD5 36b96ae4815598eeef0592c3463c5cc1
BLAKE2b-256 c56e0e3a89093c86a78af536435edef24e3cb907a91a9560a8b89ab9d78e7123

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