Skip to content

Latest commit

 

History

History
57 lines (46 loc) · 1.82 KB

README.md

File metadata and controls

57 lines (46 loc) · 1.82 KB

@navetacandra/deepinfra Documentation

Introduction

@navetacandra/deepinfra is a Node.js package that provides a DeepInfra API consumer with no APIKEY needed. This package is designed to be lightweight and does not use any additional dependencies.

Installation

To install the package, use npm:

npm install @navetacandra/deepinfra

Usage

Import the package

const { Conversation } = require('@navetacandra/deepinfra');

Create an instance of the Conversation class and initialize it

const conversation = new Conversation({ 
    history: [], // load conversation history
    stream: false, // if true, returns a stream of the response
    rewritedTo: '' // redirected URL to the DeepInfra API
});
await conversation.init(); // initialize the conversation

Set used model

console.log(conversation.models);
conversation.setModel('meta-llama/Meta-Llama-3.1-70B-Instruct');

Create completion

// asynchronously
console.log(await conversation.completion('Hello, how are you?'));

// or stream
conversation.on('chat', chat => console.log(chat));
conversation.on('completion', response => process.stdout.write(response));
conversation.completion('Hello, how are you?');

Registered events

conversation.on('chat', chat => console.log(chat)); // on new chat pushed
conversation.on('completion', response => process.stdout.write(response)); // on completion stream response
conversation.on('error', error => console.error(error)); // on error created

Examples

See the usage section for detailed examples on how to use this package, or see the examples folder in the repository.

No Dependencies

This package is designed to be lightweight and does not rely on any additional dependencies.