askllm

1.1.0 • Public • Published

AskLLM

A Node.js module for interacting with the OpenAI GPT-3 API.

Installation

To install the AskLLM module, use npm: npm install askllm

Usage

To use the AskLLM module, first import the class:

const AskLLM = require('AskLLM');

Then, create a new instance of the class with your API key:

    const chat = [
        { role: "system", content: "You are a helpful assistant. You will talk like a pirate." },
        { role: "user", content: "Can you help me?" },
        { role: "assistant", content: "Arrrr! Of course, me hearty! What can I do for ye?" },
        { role: "user", content: "What's the best way to train a parrot?" },
    ];
    const options = {
        temperature: 0.5,
        max_tokens: 1000,
        n: 1,
        stop: '\n',
    };
    const llm = new AskLLM(process.env.ENDPOINT, process.env.KEY, options)
    const completion = await llm.getCompletion(chat, options);
    console.log(completion);

API

new AskLLM(apiKey, url, options)

Creates a new instance of the AskLLM class.

  • apiKey (string): Your OpenAI API key.
  • url (string): The API endpoint URL.
  • options (object, optional): Additional options for the HTTP request.

async getCompletion(prompt, options)

Generates a text completion for the given prompt.

  • prompt (string): The prompt to generate a completion for.
  • options (object, optional): Additional options for the completion request.

Returns a Promise that resolves to the generated completion.

License

This module is licensed under the MIT License. See the LICENSE file for details.

Dependencies (1)

Dev Dependencies (8)

Package Sidebar

Install

npm i askllm

Weekly Downloads

3

Version

1.1.0

License

ISC

Unpacked Size

44.9 kB

Total Files

8

Last publish

Collaborators

  • megamanics