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 🙏

© 2026 – Pkg Stats / Ryan Hefner

colloquy_chatbot

v0.11.2

Published

A more intuitive and consistent interface on top of existing chatbot APIs.

Readme

Colloquy

A more intuitive and consistent interface on top of existing chatbot APIs.

Installation

# Using npm
npm install colloquy_chatbot

# Using Bun
bun add colloquy_chatbot

# Using yarn
yarn add colloquy_chatbot

Quick Start

import { OpenAIBot, ClaudeBot, PromptFunction } from "colloquy_chatbot";

// Create a basic OpenAI chatbot
const openaiBot = new OpenAIBot({
  instructions: "You are a helpful assistant.",
});

// Or use Claude
const claudeBot = new ClaudeBot({
  instructions: "You are a helpful assistant.",
});

// Send a message and get a response
const response = await openaiBot.prompt("Hello, can you help me?");
console.log(response); // Bot's response

// Create a chatbot with function calling
function getWeather(location = "New York") {
  return `It's sunny in ${location}`;
}

const weatherBot = new OpenAIBot({
  instructions: "You can check the weather.",
  functions: [
    new PromptFunction(getWeather, {
      description: "Get the current weather for a location",
    }),
  ],
});

const weatherResponse = await weatherBot.prompt(
  "What's the weather like in Tokyo?",
);
console.log(weatherResponse);

Chatbot Types

OpenAIBot

The main chatbot implementation that uses OpenAI's API:

import { OpenAIBot } from "colloquy_chatbot";

const bot = new OpenAIBot({
  instructions: "You are a helpful assistant.", // Optional system message
});

const response = await bot.prompt("Hello!");
console.log(response);

// Access conversation history
console.log(bot.history);

ClaudeBot

The chatbot implementation that uses Anthropic's Claude API:

import { ClaudeBot } from "colloquy_chatbot";

const bot = new ClaudeBot({
  instructions: "You are a helpful assistant.", // Optional system message
});

const response = await bot.prompt("Hello!");
console.log(response);

// Access conversation history
console.log(bot.history);

EchoBot

A simple bot for testing that echoes back the input:

import { EchoBot } from "colloquy_chatbot";

const bot = new EchoBot();
const response = await bot.prompt("Hello!");
console.log(response); // "Hello!"

Custom Bots

Create your own bot by extending the ChatBot class:

import { ChatBot, BotMessage } from "colloquy_chatbot";

class ReverseBot extends ChatBot {
  async send_prompt(): Promise<BotMessage> {
    const lastMessage = this.history.at(-1);
    const reversed = lastMessage.text.split("").reverse().join("");
    return new BotMessage(reversed);
  }
}

const bot = new ReverseBot();
console.log(await bot.prompt("Hello")); // "olleH"

Function Calling

Colloquy makes it easy to enable function calling with both OpenAI and Claude:

With OpenAI

import { OpenAIBot, PromptFunction } from "colloquy_chatbot";

// Define a function
function calculateArea(length = 1, width = 1) {
  return length * width;
}

// Create a bot with the function
const bot = new OpenAIBot({
  functions: [
    new PromptFunction(calculateArea, {
      description: "Calculate the area of a rectangle",
      parameters: {
        length: { description: "The length of the rectangle" },
        width: { description: "The width of the rectangle" },
      },
    }),
  ],
});

// The AI can now use the function when appropriate
const response = await bot.prompt("What's the area of a 5x3 rectangle?");
console.log(response);

With Claude

import { ClaudeBot, PromptFunction } from "colloquy_chatbot";

// Define a function
function calculateArea(length = 1, width = 1) {
  return length * width;
}

// Create a bot with the function
const bot = new ClaudeBot({
  functions: [
    new PromptFunction(calculateArea, {
      description: "Calculate the area of a rectangle",
      parameters: {
        length: { description: "The length of the rectangle" },
        width: { description: "The width of the rectangle" },
      },
    }),
  ],
});

// Claude can now use the function when appropriate
const response = await bot.prompt("What's the area of a 5x3 rectangle?");
console.log(response);

It can infer a lot from the function definition itself:

  • It can determine the name from the name of the function
    • It understands both () => "foo" and function test() { return "foo" }, but only the latter has a name attached
  • Default parameters are used to infer the type when they are specified
    • Typescript annotations are stripped at runtime, but default parameters are always there

These inferences are there to make your life easier, but you can always override everything but parameter names like this:

new PromptFunction(calculateArea, {
  name: "some-other-name",
  description: "Calculate the area of a rectangle",
  parameters: {
    length: {
      type: "string",
      description: "The length of the rectangle",
    },
    width: {
      type: "number",
      description: "The width of the rectangle",
    },
  },
});

Positional arguments get translated into an object before being sent to OpenAI, so feel free to use them in your functions. The goal is to allow you to define functions in a way that is intuitive, while still translating into a form supported by the API.

Environment Variables

  • OPENAI_API_KEY: Required for using OpenAIBot
  • ANTHROPIC_API_KEY: Required for using ClaudeBot

License

MIT