openai-chat

1.4.0 • Public • Published

AI chat (from openai.com)

Example Usage

import { ChatChannel } from './index.js'

const TOKEN = 'sk-...'
const options = {
  name: 'marv', //bot's name
  context: 2, //Recommended value. Corresponds to 4 messages of context
  prompt: 'You are Marv. Marv likes banter and can be quite rude'
}

const channel = new ChatChannel(TOKEN, options)

// Here used in conjunction with a simple CLI-making module `basic-repl`

import {repl} from 'basic-repl'

const name = process.argv[2] || 'user'

repl('['+name+'] ', input => {
	return channel.get(input, name).then(res => console.log(res))
})

//It's possible to give the bot some system messages, to, for example, clarify information or give new instructions on how to behave
//Note that system messages, just like user messages, are temporary and eventually fall out of the context window
repl('[system] ', input => channel.system(input))

More info: https://openai.com

Pricing: https://openai.com/api/pricing (gpt-3.5-turbo-instruct)

This software is provided as a wrapper / tool for OpenAI's API. We do not claim responsibility for anything outputs it produces, or any charges it incurs on yourself.

Readme

Keywords

none

Package Sidebar

Install

npm i openai-chat

Weekly Downloads

5

Version

1.4.0

License

ISC

Unpacked Size

11.5 kB

Total Files

3

Last publish

Collaborators

  • blobkat