Code Monkey home page Code Monkey logo

ai_horde's Introduction

@zeldafan0225/ai_horde

This package allows you to communicate with the AI Horde API

DISCLAIMER: THIS PACKAGE/REPOSITORY IS IN NO WAY ASSOCIATED TO THE CREATORS OF AI HORDE

Versions 5.0.0 and later

Version 5.0.0 introduces some breaking changes:

  • Node 18.0.0 or higher is required
  • The way some things are exported is changed

It also features an internal restructure to reduce complexity and improve performance.

Bugs

To report bugs please open an issue on GitHub.

Features

  • Configurable Caching
  • Methods for all endpoints on the API V2
  • Default Token
  • Types with comments and explanations (TS)

Features that are currently missing

  • Ratelimit bucket

Contribute

I am always happy about contributions. You can contribute by forking this repository, updating or adding and then creating a pull request. You can contribute by adding new features, optimizing the currently existing code, adding examples or anything else I missed.

How to use

The package exports the class AIHorde which includes basically everything you need, when using typescript you can also export types. The package also exports constant values used in the hordes API request payloads

const { AIHorde } = require("@zeldafan0225/ai_horde");

/*
Create new instance of the ai_horde class to communicate with the rest API
You can configure which cache should contain the data for what time
You can also configure at what interval the cache is checking if there are any data that should be deleted

The class also takes a default token. This is helpful if you want to use this package only using your own token.
The token is not a required argument in any method.

A default API route is also in the contrictor for changing where the requests are directed to (e.g. when using a subdomain like https://test.aihorde.net)
*/
const ai_horde = new AIHorde({
  cache_interval: 1000 * 10,
  cache: {
    generations_check: 1000 * 30,
  },
  client_agent: "My-Project:v0.0.1:My-Contact"
});

// start the generation of an image with the given payload
const generation = await ai_horde.postAsyncImageGenerate({
  prompt: "The legend of Zelda",
});
console.log(generation);

// check the status of your generation using the generations id
const check = await ai_horde.getImageGenerationCheck(generation.id);
console.log(check);

See the auto-generated docs for more info on methods and parameters.

ai_horde's People

Contributors

cohee1207 avatar db0 avatar exatombe avatar mrloldev avatar slayerto avatar sliterok avatar thunder04 avatar zeldafan0225 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ai_horde's Issues

Unexpected error

https://github.com/ZeldaFan0225/ai_horde/blame/9f1a358045b2483ecf0fb667d82bf54d8d80c45e/index.ts#L147

This lead to an unexpected error in my code base :

 ⨯ unhandledRejection: SyntaxError: Unexpected token I in JSON at position 0
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)
    at successSteps (node:internal/deps/undici/undici:6636:27)
    at node:internal/deps/undici/undici:1236:60
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

It's look to be caused by the JSON.parse their (i'm pretty sure it's because of that module)

import es6

Hi , is it possible to use this lib in the browser, with ES6 import ?
Thxs

Adding the API KEY

Is there a way to add in our api key when sending the prompt? I'm getting the message 'Only Trusted users are allowed to perform this operation', so assume its asking for my key, but when trying to add it through the headers getting response 400

import statement does not work as expected

I am trying to add this package to a vitejs project which does not support commonjs modules, so I have to use import instead of require.

I would expect this to work
import AIHorde, { AIHordeInitOptions } from "@zeldafan0225/ai_horde";

But it seems all imports are part of the default import instead:

console.log("AIHorde", AIHorde);
console.log("AIHorde.AIHorde", AIHorde.AIHorde);
console.log("AIHorde.AIHorde.AIHorde", AIHorde.AIHorde.AIHorde);
image

This causes and error that the named export AIHorde is missing
import { AIHorde } from "@zeldafan0225/ai_horde";

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.