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

chathub-adapter

v1.3.0

Published

A package for using different chat-focused llms seamlessly

Downloads

14

Readme

ChatHub - Adapter

A simple-to-use, one-for-all SDK for interacting with trending LLM models.

Key Features

  • All-In-One SDK: use only one package to talk to ChatGPT, GPT-4, Claude-2, Claude-Instant, and PaLM at once

  • Universal conversation: conversations may be used across different LLMs, e.g.switching from ChatGPT to Claude during one conversation.

  • Conversation storage: conversations stored in local file system, with customizable cache directory and simple, black-boxed method for manipulation.

  • Conversation setup: customize your conversation context for role-playing, scenario enacting .etc

Installation & Use

Install

Run npm i chathub-adapter.

Use

To use this package, you will first need to import the ChatHub class and instantiate it.

import { ChatHub } from "chathub-adapter";

const Hub = new ChatHub(
 // Required. If there are multiple models, load them all in the array
 [{ model: `YourModelNameHere`, APIKey: `YourAPIKeyHere` }]
);

// To send a message
const response = await Hub.sendMessage(`Hello there!`, `YourDesiredModel`);
// If you are using `ChatGPT`, you can expect `General Kenobi!`
console.log(response.text);

// Continuing a conversation
const anotherResponse = await Hub.sendMessage(`How are you?`, `YourDesiredModel`, {
 // Pass the corresponding `conversationId`
 conversationId: response.conversationId
});
console.log(anotherResponse.text);

Types and Interfaces

Currently supported models: ChatGPT, GPT-4, Claude-v1, Claude-v2, Claude-Instant,ChatPaLM2.

Please note that this package will not grant you access to models you previously have no access to. e.g. Using this package will not allow you to use GPT-4 if your account is not valid to use its API.

|Type Name|Allow Contents| |:---:|:----| |ModelOptions|Names of all supported models (case sensitive)| |ChatOptions|Properties: conversationId, context, and systemMessage| |ModelConfig|Configuration for your model, has two properties: model and APIKey.| |Conversation|The interface in which conversation messages and their corresponding id| |ConversationMessage|Properties: role and content. role allows user, system, and assistant; content is string| |conversationId|A UUID v4 for identifying conversations| |context|A general context in which the conversation takes place| |systemMessage|A information-prompting message for LLM, used to provide contextual information that should not be mentioned by the user|

Class and Methods

The main exported class for managing conversations and models is ChatHub.

ChatHub has the following public methods

Class ChatHub

|Method Name|Parameters|Return Value|Function| |:-----:|:-----:|:-----:|:-----| |constructor|config, cacheDir|An instance of ChatHub|Instantiate a ChatHub class| |sendMessage|text,model,options|ChatResponse|Send your message to designated model| |hasModel|model|boolean|Check whether a certain model is activated in the ChatHub instance| |getAllModels|none|IterableIterator<ModelOptions>|An iterator for all instantiated models| |generateText|prompt|Promise<string>|The generated text with TextPaLM(currently only supports TextPaLM)|

Class ConversationManager

If you want to import/export or manage your conversation in some other ways, you can instantiate a ConversationManager. Method are named as clear as possible.


This package is still being updated, star the GitHub repo to stay tuned!