Skip to main content

Python SDK for LangWatch for monitoring your LLMs

Project description

LangWatch Python SDK

Go to https://langwatch.ai to setup your account.

To trace OpenAI calls:

from openai import OpenAI
+ import langwatch.openai

client = OpenAI()

+ with langwatch.openai.OpenAITracer(client):
    completion = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[
            {
                "role": "system",
                "content": "You are a helpful assistant that only reply in short tweet-like responses, using lots of emojis.",
            },
            {"role": "user", "content": message},
        ],
        stream=True,
    )

To trace LangChain agent:

+ import langwatch.langchain

  # ...

  chain = LLMChain(
      llm=ChatOpenAI(),
      prompt=chat_prompt,
      output_parser=CommaSeparatedListOutputParser(),
  )
+ with langwatch.langchain.LangChainTracer() as langWatchCallback:
-   result = chain.run(text="colors")
+   result = chain.run(text="colors", callbacks=[langWatchCallback])

Project details


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.0.31.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

langwatch-0.0.31-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file langwatch-0.0.31.tar.gz.

File metadata

  • Download URL: langwatch-0.0.31.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for langwatch-0.0.31.tar.gz
Algorithm Hash digest
SHA256 41f72ffd0cc40eaa615e12813792e594da6adb5fb927f76a050f3e7a8cc06dc4
MD5 499b18129fa57f988ab61a9fd21d3ff4
BLAKE2b-256 5a9e35f41331f60edd7ac9ee3a5284331ef684a6fb80243da2657bb73925ce47

See more details on using hashes here.

File details

Details for the file langwatch-0.0.31-py3-none-any.whl.

File metadata

  • Download URL: langwatch-0.0.31-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for langwatch-0.0.31-py3-none-any.whl
Algorithm Hash digest
SHA256 83aad43bf26838043cfdf5c5c7430a5502bd442e70ad9726c845ba20f7b658c2
MD5 a3e9a6f0e14b727598bec5750f6d93e2
BLAKE2b-256 2660bb48e6af9e99e8a277244891e723d004cfc5b4dd88e59756dc301a6546c8

See more details on using hashes here.

Supported by

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