Code Monkey home page Code Monkey logo

node-stablehorde's Introduction

node-stablehorde

Unofficial Node.js API client for Stable Horde.

Getting Started

Install the module:

npm install stablehorde
# or
yarn add stablehorde

Instantiate the client:

const { Client } = require('stablehorde');

const stablehorde = new Client({
  apiKey: 'your-api-key',
});

Async Mode

You can use the methods offered by the client object directly. When you do this, the polling logic is left to you.

// initiate a generation request
const request = await stablehorde.generateAsync({
  prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
}); // initiate a generation request

// check the status of the request
const status = await stablehorde.check(request);

// get the resulting generations
// you should only call this if the status object says the request is complete
// you can only send this request twice every minute
const generations = await stablehorde.generations(request);

Event Emitter Mode

You can also let the library handle the polling logic for you in an event emitter style. This is the recommended way to use the library.

const handler = client.newRequestHandler(10000); // poll every 10 seconds

handler.on('created', (request) => {
  console.log('request created', request);
});

handler.on('statusPolled', (status) => {
  console.log('status polled', status);
});

handler.on('finished', (generations) => {
  console.log('generations finished', generations);
});

handler.on('error', (err) => {
  console.error('error', err);
});

handler.generate({
  prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
});

Join The Horde!

Stable Horde is run by individuals all around the world. If you want to help out and reduce waiting times for everyone, consider joining the horde!

For Contributors

node-stablehorde is written in TypeScript, therefore, you have to compile it to JavaScript if you'd like to test your changes. You may do so using the following command:

npm run build

The library does not currently employ any unit testing measures, however, if you would like to contribute to the library, please make sure that your changes pass linting. You can run the following command to check:

npm run lint

License

MIT. Please read the LICENSE file for more information.

node-stablehorde's People

Contributors

jozsefsallai avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gpu-net

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.