A Python library for tracking LLM and GenAI usage and sending the usage data to Doku
Project description
Doku Python SDK - dokumetry
Doku Python SDK (dokumetry
) empowers you to effortlessly track and monitor language learning model (LLM) usage data and metrics from your Python code. It seamlessly integrates with major LLM Platforms:
- ✅ OpenAI
- ✅ Anthropic
- ✅ Cohere
All LLM observability usage data is sent directly to the Doku Platform for streamlined tracking. Get started with Doku Python SDK for simplified and effective observability.
Features
-
User-friendly UI Logs: Log all your LLM requests in just two lines of code.
-
Cost and Latency Tracking: Track costs and latencies based on users and custom properties for better analysis.
-
Prompt and Response Feedback: Iterate on prompts and chat conversations directly in the UI.
-
Collaboration and Sharing: Share results and collaborate with friends or teammates for more effective teamwork.
-
Very Low Latency Impact We know latency of your Large-Language Model usage is important to your application's success, that's why we designed Doku SDKs to impact latency as little as possible.
Installation
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 URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "What is LLM Observability",
}
],
model="gpt-3.5-turbo",
)
Anthropic
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
import dokumetry
anthropic = Anthropic(
# defaults to os.environ.get("ANTHROPIC_API_KEY")
api_key="my api key",
)
# Pass the above `anthropic` object along with your Doku URL and API key and this will make sure that all Anthropic calls are automatically tracked.
dokumetry.init(llm=anthropic, doku_url="YOUR_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
completion = anthropic.completions.create(
model="claude-2",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} What is LLM Observability?{AI_PROMPT}",
)
print(completion.completion)
Cohere
import cohere
import dokumetry
# initialize the Cohere Client with an API Key
co = cohere.Client('YOUR_API_KEY')
# Pass the above `co` object along with your Doku URL and API key and this will make sure that all Cohere calls are automatically tracked.
dokumetry.init(llm=co, doku_url="YOUR_DOKU_URL", api_key="YOUR_DOKU_TOKEN")
# generate a prediction for a prompt
prediction = co.chat(message='What is LLM Observability?', 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 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
Contributing
We welcome contributions to the Doku Python Library (dokumetry
) project. Please refer to CONTRIBUTING for detailed guidelines on how you can participate.
License
Doku Python Library (dokumetry
) is available under the GPL-3.0 License.
Support
For support, issues, or feature requests, submit an issue through the GitHub issues associated with this repository.
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
Built Distribution
Hashes for dokumetry-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f18e654ace2d2a0ed957ddcf555de5a6b98d96834ade8164dce681a370adc464 |
|
MD5 | 9e2a0cbcddf48194f4db47e102df6da6 |
|
BLAKE2b-256 | 46ead24e6fdc4d29d1041966c99dd1bb814fbdc97cb80d1235dca924a89e8f5c |