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.0rc1.tar.gz (263.2 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.0rc1-py3-none-any.whl (52.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc1.tar.gz
  • Upload date:
  • Size: 263.2 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.0rc1.tar.gz
Algorithm Hash digest
SHA256 3d8876919d9d890ddee58f08241bb62597bbf5737ca963ac9e47191251103615
MD5 b1c0c1ac2ba4414651690af6fa65bc51
BLAKE2b-256 d17804d3683e26f0ec157a557be637756b932fef4b35e3fc673fa666752cd7ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langwatch-0.2.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 52.8 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.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 10e1c80588a37d0e8236aca68e568aca82e79df668c9c1d1c526cf551fd2684b
MD5 91eebc3d139e71995d9a5e24ea5c5604
BLAKE2b-256 5f01ac329c2245cb8ab4e16f58a023e5e87faeaee15f415ad9d35c6dfcaf2906

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