npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dokumetry

v0.1.2

Published

An NPM Package for tracking OpenAI API calls and sending usage metrics to Doku

Downloads

6

Readme

Doku Node SDK - dokumetry

Doku NPM Package Documentation License Package Version GitHub Last Commit GitHub Contributors

Tests Linting CodeQL

Doku Node SDK (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

npm install dokumetry

⚡️ Quick Start

OpenAI

import OpenAI from 'openai';
import DokuMetry from 'dokumetry';

const openai = new OpenAI({
  apiKey: 'My API Key', // defaults to process.env["OPENAI_API_KEY"]
});

// Pass the above `openai` 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: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})

async function main() {
  const chatCompletion = await openai.chat.completions.create({
    messages: [{ role: 'user', content: 'What is LLM Observability and Monitoring?' }],
    model: 'gpt-3.5-turbo',
  });
}

main();

Anthropic

import Anthropic from '@anthropic-ai/sdk';
import DokuMetry from 'dokumetry';

const anthropic = new Anthropic({
  apiKey: 'my_api_key', // defaults to process.env["ANTHROPIC_API_KEY"]
});

// Pass the above `anthropic` 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: anthropic, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})

async function main() {
  const message = await anthropic.messages.create({
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'What is LLM Observability and Monitoring?' }],
    model: 'claude-3-opus-20240229',
  });

  console.log(message.content);
}

main();

Cohere

import { CohereClient } from "cohere-ai";
import DokuMetry from 'dokumetry';

const cohere = new CohereClient({
    apiKey: "YOUR_COHERE_API_KEY",
});

// Pass the above `cohere` 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: cohere, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})

(async () => {
    const prediction = await cohere.generate({
        prompt: "What is LLM Observability and Monitoring?",
        maxTokens: 100,
    });
    
    console.log("Received prediction", prediction);
})();

Supported Parameters

| Parameter | Description | Required | |-------------------|-----------------------------------------------------------|---------------| | llm | Language Learning Model (LLM) Object to track | Yes | | dokuUrl | URL of your Doku Instance | Yes | | apiKey | Your Doku API key | Yes | | environment | Custom environment tag to include in your metrics | Optional | | applicationName | Custom application name tag for your metrics | Optional | | skipResp | Skip response from the Doku Ingester for faster execution | Optional |

Error

To make it easier to follow the server errors caused by dokumetry, we have logged the errors like Dokumetry: Error transmitting Data: HTTP status 401, where Dokumetry is the application name in blue and the rest is the error in red.

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

The following runtimes are supported:

  • Node.js 18 LTS or later (non-EOL) versions.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.

Security

Doku NPM Package (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 NPM Package (dokumetry) project. Please refer to CONTRIBUTING for detailed guidelines on how you can participate.

License

Doku NPM Package (dokumetry) is available under the Apache-2.0 license.

Support

For support, issues, or feature requests, submit an issue through the GitHub issues associated with the Doku Repository and add dokumetry-node label.