hiveminded-js
v0.0.6
Published
Hiveminded JS
Downloads
24
Maintainers
Readme
HiveMindedJS
HiveMindedJS is a credit management system designed to help AI developers quickly build applications without worrying about credit management. It provides a simple and intuitive API to manage credits for different users and sessions.
Installation
npm install hiveminded-js
Quickstart
Import HiveMinded.
import HiveMinded from 'hiveminded-js';
Initialize your app at the root of your project.
HiveMinded.init({organizationID: '<--- YOUR-ORG --->', namespace: '<--- YOUR-APP --->'});
Create a session (1 per user).
const session = HiveMinded.createSession({userID: 'my-user'});
You can then manage credits for this session using the following methods:
session.consume(1); // Consume 1 credit
session.refund(1); // Refund 1 credit
sesion.credits(); // Returns number of credits assigned to the user.
Example
session.consume(1);
try {
// Your cool ai code here
//...
} catch (err) {
session.refund(1);
}