Package: dokumetry
Doku Python SDK - dokumetryDoku 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✅ CohereAll 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.FeaturesUser-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 ImpactWe 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.InstallationpipinstalldokumetryQuick Start ⚡️OpenAIfrom 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",
)Anthropicfrom 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)Cohereimport 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 ParametersParameterDescriptionRequiredllmLanguage Learning Model (LLM) Object to trackYesdoku_urlURL of your Doku InstanceYesapi_keyYour Doku API keyYesenvironmentCustom environment tag to include in your metricsOptionalapplication_nameCustom application name tag for your metricsOptionalskip_respSkip response from the Doku Ingester for faster executionOptionalSemantic VersioningThis package generally followsSemVerconventions, 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.RequirementsPython >= 3.7 is supported.If you are interested in other runtime environments, please open or upvote an issue on GitHub.SecurityDoku 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 ourSecurity PolicyContributingWe welcome contributions to the Doku Python Library (dokumetry) project. Please refer toCONTRIBUTINGfor detailed guidelines on how you can participate.LicenseDoku Python Library (dokumetry) is available under theApache-2.0 license.SupportFor support, issues, or feature requests, submit an issue through theGitHub issuesassociated with this repository.