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

plexchat

v1.4.1

Published

High throughput Azure OpenAI Chat Client

Downloads

24

Readme

Plexchat

High throughput Azure OpenAI Chat Client.

  • Compatible with Azure Open AI chat and embedding API
  • Instantiate one worker per API endpoint, with endpoint specific rate and token limit
  • Customizable tokenzier for either estimated (fast) or precise (slow) token length control
  • Built-in retry based on HTTP header and heuristics
  • Built-in queue for burst of traffic
  • Support streaming mode
  • Status API for usage monitoring

Get started

Install

npm i plexchat
import { plexchat } from "plexchat";

const { chatProxy, embedProxy } = plexchat({
  manifests: [
    {
      apiKey: "<Azure OpenAI Api Key>",
      endpoint: "https://<your-deployment>.openai.azure.com",
      models: [
        {
          deploymentName: "gpt-3.5-turbo",
          modelName: "gpt-3.5-turbo",
          contextWindow: 4_096,
          rpm: 1_242,
          tpm: 207_000,
        },
        {
          deploymentName: "gpt-3.5-turbo-16k",
          modelName: "gpt-3.5-turbo-16k",
          contextWindow: 16_384,
          rpm: 1_440,
          tpm: 240_000,
        },
        {
          deploymentName: "gpt-4",
          modelName: "gpt-4",
          contextWindow: 8_192,
          rpm: 60,
          tpm: 10_000,
        },
        {
          deploymentName: "gpt-4-32k",
          modelName: "gpt-4-32k",
          contextWindow: 32_768,
          rpm: 360,
          tpm: 60_000,
        },
        {
          deploymentName: "text-embedding-ada-002",
          modelName: "text-embedding-ada-002",
          contextWindow: 2_048,
          rpm: 720,
          tpm: 120_000,
        },
      ],
    },
  ],
});

chatProxy({
  messages: [
    {
      role: "system",
      content: `You are a computer scientist`,
    },
    {
      role: "user",
      content: `What is an algorithm?`,
    },
  ],
});

embedProxy(["Hello world", "Fizz buzz"]);

How does it work

We instantiate one worker for each endpoint. The worker polls the manager for task by announcing its current capacity. The capacity is based on:

  1. Token limit
  2. Rate limit
  3. Past consumption

The manager uses a queue to track user requests. Each user request is decorated with metadata about its demand:

  1. Prompt token consumption
  2. Max response token limit
  3. Model compatibility

The manager dispatches the task to the first polling worker that has a capacity that meets or exceeds the demand. When the worker finishes the task, the result is returned to the user. When the worker fails the task, the task is requeued until all retries are used up.

For user convenience, we provide a factory to instantiate the manager as Azure Open AI embed and chat proxies. We also provide a factory to instantiate the worker against Azure Open AI specific endpoints

Polling convention

  • Manager wakes up workers upon receiving every new task
  • Worker polls indefinitely, and goes to sleep after they received at least one task and finished all assigned tasks.

Future work

  • Customizable prioritization rules for the task queue
  • HTTP based remote workers
  • Docker-deployable HTTP server
  • Automatic rate limit detection by Azure Open AI admin API