diff --git a/package-lock.json b/package-lock.json
index 94ce9514b..1c4873cbb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,15 @@
{
"name": "sillytavern",
- "version": "1.5.3",
+ "version": "1.5.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sillytavern",
- "version": "1.5.3",
+ "version": "1.5.4",
"license": "AGPL-3.0",
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
- "@zeldafan0225/ai_horde": "^4.0.1",
"axios": "^1.3.4",
"command-exists": "^1.2.9",
"compression": "^1",
@@ -419,11 +418,6 @@
"regenerator-runtime": "^0.13.3"
}
},
- "node_modules/@thunder04/supermap": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/@thunder04/supermap/-/supermap-3.0.2.tgz",
- "integrity": "sha512-SjlUrfe45mwiAgKZHRRhh+oHRwXsjrCg6NI2HJxymTJt+9SwJw422yse/A5lr5WBpTky6qEce+H6Ec1sytm93A=="
- },
"node_modules/@tokenizer/token": {
"version": "0.3.0",
"license": "MIT"
@@ -440,16 +434,6 @@
"node": ">=10.0.0"
}
},
- "node_modules/@zeldafan0225/ai_horde": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/@zeldafan0225/ai_horde/-/ai_horde-4.0.1.tgz",
- "integrity": "sha512-mf1cknnBYzKCvgH4KAkdVY3J7sLkR2b79W6I9ZEA2aJCyua28bpZzNaCDSHKKyaNj+0wyHViC+L53X32jw9pMg==",
- "dependencies": {
- "@thunder04/supermap": "^3.0.2",
- "centra": "^2.5.0",
- "esbuild": "^0.12.28"
- }
- },
"node_modules/accepts": {
"version": "1.3.8",
"license": "MIT",
@@ -637,11 +621,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/centra": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/centra/-/centra-2.6.0.tgz",
- "integrity": "sha512-dgh+YleemrT8u85QL11Z6tYhegAs3MMxsaWAq/oXeAmYJ7VxL3SI9TZtnfaEvNDMAPolj25FXIb3S+HCI4wQaQ=="
- },
"node_modules/cliui": {
"version": "8.0.1",
"license": "ISC",
@@ -893,15 +872,6 @@
"node": ">= 0.8"
}
},
- "node_modules/esbuild": {
- "version": "0.12.29",
- "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.12.29.tgz",
- "integrity": "sha512-w/XuoBCSwepyiZtIRsKsetiLDUVGPVw1E/R3VTFSecIy8UR7Cq3SOtwKHJMFoVqqVG36aGkzh4e8BvpO1Fdc7g==",
- "hasInstallScript": true,
- "bin": {
- "esbuild": "bin/esbuild"
- }
- },
"node_modules/escalade": {
"version": "3.1.1",
"license": "MIT",
diff --git a/package.json b/package.json
index 30bf2571b..5391cf508 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,6 @@
{
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
- "@zeldafan0225/ai_horde": "^4.0.1",
"axios": "^1.3.4",
"command-exists": "^1.2.9",
"compression": "^1",
@@ -42,7 +41,7 @@
"type": "git",
"url": "https://github.com/Cohee1207/SillyTavern.git"
},
- "version": "1.5.3",
+ "version": "1.5.4",
"scripts": {
"start": "node server.js"
},
diff --git a/readme.md b/readme.md
index 5b6a380fe..b8856e665 100644
--- a/readme.md
+++ b/readme.md
@@ -272,5 +272,6 @@ GNU Affero General Public License for more details.**
* KoboldAI Presets from KAI Lite:
* Noto Sans font by Google (OFL license)
* Icon theme by Font Awesome (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
+* AI Horde client library by ZeldaFan0225: https://github.com/ZeldaFan0225/ai_horde
* Linux startup script by AlpinDale
* Thanks paniphons for providing a FAQ document
diff --git a/server.js b/server.js
index 40263b2b6..7083bb49b 100644
--- a/server.js
+++ b/server.js
@@ -82,7 +82,7 @@ const allowKeysExposure = config.allowKeysExposure;
const axios = require('axios');
const tiktoken = require('@dqbd/tiktoken');
const WebSocket = require('ws');
-const AIHorde = require("@zeldafan0225/ai_horde");
+const AIHorde = require("./src/horde");
const ai_horde = new AIHorde({
client_agent: getVersion()?.agent || 'SillyTavern:UNKNOWN:Cohee#1207',
});
diff --git a/src/horde/LICENSE.md b/src/horde/LICENSE.md
new file mode 100644
index 000000000..7ffcddd31
--- /dev/null
+++ b/src/horde/LICENSE.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 ZeldaFan0225
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/src/horde/index.d.ts b/src/horde/index.d.ts
new file mode 100644
index 000000000..6c6283f21
--- /dev/null
+++ b/src/horde/index.d.ts
@@ -0,0 +1,2189 @@
+///
+import SuperMap from "@thunder04/supermap";
+import { IncomingMessage } from "http";
+declare enum ModelGenerationInputStableSamplers {
+ "k_lms" = "k_lms",
+ "k_heun" = "k_heun",
+ "k_euler" = "k_euler",
+ "k_dpm_2" = "k_dpm_2",
+ "k_dpm_2_a" = "k_dpm_2_a",
+ "DDIM" = "DDIM",
+ "PLMS" = "PLMS",
+ "k_dpm_fast" = "k_dpm_fast",
+ "k_dpm_adaptive" = "k_dpm_adaptive",
+ "k_dpmpp_2s_a" = "k_dpmpp_2s_a",
+ "k_dpmpp_2m" = "k_dpmpp_2m",
+ "dpmsolver" = "dpmsolver"
+}
+declare enum SourceImageProcessingTypes {
+ "img2img" = "img2img",
+ "inpainting" = "inpainting",
+ "outpainting" = "outpainting"
+}
+declare enum ModelGenerationInputPostProcessingTypes {
+ "GFPGAN" = "GFPGAN",
+ "RealESRGAN_x4plus" = "RealESRGAN_x4plus",
+ "CodeFormers" = "CodeFormers"
+}
+declare enum ModelInterrogationFormTypes {
+ "caption" = "caption",
+ "interrogation" = "interrogation",
+ "nsfw" = "nsfw",
+ "GFPGAN" = "GFPGAN",
+ "RealESRGAN_x4plus" = "RealESRGAN_x4plus",
+ "RealESRGAN_x4plus_anime_6B" = "RealESRGAN_x4plus_anime_6B",
+ "NMKD_Siax" = "NMKD_Siax",
+ "4x_AnimeSharp" = "4x_AnimeSharp",
+ "CodeFormers" = "CodeFormers",
+ "strip_background" = "strip_background"
+}
+declare enum HordeAsyncRequestStates {
+ "waiting" = "waiting",
+ "processing" = "processing",
+ "done" = "done",
+ "faulted" = "faulted",
+ "partial" = "partial",
+ "cancelled" = "cancelled"
+}
+declare enum ModelGenerationInputControlTypes {
+ "canny" = "canny",
+ "hed" = "hed",
+ "depth" = "depth",
+ "normal" = "normal",
+ "openpose" = "openpose",
+ "seg" = "seg",
+ "scribble" = "scribble",
+ "fakescribbles" = "fakescribbles",
+ "hough" = "hough"
+}
+declare class APIError extends Error {
+ rawError: RequestError;
+ status: number;
+ method: string;
+ url: string;
+ requestBody: any;
+ constructor(rawError: RequestError, core_res: IncomingMessage, requestBody?: any);
+ get name(): string;
+}
+declare class AIHorde {
+ #private;
+ static readonly ModelGenerationInputStableSamplers: typeof ModelGenerationInputStableSamplers;
+ readonly ModelGenerationInputStableSamplers: typeof ModelGenerationInputStableSamplers;
+ static readonly SourceImageProcessingTypes: typeof SourceImageProcessingTypes;
+ readonly SourceImageProcessingTypes: typeof SourceImageProcessingTypes;
+ static readonly ModelGenerationInputPostProcessingTypes: typeof ModelGenerationInputPostProcessingTypes;
+ readonly ModelGenerationInputPostProcessingTypes: typeof ModelGenerationInputPostProcessingTypes;
+ static readonly ModelGenerationInputControlTypes: typeof ModelGenerationInputControlTypes;
+ readonly ModelGenerationInputControlTypes: typeof ModelGenerationInputControlTypes;
+ static readonly ModelInterrogationFormTypes: typeof ModelInterrogationFormTypes;
+ readonly ModelInterrogationFormTypes: typeof ModelInterrogationFormTypes;
+ static readonly HordeAsyncRequestStates: typeof HordeAsyncRequestStates;
+ readonly HordeAsyncRequestStates: typeof HordeAsyncRequestStates;
+ static readonly APIError: typeof APIError;
+ readonly APIError: typeof APIError;
+ VERSION: string;
+ ratings: AIHordeRatings;
+ constructor(options?: AIHordeInitOptions);
+ clearCache(): void;
+ get cache(): AIHordeCache;
+ parseAgent(agent: string): {
+ name: string;
+ version: string;
+ link: string;
+ };
+ generateFieldsString(fields?: string[]): string | undefined;
+ /**
+ * Lookup user details based on their API key.
+ * This can be used to verify a user exists
+ * @param options.token - The token of the user; If none given the default from the contructor is used
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns UserDetails - The user data of the requested user
+ */
+ findUser(options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details and statistics about a specific user
+ * @param id - The user ids to get
+ * @param options.token - The token of the requesting user; Has to be Moderator, Admin or Reuqested users token
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns UserDetails - The user data of the requested user
+ */
+ getUserDetails(id: number, options?: {
+ token?: string;
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details of a worker Team
+ * @param id - The teams id to get
+ * @param options.token - The token of the requesting user
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns TeamDetailsStable - The team data
+ */
+ getTeam(id: string, options?: {
+ token?: string;
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details of a registered worker.
+ * This can be used to verify a user exists
+ * @param id - The id of the worker
+ * @param options.token - Moderator or API key of workers owner (gives more information if requesting user is owner or moderator)
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns worker details for the requested worker
+ */
+ getWorkerDetails(id: string, options?: {
+ token?: string;
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Retrieve the status of an Asynchronous generation request without images
+ * Use this method to check the status of a currently running asynchronous request without consuming bandwidth.
+ * @param id - The id of the generation
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestStatusCheck - The Check data of the Generation
+ */
+ getImageGenerationCheck(id: string, options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Retrieve the full status of an Asynchronous generation request
+ * This method will include all already generated images in base64 encoded .webp files.
+ * As such, you are requested to not retrieve this data often. Instead use the getGenerationCheck method first
+ * This method is limited to 1 request per minute
+ * @param id - The id of the generation
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestStatusStable - The Status of the Generation
+ */
+ getImageGenerationStatus(id: string, options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * This request will include all already generated texts.
+ * @param id - The id of the generation
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestStatusStable - The Status of the Generation
+ */
+ getTextGenerationStatus(id: string, options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * This request will include all already generated images.
+ * As such, you are requested to not retrieve this endpoint often. Instead use the /check/ endpoint first
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns InterrogationStatus - The Status data of the Interrogation
+ */
+ getInterrogationStatus(id: string, options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * If this loads, this node is available
+ * @returns true - If request was successful, if not throws error
+ */
+ getHeartbeat(): Promise;
+ /**
+ * Returns a list of models active currently in this horde
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ActiveModel[] - Array of Active Models
+ */
+ getModels(options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Horde Maintenance Mode Status
+ * Use this method to quicky determine if this horde is in maintenance, invite_only or raid mode
+ * @param options.token - Requires Admin or Owner API key
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns HordeModes - The current modes of the horde
+ */
+ getModes(options?: {
+ token?: string;
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Read the latest happenings on the horde
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns Newspiece[] - Array of all news articles
+ */
+ getNews(options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Details about the current performance of this Horde
+ * @param options.force - Set to true to skip cache
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns HordePerformanceStable - The hordes current performance
+ */
+ getPerformance(options?: {
+ force?: boolean;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * A List with the details and statistic of all registered users
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns UserDetails[] - An array of all users data
+ */
+ getUsers(options?: {
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * A List with the details of all registered and active workers
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns An array of all workers data
+ */
+ getWorkers(options?: {
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Details how many images were generated per model for the past day, month and total
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ImageModelStats - The stats
+ */
+ getImageModelStats(options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details how many images have been generated in the past minux,hour,day,month and total
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ImageTotalStats - The stats
+ */
+ getImageTotalStats(options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details how many texts were generated per model for the past day, month and total
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns TextModelStats - The stats
+ */
+ getTextModelStats(options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Details how many images have been generated in the past minux,hour,day,month and total
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns TextTotalStats - The stats
+ */
+ getTextTotalStats(options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * A List with the details of all teams
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns TeamDetailsStable[] - Array of Team Details
+ */
+ getTeams(options?: {
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * A List of filters
+ * @param filter_type - The type of filter to show
+ * @param options.token - The sending users API key; User must be a moderator
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns FilterDetails[] - Array of Filter Details
+ */
+ getFilters(filter_type?: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Gets Details for a specific filter
+ * @param filter_id - The filter to show
+ * @param options.token - The sending users API key; User must be a moderator
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns FilterDetails - Filter Details
+ */
+ getFilter(filter_id?: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Transfer Kudos to a registered user
+ * @param check_data - The prompt to check
+ * @param options.token - The sending users API key; User must be a moderator
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns FilterPromptSuspicion
+ */
+ postFilters(check_data: FilterCheckPayload, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Initiate an Asynchronous request to generate images
+ * This method will immediately return with the UUID of the request for generation.
+ * This method will always be accepted, even if there are no workers available currently to fulfill this request.
+ * Perhaps some will appear in the next 10 minutes.
+ * Asynchronous requests live for 10 minutes before being considered stale and being deleted.
+ * @param generation_data - The data to generate the image
+ * @param options.token - The token of the requesting user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestAsync - The id and message for the async generation request
+ */
+ postAsyncImageGenerate(generation_data: GenerationInput, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Initiate an Asynchronous request to generate text
+ * This endpoint will immediately return with the UUID of the request for generation.
+ * This endpoint will always be accepted, even if there are no workers available currently to fulfill this request.
+ * Perhaps some will appear in the next 20 minutes.
+ * Asynchronous requests live for 20 minutes before being considered stale and being deleted.
+ * @param generation_data - The data to generate the text
+ * @param options.token - The token of the requesting user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestAsync - The id and message for the async generation request
+ */
+ postAsyncTextGenerate(generation_data: GenerationInputKobold, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Submit aesthetic ratings for generated images to be used by LAION
+ * The request has to have been sent as shared: true.
+ * You can select the best image in the set, and/or provide a rating for each or some images in the set.
+ * If you select best-of image, you will gain 4 kudos. Each rating is 5 kudos. Best-of will be ignored when ratings conflict with it.
+ * You can never gain more kudos than you spent for this generation. Your reward at max will be your kudos consumption - 1.
+ * @param generation_id - The ID of the generation to rate
+ * @param rating - The data to rating data
+ * @param options.token - The token of the requesting user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationSubmitted - The kudos awarded for the rating
+ */
+ postRating(generation_id: string, rating: AestheticsPayload, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Check if there are generation requests queued for fulfillment
+ * This endpoint is used by registered workers only
+ * @param pop_input
+ * @param options.token - The token of the registered user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationPayloadStable
+ */
+ postImageGenerationPop(pop_input: PopInputStable, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Check if there are generation requests queued for fulfillment
+ * This endpoint is used by registered workers only
+ * @param pop_input
+ * @param options.token - The token of the registered user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationPayloadKobold
+ */
+ postTextGenerationPop(pop_input: PopInputKobold, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Submit a generated image
+ * This endpoint is used by registered workers only
+ * @param generation_submit
+ * @param options.token - The workers owner API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationSubmitted
+ */
+ postImageGenerationSubmit(generation_submit: {
+ id: string;
+ generation: string;
+ seed: string;
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Submit generated text
+ * This endpoint is used by registered workers only
+ * @param generation_submit
+ * @param options.token - The workers owner API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationSubmitted
+ */
+ postTextGenerationSubmit(generation_submit: {
+ id: string;
+ generation: string;
+ state: "ok" | "censored" | "faulted";
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Initiate an Asynchronous request to interrogate an image.
+ * This endpoint will immediately return with the UUID of the request for interrogation.
+ * This endpoint will always be accepted, even if there are no workers available currently to fulfill this request.
+ * Perhaps some will appear in the next 20 minutes.
+ * Asynchronous requests live for 20 minutes before being considered stale and being deleted.
+ * @param interrogate_payload
+ * @param options.token - The sending users API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestInterrogationResponse
+ */
+ postAsyncInterrogate(interrogate_payload: ModelInterrogationInputStable, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Check if there are interrogation requests queued for fulfillment
+ * This endpoint is used by registered workers only
+ * @param pop_input
+ * @param options.token - The token of the registered user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns InterrogationPopPayload
+ */
+ postInterrogationPop(pop_input: InterrogationPopInput, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Submit the results of an interrogated image
+ * This endpoint is used by registered workers only
+ * @param generation_submit
+ * @param options.token - The workers owner API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns GenerationSubmitted
+ */
+ postInterrogationSubmit(interrogation_submit: {
+ id: string;
+ result: string;
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Transfer Kudos to a registered user
+ * @param transfer_data - The data specifiying who to send how many kudos
+ * @param options.token - The sending users API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns KudosTransferred
+ */
+ postKudosTransfer(transfer_data: {
+ username: string;
+ amount: number;
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Receive kudos from the KoboldAI Horde
+ * @param user_id - The stable horde user id of the receiving user
+ * @param transfer_data - The data specifiying who to send how many kudos
+ * @param options.token - The sending users API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns null
+ */
+ postKoboldTransfer(user_id: string, transfer_data: {
+ kai_id: string;
+ kudos_amount: number;
+ trusted: boolean;
+ }, options?: {
+ token?: string;
+ }): Promise;
+ /**
+ * Create a new team
+ * Only trusted users can create new teams.
+ * @param create_payload - The data to create the team with
+ * @param options.token - The API key of a trusted user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ModifyTeam
+ */
+ createTeam(create_payload: CreateTeamInput, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /** PUT */
+ /**
+ * Change Horde Modes
+ * @param modes - The new status of the Horde
+ * @param options.token - Requires Admin API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns HordeModes
+ */
+ putStatusModes(modes: {
+ maintenance: boolean;
+ shutdown: number;
+ invite_only: boolean;
+ raid: boolean;
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Method for horde admins to perform operations on users
+ * @param update_payload - The data to change on the target user
+ * @param id - The targeted users ID
+ * @param options.token - Requires Admin API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ModifyUser
+ */
+ updateUser(update_payload: ModifyUserInput, id: number, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Put the worker into maintenance or pause mode
+ * Maintenance can be set by the owner of the serve or an admin.
+ * When in maintenance, the worker will receive a 503 request when trying to retrieve new requests. Use this to avoid disconnecting your worker in the middle of a generation
+ * Paused can be set only by the admins of this Horde.
+ * When in paused mode, the worker will not be given any requests to generate.
+ * @param update_payload - The data to change on the target worker
+ * @param id - The targeted workers ID
+ * @param options.token - The worker owners API key or Admin API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ModifyWorker
+ */
+ updateWorker(update_payload: ModifyWorkerInput, id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise;
+ /** PATCH */
+ /**
+ * Updates a Team's information
+ * @param update_payload - The data to update the team with
+ * @param options.token - The Moderator or Creator API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns ModifyTeam
+ */
+ updateTeam(update_payload: ModifyTeamInput, id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Adds a new regex filer
+ * @param create_payload - The data to create the filter with
+ * @param options.token - The Moderator API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns FilterDetails
+ */
+ addFilter(create_payload: PutNewFilter, id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /** PATCH */
+ /**
+ * Updates an existing regex filer
+ * @param update_payload - The data to update the filter with
+ * @param options.token - The Moderator API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns FilterDetails
+ */
+ updateFilter(update_payload: PatchExistingFilter, id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /** DELETE */
+ /**
+ * Cancel an unfinished request
+ * This request will include all already generated images in base64 encoded .webp files.
+ * @param id - The targeted generations ID
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestStatusStable
+ */
+ deleteImageGenerationRequest(id: string, options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Cancel an unfinished request
+ * This request will include all already generated images in base64 encoded .webp files.
+ * @param id - The targeted generations ID
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RequestStatusKobold
+ */
+ deleteTextGenerationRequest(id: string, options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Cancel an unfinished interrogation request
+ * This request will return all already interrogated image results.
+ * @param id - The targeted generations ID
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns InterrogationStatus
+ */
+ deleteInterrogationRequest(id: string, options?: {
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Delete the worker entry
+ * This will delete the worker and their statistics. Will not affect the kudos generated by that worker for their owner.
+ * Only the worker's owner and an admin can use this endpoint.
+ * This action is unrecoverable!
+ * @param id - The targeted workers ID
+ * @param options.token - The worker owners API key or a Moderators API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns DeletedWorker
+ */
+ deleteWorker(id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise;
+ /**
+ * Delete the team entry
+ * Only the team's creator or a horde moderator can use this endpoint.
+ * This action is unrecoverable!
+ * @param id - The targeted teams ID
+ * @param options.token - The worker owners API key or a Moderators API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns DeletedTeam
+ */
+ deleteTeam(id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Remove an IP from timeout
+ * Only usable by horde moderators
+ * @param ip - The IP address
+ * @param options.token - Moderators API key
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns SimpleResponse
+ */
+ deleteIPTimeout(delete_payload: DeleteTimeoutIPInput, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /**
+ * Delete a regex filter
+ * @param filter_id - The ID of the filter to delete
+ * @param options.token - The sending users API key; User must be a moderator
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns SimpleResponse
+ */
+ deleteFilter(filter_id: string, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+}
+export = AIHorde;
+export interface AIHordeInitOptions {
+ /** The configuration for caching results */
+ cache?: AIHordeCacheConfiguration;
+ /**
+ * The interval to check expired data in the cache
+ * @default 1000
+ */
+ cache_interval?: number;
+ /** The default token to use for requests */
+ default_token?: string;
+ /** The base api domain + route to use for requests */
+ api_route?: string;
+ /** The ratings api domain + route to use for requests */
+ ratings_api_route?: string;
+ /** The client agent to pass in the requests. */
+ client_agent?: string;
+}
+export interface AIHordeCacheConfiguration {
+ /** How long to cache a specific user for in Milliseconds */
+ users?: number;
+ /** How long to cache generation check data for in Milliseconds */
+ generations_check?: number;
+ /** How long to cache generation status data for in Milliseconds */
+ generations_status?: number;
+ /** How long to cache interrogation status data for in Milliseconds */
+ interrogations_status?: number;
+ /** How long to cache models for in Milliseconds */
+ models?: number;
+ /** How long to cache modes for in Milliseconds */
+ modes?: number;
+ /** How long to cache news for in Milliseconds */
+ news?: number;
+ /** How long to cache performance for in Milliseconds */
+ performance?: number;
+ /** How long to cache workers for in Milliseconds */
+ workers?: number;
+ /** How long to cache teams for in Milliseconds */
+ teams?: number;
+}
+interface AIHordeCache {
+ users?: SuperMap;
+ generations_check?: SuperMap;
+ generations_status?: SuperMap;
+ interrogations_status?: SuperMap;
+ models?: SuperMap;
+ modes?: SuperMap;
+ news?: SuperMap;
+ performance?: SuperMap;
+ workers?: SuperMap;
+ teams?: SuperMap;
+}
+export interface ModifyUserInput {
+ /** The amount of kudos to modify (can be negative) */
+ kudos?: number;
+ /**
+ * The amount of concurrent request this user can have
+ * @minimum 0
+ * @maximum 100
+ */
+ concurrency?: number;
+ /**
+ * The amount by which to multiply the users kudos consumption
+ * @minimum 0.1
+ * @maximum 10
+ */
+ usage_multiplier?: number;
+ /** Set to the amount of workers this user is allowed to join to the horde when in worker invite-only mode. */
+ worker_invited?: number;
+ /**
+ * Set to true to Make this user a horde moderator
+ * @example false
+ */
+ moderator?: boolean;
+ /**
+ * Set to true to Make this user a display their worker IDs
+ * @example false
+ */
+ public_workers?: boolean;
+ /**
+ * When specified, will start assigning the user monthly kudos, starting now!
+ * @minimum 0
+ */
+ monthly_kudos?: number;
+ /**
+ * When specified, will change the username. No profanity allowed!
+ * @minLength 3
+ * @maxLength 100
+ */
+ username?: string;
+ /**
+ * When set to true,the user and their servers will not be affected by suspicion
+ * @example false
+ */
+ trusted?: boolean;
+ /** Set the user's suspicion back to 0 */
+ reset_suspicion?: boolean;
+ /**
+ * Contact details for the horde admins to reach the user in case of emergency. This is only visible to horde moderators.
+ * @example email@example.com
+ * @minLength 5
+ * @maxLength 500
+ */
+ contact?: string;
+}
+export interface ModifyWorkerInput {
+ /** (Mods only) Set to true to put this worker into maintenance. */
+ maintenance?: boolean;
+ /** (Mods only) Set to true to pause this worker. */
+ paused?: boolean;
+ /**
+ * You can optionally provide a server note which will be seen in the server details. No profanity allowed!
+ * @minLength 5
+ * @maxLength 1000
+ */
+ info?: string;
+ /**
+ * When this is set, it will change the worker's name. No profanity allowed!
+ * @minLength 5
+ * @maxLength 100
+ */
+ name?: string;
+ /**
+ * The team towards which this worker contributes kudos. No profanity allowed!
+ * @example 0bed257b-e57c-4327-ac64-40cdfb1ac5e6
+ * @minLength 3
+ * @maxLength 100
+ */
+ team?: string;
+}
+/**
+ * @link https://aihorde.net/api/
+*/
+export interface GenerationInputKobold {
+ /** The prompt which will be sent to KoboldAI to generate text */
+ prompt?: string;
+ params?: ModelGenerationInputKobold;
+ /**
+ * Specify which softpompt needs to be used to service this request
+ * @minLength 1
+ */
+ softprompt?: string;
+ /**
+ * When true, only trusted workers will serve this request. When False, Evaluating workers will also be used which can increase speed but adds more risk!
+ * @default true
+ */
+ trusted_workers?: boolean;
+ /** Specify which workers are allowed to service this request */
+ workers?: string[];
+ /** Specify which models are allowed to be used for this request */
+ models?: string[];
+}
+export interface ModelGenerationInputKobold {
+ /**
+ * @example 1
+ * @minimum 1
+ * @maximum 20
+ */
+ n?: number;
+ /**
+ * Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.
+ * @example false
+ */
+ frmtadsnsp?: boolean;
+ /**
+ * Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in the output with one newline.
+ * @example false
+ */
+ frmtrmblln?: boolean;
+ /**
+ * Output formatting option. When enabled, removes #/@%}{+=~|^<> from the output.
+ * @example false
+ */
+ frmtrmspch?: boolean;
+ /**
+ * Output formatting option. When enabled, removes some characters from the end of the output such that the output doesn't end in the middle of a sentence. If the output is less than one sentence long, does nothing.
+ * @example false
+ */
+ frmttriminc?: boolean;
+ /**
+ * Maximum number of tokens to send to the model.
+ * @example 1024
+ * @minimum 80
+ * @maximum 2048
+ */
+ max_context_length?: number;
+ /**
+ * Number of tokens to generate.
+ * @minimum 16
+ * @maximum 512
+ */
+ max_length?: number;
+ /**
+ * Base repetition penalty value.
+ * @maximum 1
+ */
+ rep_pen?: number;
+ /** Repetition penalty range. */
+ rep_pen_range?: number;
+ /** Repetition penalty slope. */
+ rep_pen_slope?: number;
+ /**
+ * Output formatting option. When enabled, removes everything after the first line of the output, including the newline.
+ * @example false
+ */
+ singleline?: boolean;
+ /** Soft prompt to use when generating. If set to the empty string or any other string containing no non-whitespace characters, uses no soft prompt. */
+ soft_prompt?: string;
+ /**
+ * Temperature value.
+ * @minimum 0
+ */
+ temperature?: number;
+ /** Tail free sampling value. */
+ tfs?: number;
+ /** Top-a sampling value. */
+ top_a?: number;
+ /** Top-k sampling value. */
+ top_k?: number;
+ /** Top-p sampling value. */
+ top_p?: number;
+ /** Typical sampling value. */
+ typical?: number;
+ /** Array of integers representing the sampler order to be used */
+ sample_order?: number[];
+}
+export interface ModelPayloadKobold extends ModelGenerationInputKobold {
+ prompt?: string;
+}
+export interface GenerationInput {
+ /** The prompt which will be sent to Stable Diffusion to generate an image */
+ prompt: string;
+ /** The parameters for the generation */
+ params?: ModelGenerationInputStable;
+ /**
+ * Set to true if this request is NSFW. This will skip workers which censor images.
+ * @default false
+ */
+ nsfw?: boolean;
+ /**
+ * When true, only trusted workers will serve this request. When False, Evaluating workers will also be used which can increase speed but adds more risk!
+ * @default true
+ */
+ trusted_workers?: boolean;
+ /**
+ * When True, allows slower workers to pick up this request. Disabling this incurs an extra kudos cost.
+ * @default true
+ */
+ slow_workers?: boolean;
+ /**
+ * If the request is SFW, and the worker accidentaly generates NSFW, it will send back a censored image.
+ * @default false
+ */
+ censor_nsfw?: boolean;
+ /** Specify which workers are allowed to service this request */
+ workers?: string[];
+ /** Specify which models are allowed to be used for this request */
+ models?: string[];
+ /** The Base64-encoded webp to use for img2img, max siue 3072 * 3072 */
+ source_image?: string;
+ /** If source_image is provided, specifies how to process it. */
+ source_processing?: typeof AIHorde.SourceImageProcessingTypes[keyof typeof AIHorde.SourceImageProcessingTypes];
+ /** If source_processing is set to 'inpainting' or 'outpainting', this parameter can be optionally provided as the Base64-encoded webp mask of the areas to inpaint. If this arg is not passed, the inpainting/outpainting mask has to be embedded as alpha channel */
+ source_mask?: string;
+ /** If True, the image will be sent via cloudflare r2 download link */
+ r2?: boolean;
+ /** If True, The image will be shared with LAION for improving their dataset. This will also reduce your kudos consumption by 2. For anonymous users, this is always True. */
+ shared?: boolean;
+ /**
+ * If enabled, suspicious prompts are sanitized through a string replacement filter instead.
+ * @default true
+ */
+ replacement_filter?: boolean;
+}
+export interface ModelGenerationInputStable {
+ /**
+ * @default k_euler
+ */
+ sampler_name?: typeof AIHorde.ModelGenerationInputStableSamplers[keyof typeof AIHorde.ModelGenerationInputStableSamplers];
+ /**
+ * Special Toggles used in the SD Webui. To be documented.
+ */
+ toggles?: number[];
+ /**
+ * its how much the AI listens to your prompt, essentially.
+ * @default 5
+ * @minimum -40
+ * @maximum 30
+ *
+ * Multiple of 0.5
+ */
+ cfg_scale?: number;
+ /**
+ * The strength of denoising
+ * @minimum 0
+ * @maximum 1
+ *
+ * Multiple of 0.01
+ */
+ denoising_strength?: number;
+ /** The seed to use to generete this request. */
+ seed?: string;
+ /**
+ * The height of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 3072
+ *
+ * Multiple of 64
+ */
+ height?: number;
+ /**
+ * The width of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 3072
+ *
+ * Multiple of 64
+ */
+ width?: number;
+ /**
+ * If passed with multiple n, the provided seed will be incremented every time by this value
+ * @minimum 1
+ * @maximum 1000
+ */
+ seed_variation?: number;
+ /** Set to True to enable karras noise scheduling tweaks */
+ karras?: boolean;
+ /** The list of post-processors to apply to the image, in the order to be applied */
+ post_processing?: (typeof AIHorde.ModelGenerationInputPostProcessingTypes[keyof typeof AIHorde.ModelGenerationInputPostProcessingTypes])[];
+ /**
+ * Set to True to create images that stitch together seamlessly
+ * @default false
+ */
+ tiling?: boolean;
+ /**
+ * Set to True to process the image at base resolution before upscaling and re-processing
+ * @default false
+ */
+ hires_fix?: boolean;
+ /**
+ * The number of CLIP language processor layers to skip
+ * @minimum 1
+ * @maximum 12
+ */
+ clip_skip?: number;
+ control_type?: (typeof AIHorde.ModelGenerationInputControlTypes[keyof typeof AIHorde.ModelGenerationInputControlTypes]);
+ /**
+ * Set to True if the image submitted is a pre-generated control map for ControlNet use
+ * @default false
+ */
+ image_is_control?: boolean;
+ /**
+ * Set to True if you want the ControlNet map returned instead of a generated image
+ * @default false
+ */
+ return_control_map?: boolean;
+ /**
+ * @example 0.75
+ * @minimum 0
+ * @maximum 1
+ */
+ facefixer_strength?: number;
+ /**
+ * @default 30
+ * @minimum 1
+ * @maximum 500
+ */
+ steps?: number;
+ /**
+ * The amount of images to generate
+ * @minimum 1
+ * @maximum 20
+ */
+ n?: number;
+}
+export interface ModelPayloadRootStable {
+ /**
+ * @default k_euler
+ */
+ sampler_name?: typeof AIHorde.ModelGenerationInputStableSamplers[keyof typeof AIHorde.ModelGenerationInputStableSamplers];
+ /**
+ * Special Toggles used in the SD Webui. To be documented.
+ */
+ toggles?: number[];
+ /**
+ * its how much the AI listens to your prompt, essentially.
+ * @default 5
+ * @minimum -40
+ * @maximum 30
+ *
+ * Multiple of 0.5
+ */
+ cfg_scale?: number;
+ /**
+ * The strength of denoising
+ * @minimum 0
+ * @maximum 1
+ *
+ * Multiple of 0.01
+ */
+ denoising_strength?: number;
+ /** The seed to use to generete this request. */
+ seed?: string;
+ /**
+ * The height of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 1024
+ *
+ * Multiple of 64
+ */
+ height?: number;
+ /**
+ * The width of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 1024
+ *
+ * Multiple of 64
+ */
+ width?: number;
+ /**
+ * If passed with multiple n, the provided seed will be incremented every time by this value
+ * @minimum 1
+ * @maximum 1000
+ */
+ seed_variation?: number;
+ /** Set to True to enable karras noise scheduling tweaks */
+ karras?: boolean;
+ /** Set to true to process the generated image with GFPGAN (face correction) */
+ use_gfpgan?: boolean;
+ /** Set to true to process the generated image with RealESRGAN */
+ use_real_esrgan?: boolean;
+ /** Set to true to process the generated image with LDSR */
+ use_ldsr?: boolean;
+ /** Set to true to upscale the image */
+ use_upscaling?: boolean;
+}
+export interface RequestError {
+ /** The error message for this status code. */
+ message: string;
+}
+export interface RequestStatusStable extends RequestStatusCheck {
+ generations?: GenerationStable[];
+}
+export interface RequestStatusKobold extends RequestStatusCheck {
+ generations?: GenerationKobold[];
+}
+export interface RequestStatusCheck {
+ /** The amount of finished images in this request */
+ finished?: number;
+ /** The amount of still processing images in this request */
+ processing?: number;
+ /** The amount of images waiting to be picked up by a worker */
+ waiting?: number;
+ /** True when all images in this request are done. Else False. */
+ done?: boolean;
+ /** rue when this request caused an internal server error and cannot be completed. */
+ faulted?: boolean;
+ /** The expected amount to wait (in seconds) to generate all images in this request */
+ wait_time?: number;
+ /** The position in the requests queue. This position is determined by relative Kudos amounts. */
+ queue_position?: number;
+ /** The amount of total Kudos this request has consumed until now. */
+ kudos?: number;
+ /** If False, this request will not be able to be completed with the pool of workers currently available */
+ is_possible?: boolean;
+}
+export interface Generation {
+ /** The UUID of the worker which generated this image */
+ worker_id?: string;
+ /** The name of the worker which generated this image */
+ worker_name?: string;
+ /** The model which generated this image */
+ model?: string;
+}
+export interface GenerationStable extends Generation {
+ /** The generated image as a Base64-encoded .webp file OR a cloudflare r2 download link */
+ img?: string;
+ /** The seed which generated this image */
+ seed?: string;
+ /** The ID for this image */
+ id?: string;
+ /** When true this image has been censored by the worker's safety filter. */
+ censored?: boolean;
+}
+export interface GenerationKobold extends Generation {
+ /**
+ * The state of the generation,
+ * @default ok
+ * @example ok
+ */
+ state: "ok" | "censored";
+ /** The generated text */
+ text?: string;
+ /** The seed which generated this text */
+ seed: number;
+}
+export interface RequestAsync {
+ /** The UUID of the request. Use this to retrieve the request status in the future */
+ id?: string;
+ /** Any extra information from the horde about this request */
+ message?: string;
+}
+export interface PopInputStable extends PopInput {
+ /**
+ * The maximum amount of pixels this worker can generate
+ * @default 262144
+ */
+ max_pixels?: number;
+ /** Words which, when detected will refuse to pick up any jobs */
+ blacklist?: string[];
+}
+export interface PopInputKobold extends PopInput {
+ /**
+ * The maximum amount of pixels this worker can generate
+ * @default 262144
+ */
+ max_pixels?: number;
+ /** Words which, when detected will refuse to pick up any jobs */
+ blacklist?: string[];
+}
+export interface PopInput {
+ /** The Name of the Worker */
+ name?: string;
+ /** Users with priority to use this worker */
+ priority_usernames?: string[];
+ /**
+ * Whether this worker can generate NSFW requests or not.
+ * @default false
+ */
+ nsfw?: boolean;
+ /** Which models this worker is serving */
+ models?: string[];
+ /**
+ * The version of the bridge used by this worker
+ * @default 1
+ */
+ bridge_version: number;
+ /**
+ * The worker name, version and website
+ * @default unknown:0:unknown
+ * @example AI Horde Worker:11:https://github.com/db0/AI-Horde-Worker
+ * @maxLength 1000
+ */
+ bridge_agent?: string;
+ /**
+ * How many threads this worker is running. This is used to accurately the current power available in the horde
+ * @default 1
+ * @minimum 1
+ * @maximum 10
+ */
+ threads?: number;
+ /**
+ * If True, this worker will only pick up requests where the owner has the required kudos to consume already available
+ * @default false
+ * @example false
+ */
+ require_upfront_kudos?: boolean;
+}
+export interface GenerationPayloadStable {
+ payload?: ModelPayloadStable;
+ /** The UUID for this image generation */
+ id?: string;
+ skipped?: NoValidRequestFoundStable;
+ /** Which of the available models to use for this request */
+ model?: string;
+ /** The Base64-encoded webp to use for img2img */
+ source_image?: string;
+}
+export interface GenerationPayloadKobold {
+ payload?: ModelPayloadKobold;
+ /** The UUID for this text */
+ id?: string;
+ skipped?: NoValidRequestFoundKobold;
+ /** The soft prompt requested for this generation */
+ softprompt?: string;
+ /** Which of the available models to use for this request */
+ model?: string;
+}
+export interface ModelPayloadStable {
+ /**
+ * @default k_euler
+ */
+ sampler_name?: typeof AIHorde.ModelGenerationInputStableSamplers[keyof typeof AIHorde.ModelGenerationInputStableSamplers];
+ /**
+ * Special Toggles used in the SD Webui. To be documented.
+ */
+ toggles?: number[];
+ /**
+ * its how much the AI listens to your prompt, essentially.
+ * @default 5
+ * @minimum -40
+ * @maximum 30
+ *
+ * Multiple of 0.5
+ */
+ cfg_scale?: number;
+ /**
+ * The strength of denoising
+ * @minimum 0
+ * @maximum 1
+ *
+ * Multiple of 0.01
+ */
+ denoising_strength?: number;
+ /** The seed to use to generete this request. */
+ seed?: string;
+ /**
+ * The height of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 3072
+ *
+ * Multiple of 64
+ */
+ height?: number;
+ /**
+ * The width of the image to generate
+ * @default 512
+ * @minimum 64
+ * @maximum 3072
+ *
+ * Multiple of 64
+ */
+ width?: number;
+ /**
+ * If passed with multiple n, the provided seed will be incremented every time by this value
+ * @minimum 1
+ * @maximum 1000
+ */
+ seed_variation?: number;
+ /** Set to True to enable karras noise scheduling tweaks */
+ karras?: boolean;
+ /** The list of post-processors to apply to the image, in the order to be applied */
+ post_processing?: (typeof AIHorde.ModelGenerationInputPostProcessingTypes[keyof typeof AIHorde.ModelGenerationInputPostProcessingTypes])[];
+ /**
+ * Set to True to create images that stitch together seamlessly
+ * @default false
+ */
+ tiling?: boolean;
+ /**
+ * Set to True to process the image at base resolution before upscaling and re-processing
+ * @default false
+ */
+ hires_fix?: boolean;
+ /**
+ * The number of CLIP language processor layers to skip
+ * @minimum 1
+ * @maximum 12
+ */
+ clip_skip?: number;
+ control_type?: (typeof AIHorde.ModelGenerationInputControlTypes[keyof typeof AIHorde.ModelGenerationInputControlTypes]);
+ /** The prompt which will be sent to Stable Diffusion to generate an image */
+ prompt?: string;
+ /**
+ * @default 30
+ */
+ ddim_steps?: number;
+ /**
+ * The amount of images to generate
+ * @default 1
+ */
+ n_iter?: number;
+ /** When true will apply NSFW censoring model on the generation */
+ use_nsfw_censor?: boolean;
+}
+export interface NoValidRequestFoundKobold extends NoValidRequestFound {
+ /** How many waiting requests were skipped because they demanded a higher max_context_length than what this worker provides. */
+ max_context_length?: number;
+ /** How many waiting requests were skipped because they demanded more generated tokens that what this worker can provide. */
+ max_length?: number;
+ /** How many waiting requests were skipped because they demanded an available soft-prompt which this worker does not have. */
+ matching_softprompt?: number;
+}
+export interface NoValidRequestFoundStable extends NoValidRequestFound {
+ /** How many waiting requests were skipped because they demanded a higher size than this worker provides */
+ max_pixels?: number;
+}
+export interface NoValidRequestFound {
+ /** How many waiting requests were skipped because they demanded a specific worker */
+ worker_id?: number;
+ /** How many waiting requests were skipped because they required higher performance */
+ performance?: number;
+ /** How many waiting requests were skipped because they demanded a nsfw generation which this worker does not provide */
+ nsfw?: number;
+ /** How many waiting requests were skipped because they demanded a generation with a word that this worker does not accept */
+ blacklist?: number;
+ /** How many waiting requests were skipped because they demanded a trusted worker which this worker is not */
+ untrusted?: number;
+ /** How many waiting requests were skipped because they demanded a different model than what this worker provides */
+ models?: number;
+ /** How many waiting requests were skipped because they require a higher version of the bridge than this worker is running (upgrade if you see this in your skipped list) */
+ bridge_version?: number;
+}
+export interface GenerationSubmitted {
+ /** The amount of kudos gained for submitting this request */
+ reward?: number;
+}
+export interface UserThingUsageRecords {
+ /**
+ * How many megapixelsteps this user has generated or requested
+ * @default 0
+ */
+ megapixelsteps?: number;
+ /**
+ * How many tokens this user has generated or requested
+ * @default 0
+ */
+ tokens?: number;
+}
+export interface UserThingFulfillmentRecords {
+ /**
+ * How many images were generated or requested
+ * @default 0
+ */
+ image?: number;
+ /**
+ * How many images were interrogated generated or requested
+ * @default 0
+ */
+ interrogation?: number;
+ /**
+ * How many texts were generated or requested
+ * @default 0
+ */
+ text?: number;
+}
+export interface UserRecords {
+ usage?: UserThingUsageRecords;
+ contribution?: UserThingUsageRecords;
+ fulfillment?: UserThingFulfillmentRecords;
+ request?: UserThingFulfillmentRecords;
+}
+export interface UserDetails {
+ /** The user's unique Username. It is a combination of their chosen alias plus their ID. */
+ username?: string;
+ /** The user unique ID. It is always an integer. */
+ id?: number;
+ /** The amount of Kudos this user has. The amount of Kudos determines the priority when requesting image generations. */
+ kudos?: number;
+ /** (Privileged) The amount of Evaluating Kudos this untrusted user has from generations and uptime. When this number reaches 50000, they automatically become trusted. */
+ evaluating_kudos?: number;
+ /** How many concurrent generations this user may request. */
+ concurrency?: number;
+ /** Whether this user has been invited to join a worker to the horde and how many of them. When 0, this user cannot add (new) workers to the horde. */
+ worker_invited?: number;
+ /** This user is a Horde moderator. */
+ moderator?: boolean;
+ kudos_details?: UserKudosDetails;
+ /** How many workers this user has created (active or inactive) */
+ worker_count?: number;
+ worker_ids?: string[];
+ monthly_kudos?: MonthlyKudos;
+ /** This user is a trusted member of the Horde. */
+ trusted?: boolean;
+ /** This user has been flagged for suspicious activity. */
+ flagged?: boolean;
+ /** (Privileged) How much suspicion this user has accumulated */
+ suspicious?: number;
+ /** If true, this user has not registered using an oauth service. */
+ pseudonymous?: boolean;
+ /**
+ * (Privileged) Contact details for the horde admins to reach the user in case of emergency.
+ * @example email@example.com
+ */
+ contact?: string;
+ /**
+ * How many seconds since this account was created
+ * @example 60
+ */
+ account_age?: number;
+ /**
+ * @deprecated
+ */
+ usage?: UsageDetailsStable;
+ /**
+ * @deprecated
+ */
+ contributions?: ContributionsDetailsStable;
+ records?: UserRecords;
+}
+export interface UserKudosDetails {
+ /** The ammount of Kudos accumulated or used for generating images. */
+ accumulated?: number;
+ /** The amount of Kudos this user has given to other users. */
+ gifted?: number;
+ /** The amount of Kudos this user has been given by the Horde admins. */
+ admin?: number;
+ /** The amount of Kudos this user has been given by other users. */
+ received?: number;
+ /** The amount of Kudos this user has received from recurring rewards. */
+ recurring?: number;
+ /** The amount of Kudos this user has received from rating images. */
+ awarded?: number;
+}
+export interface MonthlyKudos {
+ /** How much recurring Kudos this user receives monthly. */
+ amount?: number;
+ /**
+ * Last date this user received monthly Kudos.
+ * @type string($date-time)
+ */
+ last_received?: string;
+}
+export interface UsageDetailsStable extends UsageDetails {
+ /** How many images this user has requested */
+ requests?: number;
+ /** How many megapixelsteps this user has requested */
+ megapixelsteps?: number;
+}
+export interface UsageDetails {
+ /** How many images this user has requested */
+ requests?: number;
+}
+export interface ContributionsDetailsStable extends ContributionsDetails {
+ /** How many images this user has generated */
+ fulfillments?: number;
+ /** How many megapixelsteps this user has generated */
+ megapixelsteps?: number;
+}
+export interface ContributionsDetails {
+ /** How many images this user has generated */
+ fulfillments?: number;
+}
+export interface ModifyUser {
+ /** The new total Kudos this user has after this request */
+ new_kudos?: number;
+ /** The request concurrency this user has after this request */
+ concurrency?: number;
+ /** Multiplies the amount of kudos lost when generating images. */
+ usage_multiplier?: number;
+ /** This userWhether this user has been invited to join a worker to the horde and how many of them. When 0, this user cannot add (new) workers to the horde. */
+ worker_invited?: number;
+ /** The user's new moderator status. */
+ moderator?: boolean;
+ /** The user's new public_workers status. */
+ public_workers?: number;
+ /** The user's new username. */
+ username?: string;
+ /** The user's new monthly kudos total */
+ monthly_kudos?: number;
+ /** The user's new trusted status */
+ trusted?: boolean;
+}
+export interface WorkersPerformanceFilter {
+ /**
+ * Minimal value of performance for worker to have
+ * @default 1.5
+ */
+ performance?: number;
+ /**
+ * Minimal filtered workers amount to resort to the list of first `minLength` workers sorted by `performance` value
+ * @default 5
+ */
+ size?: number;
+ /**
+ * Worker should support img2img
+ */
+ img2img?: boolean;
+ /**
+ * List of models workers should have (at least one)
+ */
+ models?: string[];
+}
+export interface WorkerDetailsStable extends WorkerDetails {
+ /** The maximum pixels in resolution this workr can generate */
+ max_pixels?: number;
+ /** How many megapixelsteps this worker has generated until now */
+ megapixelsteps_generated?: number;
+ /** If True, this worker supports and allows img2img requests. */
+ img2img?: boolean;
+ /** If True, this worker supports and allows inpainting requests. */
+ painting?: boolean;
+ /** If True, this worker supports and allows post-processing requests. */
+ "post-processing"?: boolean;
+}
+export interface WorkerDetails extends WorkerDetailsLite {
+ /** How many images this worker has generated. */
+ requests_fulfilled?: number;
+ /** How many Kudos this worker has been rewarded in total. */
+ kudos_rewards?: number;
+ kudos_details?: WorkerKudosDetails;
+ /** The average performance of this worker in human readable form. */
+ performance?: string;
+ /** How many threads this worker is running. */
+ threads?: number;
+ /** The amount of seconds this worker has been online for this Horde. */
+ uptime?: number;
+ /** When True, this worker will not pick up any new requests */
+ maintenance_mode?: boolean;
+ /** (Privileged) When True, this worker not be given any new requests. */
+ paused?: boolean;
+ /** Extra information or comments about this worker provided by its owner. */
+ info?: string;
+ /** Whether this worker can generate NSFW requests or not. */
+ nsfw?: boolean;
+ /** Privileged or public if the owner has allowed it. The alias of the owner of this worker. */
+ owner?: string;
+ /** The worker is trusted to return valid generations. */
+ trusted?: boolean;
+ /** (Privileged) How much suspicion this worker has accumulated */
+ suspicious?: number;
+ /**
+ * How many jobs this worker has left uncompleted after it started them.
+ * @example 0
+ */
+ uncompleted_jobs?: number;
+ /** Which models this worker if offerring */
+ models?: string[];
+ team?: TeamDetailsLite;
+ /**
+ * (Privileged) Contact details for the horde admins to reach the owner of this worker in emergencies.
+ * @example email@example.com
+ * @minLength 5
+ * @maxLength 500
+ */
+ contact?: string;
+ /**
+ * The bridge agent name, version and website
+ * @default: unknown:0:unknown
+ * @example: AI Horde Worker:11:https://github.com/db0/AI-Horde-Worker
+ * @maxLength: 1000
+ */
+ bridge_agent?: string;
+}
+export interface WorkerDetailsLite {
+ /** The Name given to this worker. */
+ name?: string;
+ /** The UUID of this worker. */
+ id?: string;
+ /** True if the worker has checked-in the past 5 minutes. */
+ online?: boolean;
+}
+export interface WorkerKudosDetails {
+ /** How much Kudos this worker has received for generating images */
+ generated?: number;
+ /** How much Kudos this worker has received for staying online longer */
+ uptime?: number;
+}
+export interface ModifyWorker {
+ /** The new state of the 'maintenance' var for this worker. When True, this worker will not pick up any new requests. */
+ maintenance?: boolean;
+ /** The new state of the 'paused' var for this worker. When True, this worker will not be given any new requests. */
+ paused?: boolean;
+ /** The new state of the 'info' var for this worker. */
+ info?: string;
+ /** The new name for this this worker. */
+ name?: string;
+}
+export interface DeletedWorker {
+ /** The ID of the deleted worker */
+ deleted_id?: string;
+ /** The Name of the deleted worker*/
+ deleted_name?: string;
+}
+export interface ActiveModel extends ActiveModelLite {
+ /** The average speed of generation for this model */
+ performance?: number;
+ /** The amount waiting to be generated by this model */
+ queued?: number;
+ /** Estimated time in seconds for this model's queue to be cleared */
+ eta?: number;
+}
+export interface ActiveModelLite {
+ /** The name of a model available by workers in this horde. */
+ name?: string;
+ /** How many workers in this horde are running this model. */
+ count?: number;
+}
+export interface KudosTransferred {
+ /** The amount of Kudos tranferred */
+ transferred?: number;
+}
+export interface HordeModes {
+ /** When True, this Horde will not accept new requests for image generation, but will finish processing the ones currently in the queue. */
+ maintenance_mode?: boolean;
+ /** When True, this Horde will not only accept worker explicitly invited to join. */
+ invite_only_mode?: boolean;
+ /** When True, this Horde will not always provide full information in order to throw off attackers. */
+ raid_mode?: boolean;
+}
+export interface HordePerformanceStable extends HordePerformance {
+ /** The amount of megapixelsteps in waiting and processing requests currently in this Horde */
+ queued_megapixelsteps?: number;
+ /** How many megapixelsteps this Horde generated in the last minute */
+ past_minute_megapixelsteps?: number;
+ /** The amount of image interrogations waiting and processing currently in this Horde */
+ queued_forms?: number;
+ /** How many workers are actively processing image interrogations in this Horde in the past 5 minutes */
+ interrogator_count?: number;
+ /** How many worker threads are actively processing image interrogation in this Horde in the past 5 minutes */
+ interrogator_thread_count?: number;
+}
+export interface HordePerformance {
+ /** The amount of waiting and processing requests currently in this Horde */
+ queued_requests?: number;
+ /** How many workers are actively processing image generations in this Horde in the past 5 minutes */
+ worker_count?: number;
+ /** How many worker threads are actively processing prompt generations in this Horde in the past 5 minutes */
+ thread_count?: number;
+}
+export interface Newspiece {
+ /** The date this newspiece was published */
+ date_published?: string;
+ /** The actual piece of news */
+ newspiece?: string;
+ /** How critical this piece of news is. */
+ importance?: string;
+}
+export interface CreateTeamInput {
+ /**
+ * The name of the team. No profanity allowed!
+ * @minLength 3
+ * @maxLength 100
+ */
+ name: string;
+ /**
+ * Extra information or comments about this team.
+ * @example Anarchy is emergent order.
+ * @minLength 3
+ * @maxLength 1000
+ */
+ info?: string;
+}
+export interface ModifyTeam {
+ /** The ID of the team */
+ id?: string;
+ /** The Name of the team */
+ name?: string;
+ /** The Info of the team */
+ info?: string;
+}
+export interface TeamDetailsStable extends TeamDetails {
+ /** How many megapixelsteps the workers in this team have been rewarded while part of this team. */
+ contributions?: number;
+ /** The average performance of the workers in this team, in megapixelsteps per second. */
+ performance?: number;
+ /** The total expected speed of this team when all workers are working in parallel, in megapixelsteps per second. */
+ speed?: number;
+}
+export interface TeamDetails extends TeamDetailsLite {
+ /**
+ * Extra information or comments about this team provided by its owner
+ * @example Anarchy is emergent order.
+ */
+ info?: string;
+ /** How many images this team's workers have generated */
+ requests_fulfilled?: number;
+ /** How many Kudos the workers in this team have been rewarded while part of this team. */
+ kudos?: number;
+ /** The total amount of time workers have stayed online while on this team */
+ uptime?: number;
+ /**
+ * How many workers have been dedicated to this team
+ * @example 10
+ */
+ worker_count?: number;
+ workers?: WorkerDetailsLite[];
+ models?: ActiveModelLite[];
+}
+export interface TeamDetailsLite {
+ /** The Name given to this team. */
+ name?: string;
+ /** The UUID of this team */
+ id?: string;
+}
+export interface ModifyTeamInput {
+ /**
+ * The name of the team. No profanity allowed!
+ * @minLength 3
+ * @maxLength 100
+ */
+ name?: string;
+ /**
+ * Extra information or comments about this team.
+ * @example Anarchy is emergent order.
+ * @minLength 3
+ * @maxLength 1000
+ */
+ info?: string;
+}
+export interface DeletedTeam {
+ /** The ID of the deleted team */
+ deleted_id?: string;
+ /** The Name of the deleted team */
+ deleted_name?: string;
+}
+export interface DeleteTimeoutIPInput {
+ /**
+ * The IP address to remove from timeout
+ * @example 127.0.0.1
+ * @minLength 7
+ * @maxLength 15
+ */
+ ipaddr: string;
+}
+export interface SimpleResponse {
+ /**
+ * The result of this operation
+ * @default OK
+ */
+ message: string;
+}
+export declare type InterrogationPopFormPayloadStable = Partial>;
+export declare type InterrogationFormResult = Partial>>;
+export interface ModelInterrogationFormStable {
+ /**
+ * The type of interrogation this is
+ */
+ name: typeof AIHorde.ModelInterrogationFormTypes[keyof typeof AIHorde.ModelInterrogationFormTypes];
+ payload?: InterrogationPopFormPayload;
+}
+export interface ModelInterrogationInputStable {
+ forms: ModelInterrogationFormStable[];
+ /** The public URL of the image to interrogate */
+ source_image: string;
+}
+export interface RequestInterrogationResponse {
+ /** The UUID of the request. Use this to retrieve the request status in the future */
+ id?: string;
+ /** Any extra information from the horde about this request */
+ message?: string;
+}
+export interface InterrogationPopInput {
+ /** The Name of the Worker */
+ name?: string;
+ /** Users with priority to use this worker */
+ priority_usernames?: string[];
+ /** The type of interrogation this worker can fulfull */
+ forms?: (typeof AIHorde.ModelInterrogationFormTypes[keyof typeof AIHorde.ModelInterrogationFormTypes])[];
+ /**
+ * The amount of forms to pop at the same time
+ * @default 1
+ */
+ amount?: number;
+ /**
+ * The version of the bridge used by this worker
+ * @default 1
+ */
+ bridge_version?: number;
+ /**
+ * How many threads this worker is running. This is used to accurately estimate the power available in the horde.
+ * @default 1
+ * @minimum 1
+ * @maximum 10
+ */
+ threads?: number;
+}
+export interface InterrogationPopFormPayload {
+ /** The UUID of the interrogation form. Use this to post the results in the future */
+ id?: string;
+ /**
+ * The name of this interrogation form
+ * @example caption
+ */
+ name?: typeof AIHorde.ModelInterrogationFormTypes[keyof typeof AIHorde.ModelInterrogationFormTypes];
+ payload?: InterrogationPopFormPayloadStable;
+ /** The URL From which the source image can be downloaded */
+ source_image?: string;
+}
+export interface NoValidInterrogationsFound {
+ /**
+ * How many waiting requests were skipped because they demanded a specific worker.
+ * @minimum 0
+ */
+ worker_id?: number;
+ /**
+ * How many waiting requests were skipped because they demanded a trusted worker which this worker is not.
+ * @minimum 0
+ */
+ untrusted?: number;
+ /**
+ * How many waiting requests were skipped because they require a higher version of the bridge than this worker is running (upgrade if you see this in your skipped list).
+ * @example 0
+ * @minimum 0
+ */
+ bridge_version?: number;
+}
+export interface InterrogationPopPayload {
+ forms: InterrogationPopFormPayload;
+ skipped?: NoValidInterrogationsFound;
+}
+export interface InterrogationFormStatus {
+ /** The name of this interrogation form */
+ form?: string;
+ /** title: Interrogation State */
+ state?: typeof AIHorde.HordeAsyncRequestStates[keyof typeof AIHorde.HordeAsyncRequestStates];
+ result?: InterrogationFormResult;
+}
+export interface InterrogationStatus {
+ /** title: Interrogation State */
+ state?: typeof AIHorde.HordeAsyncRequestStates[keyof typeof AIHorde.HordeAsyncRequestStates];
+ forms?: InterrogationFormStatus[];
+}
+export interface AestheticsPayload {
+ /**
+ * The UUID of the best image in this generation batch (only used when 2+ images generated). If 2+ aesthetic ratings are also provided, then they take precedence if they're not tied.
+ * @example 6038971e-f0b0-4fdd-a3bb-148f561f815e
+ * @minLength 36
+ * @maxLength 36
+ */
+ best?: string;
+ /**
+ * The team towards which this ratings contributes. It not is passed, it will leave the ratings without a team.
+ * @example 0bed257b-e57c-4327-ac64-40cdfb1ac5e6
+ * @minLength 36
+ * @maxLength 36
+ */
+ team?: string;
+ ratings?: AestheticRating[];
+}
+export interface AestheticRating {
+ /**
+ * The UUID of image being rated
+ * @example 6038971e-f0b0-4fdd-a3bb-148f561f815e
+ * @minLength 36
+ * @maxLength 36
+ */
+ id: string;
+ /**
+ * The aesthetic rating 1-10 for this image
+ * @minimum 1
+ * @maximum 10
+ */
+ rating: number;
+}
+export interface FilterCheckPayload {
+ prompt: string;
+}
+export interface FilterPromptSuspicion {
+ /** Rates how suspicious the provided prompt is. A suspicion of 2 means it would be blocked. */
+ suspicion: string;
+ matches: string[];
+}
+export interface FilterDetails {
+ /** The UUID of this filter */
+ id: string;
+ /**
+ * The regex for this filter.
+ * @example ac.*
+ */
+ regex: string;
+ /**
+ * The integer defining this filter type
+ * @minimum 10
+ * @maximum 29
+ */
+ filter_type: number;
+ /**
+ * Description about this regex
+ */
+ description?: string;
+ /**
+ * The moderator which added or last updated this regex
+ */
+ user: string;
+}
+export interface PatchExistingFilter {
+ /**
+ * The regex for this filter.
+ * @example ac.*
+ */
+ regex?: string;
+ /**
+ * The integer defining this filter type
+ * @minimum 10
+ * @maximum 29
+ */
+ filter_type?: number;
+ /**
+ * Description about this regex
+ */
+ description?: string;
+}
+export interface PutNewFilter {
+ /**
+ * The regex for this filter.
+ * @example ac.*
+ */
+ regex: string;
+ /**
+ * The integer defining this filter type
+ * @minimum 10
+ * @maximum 29
+ */
+ filter_type: number;
+ /**
+ * Description about this regex
+ */
+ description: string;
+}
+export interface ImageModelStats {
+ day?: SinglePeriodImageModelStats;
+ month?: SinglePeriodImageModelStats;
+ total?: SinglePeriodImageModelStats;
+}
+/**
+ * string - Model Name
+ * number - The amount of requests fulfilled for this model
+ */
+export declare type SinglePeriodImageModelStats = Record;
+export interface ImageTotalStats {
+ minute?: SinglePeriodImageStats;
+ hour?: SinglePeriodImageStats;
+ day?: SinglePeriodImageStats;
+ month?: SinglePeriodImageStats;
+ total?: SinglePeriodImageStats;
+}
+export interface SinglePeriodImageStats {
+ /** The amount of text requests generated during this period. */
+ requests?: number;
+ /** The amount of tokens generated during this period. */
+ tokens?: number;
+}
+export interface TextModelStats {
+ day?: SinglePeriodTextModelStats;
+ month?: SinglePeriodTextModelStats;
+ total?: SinglePeriodTextModelStats;
+}
+/**
+ * string - Model Name
+ * number - The amount of requests fulfilled for this model
+ */
+export declare type SinglePeriodTextModelStats = Record;
+export interface TextTotalStats {
+ minute?: SinglePeriodTextStats;
+ hour?: SinglePeriodTextStats;
+ day?: SinglePeriodTextStats;
+ month?: SinglePeriodTextStats;
+ total?: SinglePeriodTextStats;
+}
+export interface SinglePeriodTextStats {
+ /** The amount of text requests generated during this period. */
+ requests?: number;
+ /** The amount of tokens generated during this period. */
+ tokens?: number;
+}
+/**
+ * AI Horde Ratings
+ */
+declare enum RatingArtifactsRatings {
+ "FLAWLESS" = 0,
+ "LITTLE_FLAWS" = 1,
+ "SOME_FLAWS" = 2,
+ "OBVIOUS_FLAWS" = 3,
+ "HARMFUL_FLAWS" = 4,
+ "GARBAGE" = 5
+}
+declare class AIHordeRatings {
+ #private;
+ static readonly RatingArtifactsRatings: typeof RatingArtifactsRatings;
+ readonly RatingArtifactsRatings: typeof RatingArtifactsRatings;
+ static readonly APIError: typeof APIError;
+ readonly APIError: typeof APIError;
+ constructor(options: AIHordeRatingsInitOptions);
+ /**
+ * Display all datasets
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RatingsDatasetResponse - The datasets
+ */
+ getDatasets(options?: {
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Display all public teams
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns RatingsTeamsResponse - The datasets
+ */
+ getTeams(options?: {
+ fields?: T[];
+ }): Promise[]>;
+ /**
+ * Retrieve an image to rate from the default dataset
+ * @param image_options.dataset_id - The ID of the dataset to get an image from
+ * @param image_options.model_name - The model name to get an image from
+ * @param options.token - The token of the requesting user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns DatasetImagePopResponse - An images data to rate
+ */
+ getNewRating(image_options?: {
+ dataset_id: string;
+ model_name?: string;
+ }, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+ /** POST ENDPOINTS */
+ /**
+ * Check if there are interrogation requests queued for fulfillment
+ * This endpoint is used by registered workers only
+ * @param image_id - The ID if the Image you want to rate
+ * @param rating
+ * @param options.token - The token of the requesting user
+ * @param options.fields - Array of fields that will be included in the returned data
+ * @returns InterrogationPopPayload
+ */
+ postRating(image_id: string, rating: RatePostInput, options?: {
+ token?: string;
+ fields?: T[];
+ }): Promise>;
+}
+/**
+ * Internal Interfaces
+ */
+export interface AIHordeRatingsInitOptions {
+ /** The default token to use for requests */
+ default_token?: string;
+ /** The base api domain + route to use for requests */
+ api_route?: string;
+ /** The client agent to pass in the requests. */
+ client_agent: string;
+}
+/**
+ * API Interfaces
+ */
+export interface DatasetGetResponse {
+ /**
+ * The unique identifier for this dataset
+ * @example 00000000-0000-0000-0000-000000000000
+ */
+ id?: string;
+ /**
+ * The name of this dataset
+ * @example My Dataset
+ */
+ name?: string;
+ /**
+ * The description of this dataset
+ * @example This is a dataset of images of cats
+ */
+ description?: string;
+ /**
+ * The number of images in this dataset
+ * @example 100
+ */
+ image_count?: number;
+}
+export interface TeamsGetResponse {
+ /**
+ * The unique identifier for this team
+ * @example 00000000-0000-0000-0000-000000000000
+ */
+ id?: string;
+ /**
+ * The name of this team
+ * @example My Team
+ */
+ team_name?: string;
+ /**
+ * Whether this team is private or not
+ * @example false
+ */
+ is_private?: boolean;
+}
+export interface DatasetImagePopResponse {
+ /**
+ * The UUID of the image to rate
+ * @example 00000000-0000-0000-0000-000000000000
+ */
+ id?: string;
+ /**
+ * The URL from which to download the image
+ * @example https://cdn.droom.cloud/00000000-0000-0000-0000-000000000000.webp
+ */
+ url?: string;
+ /**
+ * The UUID of the dataset in which this image belongs
+ * @example 00000000-0000-0000-0000-000000000000
+ */
+ dataset_id?: string;
+}
+export interface RatingRequestError {
+ /** The error message for this status code. */
+ message: string;
+}
+export interface RatePostInput {
+ /**
+ * The aesthetic rating for this image. How much do you like this image subjectively and in isolation from comparison with other images or with its own prompt.
+ * @example 5
+ * @minimum 1
+ * @maximum 10
+ */
+ rating: number;
+ /**
+ * The artifacts rating for this image.
+ * 0 for flawless generation that perfectly fits to the prompt.
+ * 1 for small, hardly recognizable flaws.
+ * 2 small flaws that can easily be spotted, but don not harm the aesthetic experience.
+ * 3 for flaws that look obviously wrong, but only mildly harm the aesthetic experience.
+ * 4 for flaws that look obviously wrong & significantly harm the aesthetic experience.
+ * 5 for flaws that make the image look like total garbage
+ * @example 1
+ * @minimum 0
+ * @maximum 5
+ */
+ artifacts?: typeof AIHordeRatings.RatingArtifactsRatings[keyof typeof AIHordeRatings.RatingArtifactsRatings];
+}
+export interface RatePostResponse {
+ /**
+ * The amount of kudos awarded for this rating
+ * @example 5
+ * @minimum 1
+ */
+ reward: number;
+ /**
+ * Any extra information about the submitted rating
+ * @example Rating submitted
+ */
+ message: string;
+}
diff --git a/src/horde/index.js b/src/horde/index.js
new file mode 100644
index 000000000..b465f8ec0
--- /dev/null
+++ b/src/horde/index.js
@@ -0,0 +1 @@
+var ue=Object.create;var q=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.getPrototypeOf;var pe=Object.prototype.hasOwnProperty;var ke=(d,e,t)=>e in d?q(d,e,{enumerable:true,configurable:true,writable:true,value:t}):d[e]=t;var J=d=>q(d,"__esModule",{value:true});var P=(d,e)=>q(d,"name",{value:e,configurable:true});var M=(d,e)=>()=>(e||d((e={exports:{}}).exports,e),e.exports);var be=(d,e,t)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let s of ge(e))if(!pe.call(d,s)&&s!=="default")q(d,s,{get:()=>e[s],enumerable:!(t=fe(e,s))||t.enumerable})}return d};var G=d=>{return be(J(q(d!=null?ue(me(d)):{},"default",d&&d.__esModule&&"default"in d?{get:()=>d.default,enumerable:true}:{value:d,enumerable:true})),d)};var T=(d,e,t)=>{ke(d,typeof e!=="symbol"?e+"":e,t);return t};var O=(d,e,t)=>{if(!e.has(d))throw TypeError("Cannot "+t)};var i=(d,e,t)=>{O(d,e,"read from private field");return t?t.call(d):e.get(d)};var y=(d,e,t)=>{if(e.has(d))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(d):e.set(d,t)};var A=(d,e,t,s)=>{O(d,e,"write to private field");s?s.call(d,t):e.set(d,t);return t};var m=(d,e,t)=>{O(d,e,"access private method");return t};var ee=M((Q,Y)=>{var Z=Object.defineProperty;var we=P(d=>Z(d,"__esModule",{value:true}),"f");var Te=P((d,e)=>Z(d,"name",{value:e,configurable:true}),"h");we(Q);var _=Symbol("supermap.date_cache");var H=P(class extends Map{#e;[_]=null;#t=null;constructor(d={}){if("intervalTime"in d&&(!Number.isSafeInteger(d.intervalTime)||d.intervalTime<0))throw new TypeError("options.intervalTime must be a safe positive integer.");if("expireAfter"in d&&(!Number.isSafeInteger(d.expireAfter)||d.expireAfter<0))throw new TypeError("options.expireAfter must be a safe positive integer.");if("itemsLimit"in d&&(!Number.isSafeInteger(d.itemsLimit)||d.itemsLimit<0))throw new TypeError("options.itemsLimit must be a safe positive integer.");if("onSweep"in d&&typeof d.onSweep!=="function")throw new TypeError("options.onSweep must be a function.");d={expireAfter:0,itemsLimit:0,...d};super();this.#e=d;if("intervalTime"in d){this[_]=new Map;this.startInterval()}}toArray(){return Array.from(this.entries())}delete(d){return this[_]?.delete(d),super.delete(d)}set(d,e,t=0){if(!Number.isSafeInteger(t))throw new TypeError("ttl must be a safe integer");const s=this.#e.itemsLimit;if(s>0&&this.size>=s&&!this.has(d)){this.delete(this.first(true))}this[_]?.set(d,Date.now()+t);return super.set(d,e)}clear(d=false){if(d)this.stopInterval();else this[_]?.clear();return super.clear()}first(d){return d?this.keys().next().value:this.values().next().value}last(d=false){const e=this.entries();let t;while(true){const s=e.next();if(s.done)return t&&t[d?0:1];t=s.value}}some(d){const e=this.entries();while(true){const t=e.next();if(t.done)return false;if(d(t.value[1],t.value[0],this))return true}}every(d){const e=this.entries();while(true){const t=e.next();if(t.done)return true;if(!d(t.value[1],t.value[0],this))return false}}sweep(d){if(this.size===0)return-1;const e=this.#e.onSweep;const t=this.size;super.forEach((s,n)=>{if(d(s,n,this)){e?.(s,n);this.delete(n)}});return t-this.size}filter(d){const e=new H(this.#e);const t=this.entries();while(true){const s=t.next();if(s.done)return e;const[n,a]=s.value;if(d(a,n,this))e.set(n,a)}}map(d,e){return Array.from(this.#r(d,e))}find(d,e=false){const t=this.entries();while(true){const s=t.next();if(s.done)return null;const[n,a]=s.value;if(d(a,n,this))return e?n:a}}reduce(d,e){const t=this.entries();var s=e;while(true){const n=t.next();if(n.done)return s;s=d(s,n.value[1],n.value[0],this)}}concat(...d){const e=new H(this.#e);e[_]=this[_];for(const t of d.concat(this)){const s=t.entries();while(true){const n=s.next();if(n.done)break;e.set(...n.value)}}return e}concatMut(...d){for(const e of d){const t=e.entries();while(true){const s=t.next();if(s.done)break;this.set(...s.value)}}return this}sort(d){this.toArray().sort(([e,t],[s,n])=>d(t,n,e,s,this)).forEach(e=>this.set(...e));this.clear();return this}startInterval(){if(this[_]===null||!("intervalTime"in this.#e)){return false}this.stopInterval();this.#t=setInterval(()=>this.#s(),this.#e.intervalTime).unref();return true}stopInterval(){if(this[_]===null)return false;this[_].clear();if(this.#t!==null){clearInterval(this.#t);this.#t=null}return true}#s(){const d=this.entries(),e=this[_].entries();const t=Date.now()-this.#e.expireAfter;const s=this.#e.onSweep;while(true){const n=d.next();if(n.done)return;if(t>(e.next().value?.[1]||0)){const a=n.value[0];s?.(n.value[1],a);this.delete(a)}}}*#r(d,e){const t=this.entries();if(e){while(true){const s=t.next();if(s.done)return;const[n,a]=s.value;if(e(a,n,this)){yield d(a,n,this)}}}while(true){const s=t.next();if(s.done)return;yield d(s.value[1],s.value[0],this)}}},"u");Te(H,"SuperMap");Y.exports=H});var re=M((qe,se)=>{se.exports=P(class Ce{constructor(e,t){this.coreRes=e;this.resOptions=t;this.body=Buffer.alloc(0);this.headers=e.headers;this.statusCode=e.statusCode}_addChunk(e){this.body=Buffer.concat([this.body,e])}async json(){return this.statusCode===204?null:JSON.parse(this.body)}async text(){return this.body.toString()}},"CentraResponse")});var ae=M((Fe,ne)=>{var Pe=require("path");var ye=require("http");var _e=require("https");var xe=require("querystring");var ie=require("zlib");var{URL:Se}=require("url");var Ae=re();var je=["gzip","deflate"];ne.exports=P(class De{constructor(e,t="GET"){this.url=typeof e==="string"?new Se(e):e;this.method=t;this.data=null;this.sendDataAs=null;this.reqHeaders={};this.streamEnabled=false;this.compressionEnabled=false;this.timeoutTime=null;this.coreOptions={};this.resOptions={"maxBuffer":50*1e6};return this}query(e,t){if(typeof e==="object"){Object.keys(e).forEach(s=>{this.url.searchParams.append(s,e[s])})}else this.url.searchParams.append(e,t);return this}path(e){this.url.pathname=Pe.join(this.url.pathname,e);return this}body(e,t){this.sendDataAs=typeof e==="object"&&!t&&!Buffer.isBuffer(e)?"json":t?t.toLowerCase():"buffer";this.data=this.sendDataAs==="form"?xe.stringify(e):this.sendDataAs==="json"?JSON.stringify(e):e;return this}header(e,t){if(typeof e==="object"){Object.keys(e).forEach(s=>{this.reqHeaders[s.toLowerCase()]=e[s]})}else this.reqHeaders[e.toLowerCase()]=t;return this}timeout(e){this.timeoutTime=e;return this}option(e,t){this.coreOptions[e]=t;return this}stream(){this.streamEnabled=true;return this}compress(){this.compressionEnabled=true;if(!this.reqHeaders["accept-encoding"])this.reqHeaders["accept-encoding"]=je.join(", ");return this}send(){return new Promise((e,t)=>{if(this.data){if(!this.reqHeaders.hasOwnProperty("content-type")){if(this.sendDataAs==="json"){this.reqHeaders["content-type"]="application/json"}else if(this.sendDataAs==="form"){this.reqHeaders["content-type"]="application/x-www-form-urlencoded"}}if(!this.reqHeaders.hasOwnProperty("content-length")){this.reqHeaders["content-length"]=Buffer.byteLength(this.data)}}const s=Object.assign({"protocol":this.url.protocol,"host":this.url.hostname,"port":this.url.port,"path":this.url.pathname+(this.url.search===null?"":this.url.search),"method":this.method,"headers":this.reqHeaders},this.coreOptions);let n;const a=P(r=>{let o=r;if(this.compressionEnabled){if(r.headers["content-encoding"]==="gzip"){o=r.pipe(ie.createGunzip())}else if(r.headers["content-encoding"]==="deflate"){o=r.pipe(ie.createInflate())}}let h;if(this.streamEnabled){e(o)}else{h=new Ae(r,this.resOptions);o.on("error",l=>{t(l)});o.on("aborted",()=>{t(new Error("Server aborted request"))});o.on("data",l=>{h._addChunk(l);if(this.resOptions.maxBuffer!==null&&h.body.length>this.resOptions.maxBuffer){o.destroy();t("Received a response which was longer than acceptable when buffering. ("+this.body.length+" bytes)")}});o.on("end",()=>{e(h)})}},"resHandler");if(this.url.protocol==="http:"){n=ye.request(s,a)}else if(this.url.protocol==="https:"){n=_e.request(s,a)}else throw new Error("Bad URL protocol: "+this.url.protocol);if(this.timeoutTime){n.setTimeout(this.timeoutTime,()=>{n.abort();if(!this.streamEnabled){t(new Error("Timeout reached"))}})}n.on("error",r=>{t(r)});if(this.data)n.write(this.data);n.end()})}},"CentraRequest")});var de=M((ve,oe)=>{var Ie=ae();oe.exports=(d,e)=>{return new Ie(d,e)}});J(exports);var te=G(ee());var x=te.default;var u=G(de());var le=G(require("fs"));var ce=G(require("path"));var X;(function(w){w["k_lms"]="k_lms";w["k_heun"]="k_heun";w["k_euler"]="k_euler";w["k_dpm_2"]="k_dpm_2";w["k_dpm_2_a"]="k_dpm_2_a";w["DDIM"]="DDIM";w["PLMS"]="PLMS";w["k_dpm_fast"]="k_dpm_fast";w["k_dpm_adaptive"]="k_dpm_adaptive";w["k_dpmpp_2s_a"]="k_dpmpp_2s_a";w["k_dpmpp_2m"]="k_dpmpp_2m";w["dpmsolver"]="dpmsolver"})(X||(X={}));var N;(function(s){s["img2img"]="img2img";s["inpainting"]="inpainting";s["outpainting"]="outpainting"})(N||(N={}));var L;(function(s){s["GFPGAN"]="GFPGAN";s["RealESRGAN_x4plus"]="RealESRGAN_x4plus";s["CodeFormers"]="CodeFormers"})(L||(L={}));var W;(function(l){l["caption"]="caption";l["interrogation"]="interrogation";l["nsfw"]="nsfw";l["GFPGAN"]="GFPGAN";l["RealESRGAN_x4plus"]="RealESRGAN_x4plus";l["RealESRGAN_x4plus_anime_6B"]="RealESRGAN_x4plus_anime_6B";l["NMKD_Siax"]="NMKD_Siax";l["4x_AnimeSharp"]="4x_AnimeSharp";l["CodeFormers"]="CodeFormers";l["strip_background"]="strip_background"})(W||(W={}));var K;(function(r){r["waiting"]="waiting";r["processing"]="processing";r["done"]="done";r["faulted"]="faulted";r["partial"]="partial";r["cancelled"]="cancelled"})(K||(K={}));var B;(function(l){l["canny"]="canny";l["hed"]="hed";l["depth"]="depth";l["normal"]="normal";l["openpose"]="openpose";l["seg"]="seg";l["scribble"]="scribble";l["fakescribbles"]="fakescribbles";l["hough"]="hough"})(B||(B={}));var U=class extends Error{rawError;status;method;url;requestBody;constructor(e,t,s){super();this.rawError=e;this.status=t.statusCode??0;this.method=t.method??"GET";this.url=t.url??"";this.requestBody=s}get name(){return this.rawError.message}};P(U,"APIError");var F,g,p,f,c,k,b,j,C;var I=class{constructor(e){y(this,k);y(this,j);T(this,"ModelGenerationInputStableSamplers",I.ModelGenerationInputStableSamplers);T(this,"SourceImageProcessingTypes",I.SourceImageProcessingTypes);T(this,"ModelGenerationInputPostProcessingTypes",I.ModelGenerationInputPostProcessingTypes);T(this,"ModelGenerationInputControlTypes",I.ModelGenerationInputControlTypes);T(this,"ModelInterrogationFormTypes",I.ModelInterrogationFormTypes);T(this,"HordeAsyncRequestStates",I.HordeAsyncRequestStates);T(this,"APIError",I.APIError);y(this,F,void 0);y(this,g,void 0);y(this,p,void 0);y(this,f,void 0);T(this,"VERSION");y(this,c,void 0);T(this,"ratings");A(this,F,e?.default_token);A(this,f,e?.api_route??"https://aihorde.net/api/v2");A(this,g,{users:e?.cache?.users??0,generations_check:e?.cache?.generations_check??0,generations_status:e?.cache?.generations_status??0,interrogations_status:e?.cache?.interrogations_status??0,models:e?.cache?.models??0,modes:e?.cache?.modes??0,news:e?.cache?.news??0,performance:e?.cache?.performance??0,workers:e?.cache?.workers??0,teams:e?.cache?.teams??0});if(Object.values(i(this,g)).some(t=>!Number.isSafeInteger(t)||t<0))throw new TypeError("Every cache duration must be a positive safe integer");A(this,p,{users:i(this,g).users?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).users}):void 0,generations_check:i(this,g).generations_check?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).generations_check}):void 0,generations_status:i(this,g).generations_status?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).generations_status}):void 0,interrogations_status:i(this,g).interrogations_status?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).interrogations_status}):void 0,models:i(this,g).models?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).models}):void 0,modes:i(this,g).modes?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).modes}):void 0,news:i(this,g).news?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).news}):void 0,performance:i(this,g).performance?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).performance}):void 0,workers:i(this,g).workers?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).workers}):void 0,teams:i(this,g).teams?new x({intervalTime:e?.cache_interval??1e3,expireAfter:i(this,g).teams}):void 0});try{let t=JSON.parse((0,le.readFileSync)((0,ce.join)(__dirname,"./package.json"),"utf-8"));A(this,c,e?.client_agent??`${t.name}:${t.version}:${t.bugs?.slice(8)}`);this.VERSION=t.version}catch{A(this,c,e?.client_agent??`@zeldafan0225/ai_horde:Version_Unknown:github.com/ZeldaFan0225/ai_horde/issues`);this.VERSION="Unknown"}this.ratings=new D({api_route:e?.ratings_api_route??"https://ratings.aihorde.net/api/v1",default_token:e?.default_token,client_agent:i(this,c)})}clearCache(){Object.values(i(this,p)).forEach(e=>e.clear())}get cache(){return i(this,p)}parseAgent(e){const[t,s,n]=e.split(":");return{name:t,version:s,link:n}}generateFieldsString(e){return e?.join(",")}async findUser(e){const{result:t,fields_string:s}=await m(this,j,C).call(this,"/find_user","GET",e);if(t.statusCode===404)throw new this.APIError(await t.json().then(a=>a),t.coreRes);const n=await t.json();if(i(this,g).users){const a=n;if("id"in a)i(this,p).users?.set(a.id+s,n)}return n}async getUserDetails(e,t){const s=this.generateFieldsString(t?.fields);const n=m(this,k,b).call(this,t?.token);const a=!t?.force&&i(this,p).users?.get(e.toString()+s);if(a)return a;const{result:r}=await m(this,j,C).call(this,`/users/${e}`,"GET",{fields_string:s,token:n});if(r.statusCode===404)throw new this.APIError(await r.json().then(h=>h),r.coreRes);const o=await r.json();if(i(this,g).users){const h=o;if("id"in h)i(this,p).users?.set(h.id+s,o)}return o}async getTeam(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=!t?.force&&i(this,p).teams?.get(e+s);if(a)return a;const r=(0,u.default)(`${i(this,f)}/teams/${e}`,"GET").header("Client-Agent",i(this,c)).header("apikey",n);if(s)r.header("X-Fields",s);const o=await r.send();switch(o.statusCode){case 401:case 403:case 404:{throw new this.APIError(await o.json().then(l=>l),o.coreRes)}}const h=await o.json();if(i(this,g).teams){const l=h;if("id"in l)i(this,p).teams?.set(l.id+s,h)}return h}async getWorkerDetails(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=!t?.force&&i(this,p).workers?.get(e+s);if(a)return a;const r=(0,u.default)(`${i(this,f)}/workers/${e}`,"GET").header("Client-Agent",i(this,c)).header("apikey",n);if(s)r.header("X-Fields",s);const o=await r.send();switch(o.statusCode){case 401:case 403:case 404:{throw new this.APIError(await o.json().then(l=>l),o.coreRes)}}const h=await o.json();if(i(this,g).workers){const l=h;if("id"in l)i(this,p).workers?.set(l.id+s,h)}return h}async getImageGenerationCheck(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=!t?.force&&i(this,p).generations_check?.get(e+s);if(n)return n;const a=(0,u.default)(`${i(this,f)}/generate/check/${e}`,"GET").header("Client-Agent",i(this,c));if(s)a.header("X-Fields",s);const r=await a.send();if(r.statusCode===404)throw new this.APIError(await r.json().then(h=>h),r.coreRes);const o=await r.json();if(i(this,g).generations_check)i(this,p).generations_check?.set(e+s,o);return o}async getImageGenerationStatus(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=!t?.force&&i(this,p).generations_status?.get(e);if(n)return n;const a=(0,u.default)(`${i(this,f)}/generate/status/${e}`,"GET").header("Client-Agent",i(this,c));if(s)a.header("X-Fields",s);const r=await a.send();if(r.statusCode===404)throw new this.APIError(await r.json().then(h=>h),r.coreRes);const o=await r.json();if(i(this,g).generations_status)i(this,p).generations_status?.set(e+s,o);return o}async getTextGenerationStatus(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=!t?.force&&i(this,p).generations_status?.get(e);if(n)return n;const a=(0,u.default)(`${i(this,f)}/generate/text/status/${e}`,"GET").header("Client-Agent",i(this,c));if(s)a.header("X-Fields",s);const r=await a.send();if(r.statusCode===404)throw new this.APIError(await r.json().then(h=>h),r.coreRes);const o=await r.json();if(i(this,g).generations_status)i(this,p).generations_status?.set(e+s,o);return o}async getInterrogationStatus(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=!t?.force&&i(this,p).interrogations_status?.get(e+s);if(n)return n;const a=(0,u.default)(`${i(this,f)}/interrogate/status/${e}`,"GET").header("Client-Agent",i(this,c));if(s)a.header("X-Fields",s);const r=await a.send();if(r.statusCode===404)throw new this.APIError(await r.json().then(h=>h),r.coreRes);const o=await r.json();if(i(this,g).interrogations_status)i(this,p).interrogations_status?.set(e+s,o);return o}async getHeartbeat(){await(0,u.default)(`${i(this,f)}/status/heartbeat`,"GET").header("Client-Agent",i(this,c)).send();return true}async getModels(e){const t=e?.fields?.length?e.fields.join(","):"";const s=!e?.force&&i(this,p).models?.get("CACHE-MODELS"+t);if(s)return s;const n=(0,u.default)(`${i(this,f)}/status/models`,"GET").header("Client-Agent",i(this,c));if(t)n.header("X-Fields",t);const a=await n.send();const r=await a.json();if(i(this,g).models)i(this,p).models?.set("CACHE-MODELS"+t,r);return r}async getModes(e){const t=e?.fields?.length?e.fields.join(","):"";const s=m(this,k,b).call(this,e?.token);const n=!e?.force&&i(this,p).modes?.get("CACHE-MODES"+t);if(n)return n;const a=(0,u.default)(`${i(this,f)}/status/modes`,"GET").header("Client-Agent",i(this,c)).header("apikey",s);if(t)a.header("X-Fields",t);const r=await a.send();const o=await r.json();if(i(this,g).modes)i(this,p).modes?.set("CACHE-MODES"+t,o);return o}async getNews(e){const t=e?.fields?.length?e.fields.join(","):"";const s=!e?.force&&i(this,p).news?.get("CACHE-NEWS"+t);if(s)return s;const n=(0,u.default)(`${i(this,f)}/status/news`,"GET").header("Client-Agent",i(this,c));if(t)n.header("X-Fields",t);const a=await n.send();const r=await a.json();if(i(this,g).news)i(this,p).news?.set("CACHE-NEWS"+t,r);return r}async getPerformance(e){const t=e?.fields?.length?e.fields.join(","):"";const s=!e?.force&&i(this,p).performance?.get("CACHE-PERFORMANCE"+t);if(s)return s;const n=(0,u.default)(`${i(this,f)}/status/performance`,"GET").header("Client-Agent",i(this,c));if(t)n.header("X-Fields",t);const a=await n.send();const r=await a.json();if(i(this,g).performance)i(this,p).performance?.set("CACHE-PERFORMANCE"+t,r);return r}async getUsers(e){const t=e?.fields?.length?e.fields.join(","):"";const s=(0,u.default)(`${i(this,f)}/users`,"GET").header("Client-Agent",i(this,c));if(t)s.header("X-Fields",t);const n=await s.send();const a=await n.json();if(i(this,g).users)a.forEach(r=>{const o=r;if("id"in o)i(this,p).users?.set(o.id+t,r)});return a}async getWorkers(e){const t=e?.fields?.length?e?.fields.join(","):"";const s=(0,u.default)(`${i(this,f)}/workers`,"GET").header("Client-Agent",i(this,c));if(t)s.header("X-Fields",t);const n=await s.send();const a=await n.json();if(i(this,g).workers)a.forEach(r=>{const o=a;if("id"in o)i(this,p).workers?.set(o.id+t,r)});return a}async getImageModelStats(e){const t=e?.fields?.length?e.fields.join(","):"";const{result:s}=await m(this,j,C).call(this,"/stats/img/models","GET",{fields:e?.fields,fields_string:t});const n=await s.json();return n}async getImageTotalStats(e){const t=e?.fields?.length?e.fields.join(","):"";const{result:s}=await m(this,j,C).call(this,"/stats/img/totals","GET",{fields:e?.fields,fields_string:t});const n=await s.json();return n}async getTextModelStats(e){const t=e?.fields?.length?e.fields.join(","):"";const{result:s}=await m(this,j,C).call(this,"/stats/text/models","GET",{fields:e?.fields,fields_string:t});const n=await s.json();return n}async getTextTotalStats(e){const t=e?.fields?.length?e.fields.join(","):"";const{result:s}=await m(this,j,C).call(this,"/stats/text/totals","GET",{fields:e?.fields,fields_string:t});const n=await s.json();return n}async getTeams(e){const t=e?.fields?.length?e?.fields.join(","):"";const s=(0,u.default)(`${i(this,f)}/teams`,"GET").header("Client-Agent",i(this,c));if(t)s.header("X-Fields",t);const n=await s.send();const a=await n.json();if(i(this,g).teams)a.forEach(r=>{const o=r;if("id"in o)i(this,p).teams?.set(o.id+t,r)});return a}async getFilters(e,t){const s=t?.fields?.length?t?.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/filters`,"GET").header("Client-Agent",i(this,c)).header("apikey",n);if(s)a.header("X-Fields",s);if(e)a.header("filter_type",e);const r=await a.send();const o=await r.json();return o}async getFilter(e,t){const s=t?.fields?.length?t?.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/filters/${e}`,"GET").header("Client-Agent",i(this,c)).header("apikey",n);if(s)a.header("X-Fields",s);const r=await a.send();const o=await r.json();return o}async postFilters(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/filters`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postAsyncImageGenerate(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/async`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 429:case 503:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postAsyncTextGenerate(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/text/async`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 429:case 503:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postRating(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/generate/rate/${e}`,"POST").header("Client-Agent",i(this,c)).header("apikey",a).body(t,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 429:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,t)}}return await o.json()}async postImageGenerationPop(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/pop`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 401:case 403:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postTextGenerationPop(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/text/pop`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 401:case 403:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postImageGenerationSubmit(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/submit`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 402:case 404:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postTextGenerationSubmit(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/generate/text/submit`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 402:case 404:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postAsyncInterrogate(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/interrogate/async`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 429:case 503:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postInterrogationPop(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/interrogate/pop`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postInterrogationSubmit(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/interrogate/submit`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:case 404:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postKudosTransfer(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/kudos/transfer`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async postKoboldTransfer(e,t,s){const n=m(this,k,b).call(this,s?.token);const a=(0,u.default)(`${i(this,f)}/kudos/kai/${e}`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(t,"json");const r=await a.send();switch(r.statusCode){case 400:case 401:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,t)}}return null}async createTeam(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/teams`,"POST").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async putStatusModes(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/status/modes`,"PUT").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 401:case 402:{throw new this.APIError(await r.json().then(o=>o),r.coreRes,e)}}return await r.json()}async updateUser(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/users/${t}`,"PUT").header("Client-Agent",i(this,c)).header("apikey",a).body(e,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 402:case 404:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,e)}}if(i(this,g).users)i(this,p).users?.delete(t.toString()+n);return await o.json()}async updateWorker(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/workers/${t}`,"PUT").header("Client-Agent",i(this,c)).header("apikey",a).body(e,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 402:case 404:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,e)}}if(i(this,g).workers)i(this,p).workers?.delete(t);return await o.json()}async updateTeam(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/teams/${t}`,"PATCH").header("Client-Agent",i(this,c)).header("apikey",a).body(e,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 403:case 404:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,e)}}if(i(this,g).teams)i(this,p).teams?.delete(t);return await o.json()}async addFilter(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/filters`,"PUT").header("Client-Agent",i(this,c)).header("apikey",a).body(e,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,e)}}return await o.json()}async updateFilter(e,t,s){const n=s?.fields?.length?s.fields.join(","):"";const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}/filters/${t}`,"PATCH").header("Client-Agent",i(this,c)).header("apikey",a).body(e,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 404:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,e)}}return await o.json()}async deleteImageGenerationRequest(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=(0,u.default)(`${i(this,f)}/generate/status/${e}`,"DELETE").header("Client-Agent",i(this,c));if(s)n.header("X-Fields",s);const a=await n.send();switch(a.statusCode){case 404:{throw new this.APIError(await a.json().then(o=>o),a.coreRes)}}const r=await a.json();if(i(this,g).generations_status)i(this,p).generations_status?.set(e+s,r);return r}async deleteTextGenerationRequest(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=(0,u.default)(`${i(this,f)}/generate/text/status/${e}`,"DELETE").header("Client-Agent",i(this,c));if(s)n.header("X-Fields",s);const a=await n.send();switch(a.statusCode){case 404:{throw new this.APIError(await a.json().then(o=>o),a.coreRes)}}const r=await a.json();if(i(this,g).generations_status)i(this,p).generations_status?.set(e+s,r);return r}async deleteInterrogationRequest(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=(0,u.default)(`${i(this,f)}/interrogate/status/${e}`,"DELETE").header("Client-Agent",i(this,c));if(s)n.header("X-Fields",s);const a=await n.send();switch(a.statusCode){case 404:{throw new this.APIError(await a.json().then(o=>o),a.coreRes)}}const r=await a.json();if(i(this,g).interrogations_status)i(this,p).interrogations_status?.set(e+s,r);return r}async deleteWorker(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/workers/${e}`,"DELETE").header("Client-Agent",i(this,c)).header("apikey",n);if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 401:case 402:case 404:{throw new this.APIError(await r.json().then(h=>h),r.coreRes)}}const o=await r.json();i(this,p).workers?.delete(e);return o}async deleteTeam(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/teams/${e}`,"DELETE").header("Client-Agent",i(this,c)).header("apikey",n);if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 401:case 403:case 404:{throw new this.APIError(await r.json().then(h=>h),r.coreRes)}}const o=await r.json();i(this,p).teams?.delete(e+s);return o}async deleteIPTimeout(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/operations/ipaddr`,"DELETE").header("Client-Agent",i(this,c)).header("apikey",n).body(e,"json");if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:{throw new this.APIError(await r.json().then(h=>h),r.coreRes,e)}}const o=await r.json();return o}async deleteFilter(e,t){const s=t?.fields?.length?t.fields.join(","):"";const n=m(this,k,b).call(this,t?.token);const a=(0,u.default)(`${i(this,f)}/filters/${e}`,"DELETE").header("Client-Agent",i(this,c)).header("apikey",n);if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:{throw new this.APIError(await r.json().then(h=>h),r.coreRes)}}const o=await r.json();return o}};var S=I;P(S,"AIHorde");F=new WeakMap;g=new WeakMap;p=new WeakMap;f=new WeakMap;c=new WeakMap;k=new WeakSet;b=P(function(e){return e||i(this,F)||"0000000000"},"#getToken");j=new WeakSet;C=P(async function(e,t,s){const n=s?.fields?.join(",")||s?.fields_string;const a=m(this,k,b).call(this,s?.token);const r=(0,u.default)(`${i(this,f)}${e}`,t).header("Client-Agent",i(this,c));if(s?.token)r.header("apikey",a);if(s?.body)r.body(s.body,"json");if(n)r.header("X-Fields",n);const o=await r.send();return{result:o,fields_string:n}},"#request");T(S,"ModelGenerationInputStableSamplers",X);T(S,"SourceImageProcessingTypes",N);T(S,"ModelGenerationInputPostProcessingTypes",L);T(S,"ModelGenerationInputControlTypes",B);T(S,"ModelInterrogationFormTypes",W);T(S,"HordeAsyncRequestStates",K);T(S,"APIError",U);var V;(function(r){r[r["FLAWLESS"]=0]="FLAWLESS";r[r["LITTLE_FLAWS"]=1]="LITTLE_FLAWS";r[r["SOME_FLAWS"]=2]="SOME_FLAWS";r[r["OBVIOUS_FLAWS"]=3]="OBVIOUS_FLAWS";r[r["HARMFUL_FLAWS"]=4]="HARMFUL_FLAWS";r[r["GARBAGE"]=5]="GARBAGE"})(V||(V={}));var v,E,R,$,he;var z=class{constructor(e){y(this,$);T(this,"RatingArtifactsRatings",z.RatingArtifactsRatings);T(this,"APIError",S.APIError);y(this,v,void 0);y(this,E,void 0);y(this,R,void 0);A(this,v,e.default_token);A(this,E,e.api_route??"https://ratings.aihorde.net/api/v1");A(this,R,e.client_agent)}async getDatasets(e){const t=e?.fields?.length?e?.fields.join(","):"";const s=(0,u.default)(`${i(this,E)}/datasets`,"GET").header("Client-Agent",i(this,R));if(t)s.header("X-Fields",t);const n=await s.send();const a=await n.json();return a}async getTeams(e){const t=e?.fields?.length?e?.fields.join(","):"";const s=(0,u.default)(`${i(this,E)}/teams`,"GET").header("Client-Agent",i(this,R));if(t)s.header("X-Fields",t);const n=await s.send();const a=await n.json();return a}async getNewRating(e,t){const s=t?.fields?.length?t?.fields.join(","):"";const n=m(this,$,he).call(this,t?.token);const a=(0,u.default)(`${i(this,E)}/rating/new${e?.dataset_id?`/${e.dataset_id}${e?.model_name?`/${e.model_name}`:""}`:""}`,"GET").header("Client-Agent",i(this,R)).header("apikey",n);if(s)a.header("X-Fields",s);const r=await a.send();switch(r.statusCode){case 400:case 401:case 403:case 500:{throw new this.APIError(await r.json().then(h=>h),r.coreRes,{})}}const o=await r.json();return o}async postRating(e,t,s){const n=s?.fields?.length?s?.fields.join(","):"";const a=m(this,$,he).call(this,s?.token);const r=(0,u.default)(`${i(this,E)}/rating/${e}`,"POST").header("Client-Agent",i(this,R)).header("apikey",a).body(t,"json");if(n)r.header("X-Fields",n);const o=await r.send();switch(o.statusCode){case 400:case 401:case 403:{throw new this.APIError(await o.json().then(h=>h),o.coreRes,t)}}return await o.json()}};var D=z;P(D,"AIHordeRatings");v=new WeakMap;E=new WeakMap;R=new WeakMap;$=new WeakSet;he=P(function(e){return e||i(this,v)||"0000000000"},"#getToken");T(D,"RatingArtifactsRatings",V);T(D,"APIError",U);module.exports=S;
diff --git a/src/horde/index.mjs b/src/horde/index.mjs
new file mode 100644
index 000000000..7597fdcd8
--- /dev/null
+++ b/src/horde/index.mjs
@@ -0,0 +1,3 @@
+import AIHorde from './index.js'
+export default AIHorde
+export { AIHorde }
\ No newline at end of file