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

Uploaded Python 3

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc5.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.0rc5.tar.gz
Algorithm Hash digest
SHA256 3e52d29a3a73cf7cbed9ac2602cdb3b329936fd7c22f80e0027e4404b165e4e7
MD5 f451cbc208402aa2ce76d4ef949b09ec
BLAKE2b-256 ea5eaf62b3fd7cb97dadf2ec42654082ee60712007ad71c7ef3095e68c77ac64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc5-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.0rc5-py3-none-any.whl
Algorithm Hash digest
SHA256 19473ec3f8dd6724f567d4c16dc05c79b9687d42d4aaef54cf78aa9bd51dbb39
MD5 12c29ffcc07c116b24fb4d8c707bcd73
BLAKE2b-256 6023aa0f51a858cb181c71f2fbc26468da062a5909fbe242f57ad9ff444557e0

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