# Doku Python SDK - dokumetry
[![Doku Python Package](https://img.shields.io/badge/Doku-orange)](https://github.com/dokulabs/doku)
[![Documentation](https://img.shields.io/badge/Documentation-orange?logo=Google-Docs&logoColor=white)](https://docs.dokulabs.com/)
[![License](https://img.shields.io/github/license/dokulabs/dokumetry-python?label=license&logo=github&color=f80&logoColor=fff%22%20alt=%22License)](https://github.com/dokulabs/dokumetry-python/blob/main/LICENSE)
[![Downloads](https://static.pepy.tech/badge/dokumetry/month)](https://pepy.tech/project/dokumetry)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/dokulabs/dokumetry-python)](https://github.com/dokulabs/dokumetry-python/pulse)
[![GitHub Contributors](https://img.shields.io/github/contributors/dokulabs/dokumetry-python)](https://github.com/dokulabs/dokumetry-python/graphs/contributors)
[![Library Version](https://img.shields.io/github/tag/dokulabs/dokumetry-python.svg?&label=Library%20Version&logo=python)](https://github.com/dokulabs/dokumetry-python/tags)
[![Tests](https://github.com/dokulabs/dokumetry-python/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/tests.yml)
[![Pylint](https://github.com/dokulabs/dokumetry-python/actions/workflows/pylint.yml/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/pylint.yml)
[![CodeQL](https://github.com/dokulabs/dokumetry-python/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/github-code-scanning/codeql)
[Doku Python SDK](https://pypi.org/project/dokumetry/) (`dokumetry`) is your workhorse for collecting and transmitting language learning model (LLM) usage data and metrics with zero added latency. Simplicity is at the core of `dokumetry`, enabling you to kickstart comprehensive LLM observability with just two lines of code. It’s designed to blend seamlessly into your projects, supporting integration with leading LLM platforms:
- ✅ OpenAI
- ✅ Anthropic
- ✅ Cohere
- ✅ Mistral
- ✅ Azure OpenAI
Deployed as the backbone for all your LLM monitoring needs, `dokumetry` channels crucial usage data directly to Doku, streamlining the tracking process. Unlock efficient and effective observability for your LLM applications with DokuMetry.
## 🔥 Features
- **Effortless Integration:** With `dokumetry`, observability comes easy. Elevate your LLM observability by integrating this powerhouse into your projects using just two lines of code.
- **Zero Latency Impact:** We value the performance of your applications. `dokumetry` is engineered to capture and send data without hampering your application’s speed, ensuring a seamless user experience.
- - **Customizable Data Labeling:** Enhance your LLM analytics with customizable environment and application tags. `dokumetry` allows you to append these labels to your data, offering you the capability to sift through your observability data with ease. Drill down and view metrics in Doku, segmented by these specific tags for a more insightful analysis.
## 💿 Installation
```bash
pip install dokumetry
```
## ⚡️ Quick Start
### OpenAI
```
from openai import OpenAI
import dokumetry
client = OpenAI(
api_key="YOUR_OPENAI_KEY"
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_INGESTER_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "What is LLM Observability and Monitoring?",
}
],
model="gpt-3.5-turbo",
)
```
### Anthropic
```
from anthropic import Anthropic
import dokumetry
client = Anthropic(
# This is the default and can be omitted
api_key="YOUR_ANTHROPIC_API_KEY",
)
# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all Anthropic calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_INGESTER_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
message = client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "What is LLM Observability and Monitoring?",
}
],
model="claude-3-opus-20240229",
)
print(message.content)
```
### Cohere
```
import cohere
import dokumetry
# initialize the Cohere Client with an API Key
co = cohere.Client('YOUR_COHERE_API_KEY')
# Pass the above `co` object along with your Doku Ingester URL and API key and this will make sure that all Cohere calls are automatically tracked.
dokumetry.init(llm=co, doku_url="YOUR_INGESTER_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
# generate a prediction for a prompt
prediction = co.chat(message='What is LLM Observability and Monitoring?', model='command')
# print the predicted text
print(f'Chatbot: {prediction.text}')
```
## Supported Parameters
| Parameter | Description | Required |
|-------------------|-----------------------------------------------------------|---------------|
| llm | Language Learning Model (LLM) Object to track | Yes |
| doku_url | URL of your Doku Instance | Yes |
| api_key | Your Doku API key | Yes |
| environment | Custom environment tag to include in your metrics | Optional |
| application_name | Custom application name tag for your metrics | Optional |
| skip_resp | Skip response from the Doku Ingester for faster execution | Optional |
## Semantic Versioning
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
Changes that only affect static types, without breaking runtime behavior.
Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals).
Changes that we do not expect to impact the vast majority of users in practice.
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
## Requirements
Python >= 3.7 is supported.
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
## Security
Doku Python Library (`dokumetry`) sends the observability data over HTTP/HTTPS to the Doku Ingester which uses key based authentication mechanism to ensure the security of your data. Be sure to keep your API keys confidential and manage permissions diligently. Refer to our [Security Policy](SECURITY)
## Contributing
We welcome contributions to the Doku Python Library (`dokumetry`) project. Please refer to [CONTRIBUTING](CONTRIBUTING) for detailed guidelines on how you can participate.
## License
Doku Python Library (`dokumetry`) is available under the [Apache-2.0 license](LICENSE).
## Support
For support, issues, or feature requests, submit an issue through the [GitHub issues](https://github.com/dokulabs/doku/issues) associated with the Doku Repository and add `dokumetry-python` label.
Raw data
{
"_id": null,
"home_page": "https://github.com/dokulabs/dokumetry-python",
"name": "dokumetry",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.7.1",
"maintainer_email": null,
"keywords": "openai, anthropic, claude, cohere, llm monitoring, observability, monitoring, gpt, Generative AI, chatGPT",
"author": "Doku Labs",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/7d/e5/bec982c1758df815f15647045748783124d3dc10a96f34b9014d44f80882/dokumetry-0.1.2.tar.gz",
"platform": null,
"description": "# Doku Python SDK - dokumetry\n\n[![Doku Python Package](https://img.shields.io/badge/Doku-orange)](https://github.com/dokulabs/doku)\n[![Documentation](https://img.shields.io/badge/Documentation-orange?logo=Google-Docs&logoColor=white)](https://docs.dokulabs.com/)\n[![License](https://img.shields.io/github/license/dokulabs/dokumetry-python?label=license&logo=github&color=f80&logoColor=fff%22%20alt=%22License)](https://github.com/dokulabs/dokumetry-python/blob/main/LICENSE)\n[![Downloads](https://static.pepy.tech/badge/dokumetry/month)](https://pepy.tech/project/dokumetry)\n[![GitHub Last Commit](https://img.shields.io/github/last-commit/dokulabs/dokumetry-python)](https://github.com/dokulabs/dokumetry-python/pulse)\n[![GitHub Contributors](https://img.shields.io/github/contributors/dokulabs/dokumetry-python)](https://github.com/dokulabs/dokumetry-python/graphs/contributors)\n\n[![Library Version](https://img.shields.io/github/tag/dokulabs/dokumetry-python.svg?&label=Library%20Version&logo=python)](https://github.com/dokulabs/dokumetry-python/tags)\n\n[![Tests](https://github.com/dokulabs/dokumetry-python/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/tests.yml)\n[![Pylint](https://github.com/dokulabs/dokumetry-python/actions/workflows/pylint.yml/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/pylint.yml)\n[![CodeQL](https://github.com/dokulabs/dokumetry-python/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/dokulabs/dokumetry-python/actions/workflows/github-code-scanning/codeql)\n\n[Doku Python SDK](https://pypi.org/project/dokumetry/) (`dokumetry`) is your workhorse for collecting and transmitting language learning model (LLM) usage data and metrics with zero added latency. Simplicity is at the core of `dokumetry`, enabling you to kickstart comprehensive LLM observability with just two lines of code. It\u2019s designed to blend seamlessly into your projects, supporting integration with leading LLM platforms:\n\n- \u2705 OpenAI\n- \u2705 Anthropic\n- \u2705 Cohere\n- \u2705 Mistral\n- \u2705 Azure OpenAI\n\nDeployed as the backbone for all your LLM monitoring needs, `dokumetry` channels crucial usage data directly to Doku, streamlining the tracking process. Unlock efficient and effective observability for your LLM applications with DokuMetry.\n\n## \ud83d\udd25 Features\n\n- **Effortless Integration:** With `dokumetry`, observability comes easy. Elevate your LLM observability by integrating this powerhouse into your projects using just two lines of code. \n\n- **Zero Latency Impact:** We value the performance of your applications. `dokumetry` is engineered to capture and send data without hampering your application\u2019s speed, ensuring a seamless user experience.\n\n- - **Customizable Data Labeling:** Enhance your LLM analytics with customizable environment and application tags. `dokumetry` allows you to append these labels to your data, offering you the capability to sift through your observability data with ease. Drill down and view metrics in Doku, segmented by these specific tags for a more insightful analysis.\n\n## \ud83d\udcbf Installation\n\n```bash\npip install dokumetry\n```\n\n## \u26a1\ufe0f Quick Start\n\n### OpenAI\n\n```\nfrom openai import OpenAI\nimport dokumetry\n\nclient = OpenAI(\n api_key=\"YOUR_OPENAI_KEY\"\n)\n\n# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.\ndokumetry.init(llm=client, doku_url=\"YOUR_INGESTER_DOKU_URL\", api_key=\"YOUR_DOKU_TOKEN\")\n\nchat_completion = client.chat.completions.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"What is LLM Observability and Monitoring?\",\n }\n ],\n model=\"gpt-3.5-turbo\",\n)\n```\n\n### Anthropic\n\n```\nfrom anthropic import Anthropic\nimport dokumetry\n\nclient = Anthropic(\n # This is the default and can be omitted\n api_key=\"YOUR_ANTHROPIC_API_KEY\",\n)\n\n# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all Anthropic calls are automatically tracked.\ndokumetry.init(llm=client, doku_url=\"YOUR_INGESTER_DOKU_URL\", api_key=\"YOUR_DOKU_TOKEN\")\n\nmessage = client.messages.create(\n max_tokens=1024,\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"What is LLM Observability and Monitoring?\",\n }\n ],\n model=\"claude-3-opus-20240229\",\n)\nprint(message.content)\n\n```\n\n### Cohere\n\n```\nimport cohere\nimport dokumetry\n\n# initialize the Cohere Client with an API Key\nco = cohere.Client('YOUR_COHERE_API_KEY')\n\n# Pass the above `co` object along with your Doku Ingester URL and API key and this will make sure that all Cohere calls are automatically tracked.\ndokumetry.init(llm=co, doku_url=\"YOUR_INGESTER_DOKU_URL\", api_key=\"YOUR_DOKU_TOKEN\")\n\n# generate a prediction for a prompt\nprediction = co.chat(message='What is LLM Observability and Monitoring?', model='command')\n\n# print the predicted text\nprint(f'Chatbot: {prediction.text}')\n```\n\n## Supported Parameters\n\n| Parameter | Description | Required |\n|-------------------|-----------------------------------------------------------|---------------|\n| llm | Language Learning Model (LLM) Object to track | Yes |\n| doku_url | URL of your Doku Instance | Yes |\n| api_key | Your Doku API key | Yes |\n| environment | Custom environment tag to include in your metrics | Optional |\n| application_name | Custom application name tag for your metrics | Optional |\n| skip_resp | Skip response from the Doku Ingester for faster execution | Optional |\n\n\n## Semantic Versioning\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\nChanges that only affect static types, without breaking runtime behavior.\nChanges to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals).\nChanges that we do not expect to impact the vast majority of users in practice.\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\n## Requirements\nPython >= 3.7 is supported.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Security\n\nDoku Python Library (`dokumetry`) sends the observability data over HTTP/HTTPS to the Doku Ingester which uses key based authentication mechanism to ensure the security of your data. Be sure to keep your API keys confidential and manage permissions diligently. Refer to our [Security Policy](SECURITY)\n\n## Contributing\n\nWe welcome contributions to the Doku Python Library (`dokumetry`) project. Please refer to [CONTRIBUTING](CONTRIBUTING) for detailed guidelines on how you can participate.\n\n## License\n\nDoku Python Library (`dokumetry`) is available under the [Apache-2.0 license](LICENSE).\n\n## Support\n\nFor support, issues, or feature requests, submit an issue through the [GitHub issues](https://github.com/dokulabs/doku/issues) associated with the Doku Repository and add `dokumetry-python` label.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for tracking LLM and GenAI usage and sending the usage data to Doku",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/dokulabs/dokumetry-python",
"Repository": "https://github.com/dokulabs/dokumetry-python"
},
"split_keywords": [
"openai",
" anthropic",
" claude",
" cohere",
" llm monitoring",
" observability",
" monitoring",
" gpt",
" generative ai",
" chatgpt"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fbda90e89e7f1cd1b39b1aaf08c39386e8331a9275fb6996951b59bd983d88ac",
"md5": "90d7604a2ad6034c6d4394fd75084839",
"sha256": "e539d21176787b2fbd763ad3ab7d1cd6c1341362428e01afe0aac3781e265b1c"
},
"downloads": -1,
"filename": "dokumetry-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "90d7604a2ad6034c6d4394fd75084839",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.7.1",
"size": 26740,
"upload_time": "2024-03-24T09:06:21",
"upload_time_iso_8601": "2024-03-24T09:06:21.593601Z",
"url": "https://files.pythonhosted.org/packages/fb/da/90e89e7f1cd1b39b1aaf08c39386e8331a9275fb6996951b59bd983d88ac/dokumetry-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7de5bec982c1758df815f15647045748783124d3dc10a96f34b9014d44f80882",
"md5": "63c7ca6f7d12a86403e2c0104e217d4d",
"sha256": "a517d3ff0c1b70fa59a656dced025a1565b38b6581aaa3150b68b2005c085605"
},
"downloads": -1,
"filename": "dokumetry-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "63c7ca6f7d12a86403e2c0104e217d4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.7.1",
"size": 17657,
"upload_time": "2024-03-24T09:06:22",
"upload_time_iso_8601": "2024-03-24T09:06:22.665021Z",
"url": "https://files.pythonhosted.org/packages/7d/e5/bec982c1758df815f15647045748783124d3dc10a96f34b9014d44f80882/dokumetry-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-24 09:06:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dokulabs",
"github_project": "dokumetry-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "dokumetry"
}