1.0.18 • Published 6 days ago

fullmetal-client v1.0.18

Weekly downloads
-
License
ISC
Repository
-
Last release
6 days ago

Installation

  1. npm install fullmetal-client

Usage

const io = require('socket.io')();
import Fullmetal from 'fullmetal-client';

const fullMetalConfig = {
  apiKey: process.env.FULLMETAL_API_KEY, // get apiKey from .env file
  name: process.env.APP_NAME, // get app name from .env file
};
const fullmetal = new Fullmetal(fullMetalConfig);
fullmetal.onResponse(async (response) => {
  // response= {token:'', completed:false, speed:10/s, elapsedTime:2s model:''Wizard-Vicuna-7B-Uncensored', refId: end-client-socket.id}
  io.to(response.refId).emit('response', response); // The particular page/browser tab from which the requested prompt fired can be found using refId.
});

// Handle error message to client side, if any
fullmetal.onError(async (response) => {
  io.to(response.refId).emit('error', response.message);
});

// Handle response queue number of prompt e.g Prompt successfully queued. There are 3 prompts ahead of you.
fullmetal.onResponseQueue(async (response) => {
  io.to(response.refId).emit('responseQueuedNumber', response.queuedNumber);
});

io.on('connection', async (socket) => {
  socket.on('prompt', async (data) => {
    await fullmetal.sendPrompt(
      data.prompt,
      socket.id,
      { model: data.model }
    );
  });
});

DEMO

Click here to see the sample code

1.0.18

6 days ago

1.0.16

19 days ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.2

7 months ago

1.0.7

7 months ago

1.0.5

7 months ago

1.0.3

7 months ago

1.0.0

9 months ago