modelfusion 0.100.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1411 -0
- package/core/api/BaseUrlApiConfiguration.d.ts +7 -6
- package/core/api/BaseUrlPartsApiConfiguration.cjs +53 -0
- package/core/api/BaseUrlPartsApiConfiguration.d.ts +26 -0
- package/core/api/BaseUrlPartsApiConfiguration.js +49 -0
- package/core/api/index.cjs +1 -0
- package/core/api/index.d.ts +1 -0
- package/core/api/index.js +1 -0
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.cjs +8 -9
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.d.ts +7 -9
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.js +8 -9
- package/model-provider/automatic1111/Automatic1111Error.cjs +7 -31
- package/model-provider/automatic1111/Automatic1111Error.d.ts +2 -11
- package/model-provider/automatic1111/Automatic1111Error.js +6 -28
- package/model-provider/automatic1111/Automatic1111Facade.cjs +10 -1
- package/model-provider/automatic1111/Automatic1111Facade.d.ts +7 -0
- package/model-provider/automatic1111/Automatic1111Facade.js +8 -0
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +22 -27
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +8 -8
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +22 -27
- package/model-provider/automatic1111/index.cjs +1 -3
- package/model-provider/automatic1111/index.d.ts +1 -1
- package/model-provider/automatic1111/index.js +0 -1
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +6 -6
- package/package.json +15 -15
@@ -1,6 +1,12 @@
|
|
1
1
|
import { AbstractApiConfiguration } from "./AbstractApiConfiguration.js";
|
2
2
|
import { RetryFunction } from "./RetryFunction.js";
|
3
3
|
import { ThrottleFunction } from "./ThrottleFunction.js";
|
4
|
+
export type BaseUrlApiConfigurationOptions = {
|
5
|
+
baseUrl: string;
|
6
|
+
headers: Record<string, string>;
|
7
|
+
retry?: RetryFunction;
|
8
|
+
throttle?: ThrottleFunction;
|
9
|
+
};
|
4
10
|
/**
|
5
11
|
* An API configuration that uses a base URL and a set of headers.
|
6
12
|
*
|
@@ -9,11 +15,6 @@ import { ThrottleFunction } from "./ThrottleFunction.js";
|
|
9
15
|
export declare class BaseUrlApiConfiguration extends AbstractApiConfiguration {
|
10
16
|
readonly baseUrl: string;
|
11
17
|
readonly headers: Record<string, string>;
|
12
|
-
constructor({ baseUrl, headers, retry, throttle, }:
|
13
|
-
baseUrl: string;
|
14
|
-
headers: Record<string, string>;
|
15
|
-
retry?: RetryFunction;
|
16
|
-
throttle?: ThrottleFunction;
|
17
|
-
});
|
18
|
+
constructor({ baseUrl, headers, retry, throttle, }: BaseUrlApiConfigurationOptions);
|
18
19
|
assembleUrl(path: string): string;
|
19
20
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BaseUrlPartsApiConfiguration = void 0;
|
4
|
+
const AbstractApiConfiguration_js_1 = require("./AbstractApiConfiguration.cjs");
|
5
|
+
/**
|
6
|
+
* An API configuration that uses different URL parts and a set of headers.
|
7
|
+
*
|
8
|
+
* You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
|
9
|
+
*/
|
10
|
+
class BaseUrlPartsApiConfiguration extends AbstractApiConfiguration_js_1.AbstractApiConfiguration {
|
11
|
+
constructor({ protocol, host, port, path, headers, retry, throttle, }) {
|
12
|
+
super({ retry, throttle });
|
13
|
+
Object.defineProperty(this, "protocol", {
|
14
|
+
enumerable: true,
|
15
|
+
configurable: true,
|
16
|
+
writable: true,
|
17
|
+
value: void 0
|
18
|
+
});
|
19
|
+
Object.defineProperty(this, "host", {
|
20
|
+
enumerable: true,
|
21
|
+
configurable: true,
|
22
|
+
writable: true,
|
23
|
+
value: void 0
|
24
|
+
});
|
25
|
+
Object.defineProperty(this, "port", {
|
26
|
+
enumerable: true,
|
27
|
+
configurable: true,
|
28
|
+
writable: true,
|
29
|
+
value: void 0
|
30
|
+
});
|
31
|
+
Object.defineProperty(this, "path", {
|
32
|
+
enumerable: true,
|
33
|
+
configurable: true,
|
34
|
+
writable: true,
|
35
|
+
value: void 0
|
36
|
+
});
|
37
|
+
Object.defineProperty(this, "headers", {
|
38
|
+
enumerable: true,
|
39
|
+
configurable: true,
|
40
|
+
writable: true,
|
41
|
+
value: void 0
|
42
|
+
});
|
43
|
+
this.protocol = protocol;
|
44
|
+
this.host = host;
|
45
|
+
this.port = port;
|
46
|
+
this.path = path;
|
47
|
+
this.headers = headers;
|
48
|
+
}
|
49
|
+
assembleUrl(path) {
|
50
|
+
return `${this.protocol}://${this.host}:${this.port}${this.path}${path}`;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
exports.BaseUrlPartsApiConfiguration = BaseUrlPartsApiConfiguration;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { AbstractApiConfiguration } from "./AbstractApiConfiguration.js";
|
2
|
+
import { RetryFunction } from "./RetryFunction.js";
|
3
|
+
import { ThrottleFunction } from "./ThrottleFunction.js";
|
4
|
+
export type BaseUrlPartsApiConfigurationOptions = {
|
5
|
+
protocol: string;
|
6
|
+
host: string;
|
7
|
+
port: string;
|
8
|
+
path: string;
|
9
|
+
headers: Record<string, string>;
|
10
|
+
retry?: RetryFunction;
|
11
|
+
throttle?: ThrottleFunction;
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* An API configuration that uses different URL parts and a set of headers.
|
15
|
+
*
|
16
|
+
* You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
|
17
|
+
*/
|
18
|
+
export declare class BaseUrlPartsApiConfiguration extends AbstractApiConfiguration {
|
19
|
+
readonly protocol: string;
|
20
|
+
readonly host: string;
|
21
|
+
readonly port: string;
|
22
|
+
readonly path: string;
|
23
|
+
readonly headers: Record<string, string>;
|
24
|
+
constructor({ protocol, host, port, path, headers, retry, throttle, }: BaseUrlPartsApiConfigurationOptions);
|
25
|
+
assembleUrl(path: string): string;
|
26
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { AbstractApiConfiguration } from "./AbstractApiConfiguration.js";
|
2
|
+
/**
|
3
|
+
* An API configuration that uses different URL parts and a set of headers.
|
4
|
+
*
|
5
|
+
* You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
|
6
|
+
*/
|
7
|
+
export class BaseUrlPartsApiConfiguration extends AbstractApiConfiguration {
|
8
|
+
constructor({ protocol, host, port, path, headers, retry, throttle, }) {
|
9
|
+
super({ retry, throttle });
|
10
|
+
Object.defineProperty(this, "protocol", {
|
11
|
+
enumerable: true,
|
12
|
+
configurable: true,
|
13
|
+
writable: true,
|
14
|
+
value: void 0
|
15
|
+
});
|
16
|
+
Object.defineProperty(this, "host", {
|
17
|
+
enumerable: true,
|
18
|
+
configurable: true,
|
19
|
+
writable: true,
|
20
|
+
value: void 0
|
21
|
+
});
|
22
|
+
Object.defineProperty(this, "port", {
|
23
|
+
enumerable: true,
|
24
|
+
configurable: true,
|
25
|
+
writable: true,
|
26
|
+
value: void 0
|
27
|
+
});
|
28
|
+
Object.defineProperty(this, "path", {
|
29
|
+
enumerable: true,
|
30
|
+
configurable: true,
|
31
|
+
writable: true,
|
32
|
+
value: void 0
|
33
|
+
});
|
34
|
+
Object.defineProperty(this, "headers", {
|
35
|
+
enumerable: true,
|
36
|
+
configurable: true,
|
37
|
+
writable: true,
|
38
|
+
value: void 0
|
39
|
+
});
|
40
|
+
this.protocol = protocol;
|
41
|
+
this.host = host;
|
42
|
+
this.port = port;
|
43
|
+
this.path = path;
|
44
|
+
this.headers = headers;
|
45
|
+
}
|
46
|
+
assembleUrl(path) {
|
47
|
+
return `${this.protocol}://${this.host}:${this.port}${this.path}${path}`;
|
48
|
+
}
|
49
|
+
}
|
package/core/api/index.cjs
CHANGED
@@ -18,6 +18,7 @@ __exportStar(require("./AbortError.cjs"), exports);
|
|
18
18
|
__exportStar(require("./ApiCallError.cjs"), exports);
|
19
19
|
__exportStar(require("./ApiConfiguration.cjs"), exports);
|
20
20
|
__exportStar(require("./BaseUrlApiConfiguration.cjs"), exports);
|
21
|
+
__exportStar(require("./BaseUrlPartsApiConfiguration.cjs"), exports);
|
21
22
|
__exportStar(require("./RetryError.cjs"), exports);
|
22
23
|
__exportStar(require("./RetryFunction.cjs"), exports);
|
23
24
|
__exportStar(require("./ThrottleFunction.cjs"), exports);
|
package/core/api/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ export * from "./AbortError.js";
|
|
2
2
|
export * from "./ApiCallError.js";
|
3
3
|
export * from "./ApiConfiguration.js";
|
4
4
|
export * from "./BaseUrlApiConfiguration.js";
|
5
|
+
export * from "./BaseUrlPartsApiConfiguration.js";
|
5
6
|
export * from "./RetryError.js";
|
6
7
|
export * from "./RetryFunction.js";
|
7
8
|
export * from "./ThrottleFunction.js";
|
package/core/api/index.js
CHANGED
@@ -2,6 +2,7 @@ export * from "./AbortError.js";
|
|
2
2
|
export * from "./ApiCallError.js";
|
3
3
|
export * from "./ApiConfiguration.js";
|
4
4
|
export * from "./BaseUrlApiConfiguration.js";
|
5
|
+
export * from "./BaseUrlPartsApiConfiguration.js";
|
5
6
|
export * from "./RetryError.js";
|
6
7
|
export * from "./RetryFunction.js";
|
7
8
|
export * from "./ThrottleFunction.js";
|
@@ -1,15 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.Automatic1111ApiConfiguration = void 0;
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
});
|
4
|
+
const BaseUrlPartsApiConfiguration_js_1 = require("../../core/api/BaseUrlPartsApiConfiguration.cjs");
|
5
|
+
/**
|
6
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
7
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
8
|
+
*/
|
9
|
+
class Automatic1111ApiConfiguration extends BaseUrlPartsApiConfiguration_js_1.BaseUrlPartsApiConfiguration {
|
10
|
+
constructor({ protocol = "http", host = "127.0.0.1", port = "7860", path = "/sdapi/v1", headers = {}, retry, throttle, } = {}) {
|
11
|
+
super({ protocol, host, port, path, headers, retry, throttle });
|
13
12
|
}
|
14
13
|
}
|
15
14
|
exports.Automatic1111ApiConfiguration = Automatic1111ApiConfiguration;
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
throttle?: ThrottleFunction;
|
9
|
-
});
|
1
|
+
import { BaseUrlPartsApiConfiguration, BaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlPartsApiConfiguration.js";
|
2
|
+
/**
|
3
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
4
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
5
|
+
*/
|
6
|
+
export declare class Automatic1111ApiConfiguration extends BaseUrlPartsApiConfiguration {
|
7
|
+
constructor({ protocol, host, port, path, headers, retry, throttle, }?: Partial<BaseUrlPartsApiConfigurationOptions>);
|
10
8
|
}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
});
|
1
|
+
import { BaseUrlPartsApiConfiguration, } from "../../core/api/BaseUrlPartsApiConfiguration.js";
|
2
|
+
/**
|
3
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
4
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
5
|
+
*/
|
6
|
+
export class Automatic1111ApiConfiguration extends BaseUrlPartsApiConfiguration {
|
7
|
+
constructor({ protocol = "http", host = "127.0.0.1", port = "7860", path = "/sdapi/v1", headers = {}, retry, throttle, } = {}) {
|
8
|
+
super({ protocol, host, port, path, headers, retry, throttle });
|
10
9
|
}
|
11
10
|
}
|
@@ -1,40 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.failedAutomatic1111CallResponseHandler =
|
3
|
+
exports.failedAutomatic1111CallResponseHandler = void 0;
|
4
4
|
const zod_1 = require("zod");
|
5
|
-
const
|
5
|
+
const postToApi_js_1 = require("../../core/api/postToApi.cjs");
|
6
6
|
const ZodSchema_js_1 = require("../../core/schema/ZodSchema.cjs");
|
7
|
-
const
|
8
|
-
exports.automatic1111ErrorDataSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
|
7
|
+
const automatic1111ErrorDataSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
|
9
8
|
error: zod_1.z.string(),
|
10
9
|
detail: zod_1.z.string(),
|
11
10
|
body: zod_1.z.string(),
|
12
11
|
errors: zod_1.z.string(),
|
13
12
|
}));
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
enumerable: true,
|
19
|
-
configurable: true,
|
20
|
-
writable: true,
|
21
|
-
value: void 0
|
22
|
-
});
|
23
|
-
this.data = data;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
exports.Automatic1111Error = Automatic1111Error;
|
27
|
-
const failedAutomatic1111CallResponseHandler = async ({ response, url, requestBodyValues }) => {
|
28
|
-
const responseBody = await response.text();
|
29
|
-
const parsedError = (0, parseJSON_js_1.parseJSON)({
|
30
|
-
text: responseBody,
|
31
|
-
schema: exports.automatic1111ErrorDataSchema,
|
32
|
-
});
|
33
|
-
return new Automatic1111Error({
|
34
|
-
url,
|
35
|
-
requestBodyValues,
|
36
|
-
statusCode: response.status,
|
37
|
-
data: parsedError,
|
38
|
-
});
|
39
|
-
};
|
40
|
-
exports.failedAutomatic1111CallResponseHandler = failedAutomatic1111CallResponseHandler;
|
13
|
+
exports.failedAutomatic1111CallResponseHandler = (0, postToApi_js_1.createJsonErrorResponseHandler)({
|
14
|
+
errorSchema: automatic1111ErrorDataSchema,
|
15
|
+
errorToMessage: (error) => error.detail,
|
16
|
+
});
|
@@ -1,21 +1,12 @@
|
|
1
1
|
import { ApiCallError } from "../../core/api/ApiCallError.js";
|
2
2
|
import { ResponseHandler } from "../../core/api/postToApi.js";
|
3
3
|
import { ZodSchema } from "../../core/schema/ZodSchema.js";
|
4
|
-
|
4
|
+
declare const automatic1111ErrorDataSchema: ZodSchema<{
|
5
5
|
error: string;
|
6
6
|
errors: string;
|
7
7
|
body: string;
|
8
8
|
detail: string;
|
9
9
|
}>;
|
10
10
|
export type Automatic1111ErrorData = (typeof automatic1111ErrorDataSchema)["_type"];
|
11
|
-
export declare class Automatic1111Error extends ApiCallError {
|
12
|
-
readonly data: Automatic1111ErrorData;
|
13
|
-
constructor({ data, statusCode, url, requestBodyValues, message, }: {
|
14
|
-
message?: string;
|
15
|
-
statusCode: number;
|
16
|
-
url: string;
|
17
|
-
requestBodyValues: unknown;
|
18
|
-
data: Automatic1111ErrorData;
|
19
|
-
});
|
20
|
-
}
|
21
11
|
export declare const failedAutomatic1111CallResponseHandler: ResponseHandler<ApiCallError>;
|
12
|
+
export {};
|
@@ -1,35 +1,13 @@
|
|
1
1
|
import { z } from "zod";
|
2
|
-
import {
|
2
|
+
import { createJsonErrorResponseHandler, } from "../../core/api/postToApi.js";
|
3
3
|
import { ZodSchema } from "../../core/schema/ZodSchema.js";
|
4
|
-
|
5
|
-
export const automatic1111ErrorDataSchema = new ZodSchema(z.object({
|
4
|
+
const automatic1111ErrorDataSchema = new ZodSchema(z.object({
|
6
5
|
error: z.string(),
|
7
6
|
detail: z.string(),
|
8
7
|
body: z.string(),
|
9
8
|
errors: z.string(),
|
10
9
|
}));
|
11
|
-
export
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
enumerable: true,
|
16
|
-
configurable: true,
|
17
|
-
writable: true,
|
18
|
-
value: void 0
|
19
|
-
});
|
20
|
-
this.data = data;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
export const failedAutomatic1111CallResponseHandler = async ({ response, url, requestBodyValues }) => {
|
24
|
-
const responseBody = await response.text();
|
25
|
-
const parsedError = parseJSON({
|
26
|
-
text: responseBody,
|
27
|
-
schema: automatic1111ErrorDataSchema,
|
28
|
-
});
|
29
|
-
return new Automatic1111Error({
|
30
|
-
url,
|
31
|
-
requestBodyValues,
|
32
|
-
statusCode: response.status,
|
33
|
-
data: parsedError,
|
34
|
-
});
|
35
|
-
};
|
10
|
+
export const failedAutomatic1111CallResponseHandler = createJsonErrorResponseHandler({
|
11
|
+
errorSchema: automatic1111ErrorDataSchema,
|
12
|
+
errorToMessage: (error) => error.detail,
|
13
|
+
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ImageGenerator = void 0;
|
3
|
+
exports.Api = exports.ImageGenerator = void 0;
|
4
|
+
const Automatic1111ApiConfiguration_js_1 = require("./Automatic1111ApiConfiguration.cjs");
|
4
5
|
const Automatic1111ImageGenerationModel_js_1 = require("./Automatic1111ImageGenerationModel.cjs");
|
5
6
|
/**
|
6
7
|
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
@@ -13,3 +14,11 @@ function ImageGenerator(settings) {
|
|
13
14
|
return new Automatic1111ImageGenerationModel_js_1.Automatic1111ImageGenerationModel(settings);
|
14
15
|
}
|
15
16
|
exports.ImageGenerator = ImageGenerator;
|
17
|
+
/**
|
18
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
19
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
20
|
+
*/
|
21
|
+
function Api(settings) {
|
22
|
+
return new Automatic1111ApiConfiguration_js_1.Automatic1111ApiConfiguration(settings);
|
23
|
+
}
|
24
|
+
exports.Api = Api;
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { BaseUrlPartsApiConfigurationOptions } from "../../core/api/BaseUrlPartsApiConfiguration.js";
|
2
|
+
import { Automatic1111ApiConfiguration } from "./Automatic1111ApiConfiguration.js";
|
1
3
|
import { Automatic1111ImageGenerationModel, Automatic1111ImageGenerationSettings } from "./Automatic1111ImageGenerationModel.js";
|
2
4
|
/**
|
3
5
|
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
@@ -7,3 +9,8 @@ import { Automatic1111ImageGenerationModel, Automatic1111ImageGenerationSettings
|
|
7
9
|
* @return A new instance of ${@link Automatic1111ImageGenerationModel}.
|
8
10
|
*/
|
9
11
|
export declare function ImageGenerator(settings: Automatic1111ImageGenerationSettings): Automatic1111ImageGenerationModel;
|
12
|
+
/**
|
13
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
14
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
15
|
+
*/
|
16
|
+
export declare function Api(settings: Partial<BaseUrlPartsApiConfigurationOptions>): Automatic1111ApiConfiguration;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Automatic1111ApiConfiguration } from "./Automatic1111ApiConfiguration.js";
|
1
2
|
import { Automatic1111ImageGenerationModel, } from "./Automatic1111ImageGenerationModel.js";
|
2
3
|
/**
|
3
4
|
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
@@ -9,3 +10,10 @@ import { Automatic1111ImageGenerationModel, } from "./Automatic1111ImageGenerati
|
|
9
10
|
export function ImageGenerator(settings) {
|
10
11
|
return new Automatic1111ImageGenerationModel(settings);
|
11
12
|
}
|
13
|
+
/**
|
14
|
+
* Creates an API configuration for the AUTOMATIC1111 Stable Diffusion Web UI API.
|
15
|
+
* It calls the API at http://127.0.0.1:7860/sdapi/v1 by default.
|
16
|
+
*/
|
17
|
+
export function Api(settings) {
|
18
|
+
return new Automatic1111ApiConfiguration(settings);
|
19
|
+
}
|
@@ -28,13 +28,29 @@ class Automatic1111ImageGenerationModel extends AbstractModel_js_1.AbstractModel
|
|
28
28
|
return this.settings.model;
|
29
29
|
}
|
30
30
|
async callAPI(input, options) {
|
31
|
+
const api = this.settings.api ?? new Automatic1111ApiConfiguration_js_1.Automatic1111ApiConfiguration();
|
32
|
+
const abortSignal = options?.run?.abortSignal;
|
31
33
|
return (0, callWithRetryAndThrottle_js_1.callWithRetryAndThrottle)({
|
32
|
-
retry:
|
33
|
-
throttle:
|
34
|
-
call: async () =>
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
retry: api.retry,
|
35
|
+
throttle: api.throttle,
|
36
|
+
call: async () => (0, postToApi_js_1.postJsonToApi)({
|
37
|
+
url: api.assembleUrl(`/txt2img`),
|
38
|
+
headers: api.headers,
|
39
|
+
body: {
|
40
|
+
height: this.settings.height,
|
41
|
+
width: this.settings.width,
|
42
|
+
prompt: input.prompt,
|
43
|
+
negative_prompt: input.negativePrompt,
|
44
|
+
sampler_index: this.settings.sampler,
|
45
|
+
steps: this.settings.steps,
|
46
|
+
seed: input.seed,
|
47
|
+
override_settings: {
|
48
|
+
sd_model_checkpoint: this.settings.model,
|
49
|
+
},
|
50
|
+
},
|
51
|
+
failedResponseHandler: Automatic1111Error_js_1.failedAutomatic1111CallResponseHandler,
|
52
|
+
successfulResponseHandler: (0, postToApi_js_1.createJsonResponseHandler)(Automatic1111ImageGenerationResponseSchema),
|
53
|
+
abortSignal,
|
38
54
|
}),
|
39
55
|
});
|
40
56
|
}
|
@@ -72,24 +88,3 @@ const Automatic1111ImageGenerationResponseSchema = zod_1.z.object({
|
|
72
88
|
parameters: zod_1.z.object({}),
|
73
89
|
info: zod_1.z.string(),
|
74
90
|
});
|
75
|
-
async function callAutomatic1111ImageGenerationAPI({ api = new Automatic1111ApiConfiguration_js_1.Automatic1111ApiConfiguration(), abortSignal, height, width, prompt, negativePrompt, sampler, steps, seed, model, }) {
|
76
|
-
return (0, postToApi_js_1.postJsonToApi)({
|
77
|
-
url: api.assembleUrl(`/txt2img`),
|
78
|
-
headers: api.headers,
|
79
|
-
body: {
|
80
|
-
height,
|
81
|
-
width,
|
82
|
-
prompt,
|
83
|
-
negative_prompt: negativePrompt,
|
84
|
-
sampler_index: sampler,
|
85
|
-
steps,
|
86
|
-
seed,
|
87
|
-
override_settings: {
|
88
|
-
sd_model_checkpoint: model,
|
89
|
-
},
|
90
|
-
},
|
91
|
-
failedResponseHandler: Automatic1111Error_js_1.failedAutomatic1111CallResponseHandler,
|
92
|
-
successfulResponseHandler: (0, postToApi_js_1.createJsonResponseHandler)(Automatic1111ImageGenerationResponseSchema),
|
93
|
-
abortSignal,
|
94
|
-
});
|
95
|
-
}
|
@@ -6,6 +6,14 @@ import { PromptTemplate } from "../../model-function/PromptTemplate.js";
|
|
6
6
|
import { ImageGenerationModel, ImageGenerationModelSettings } from "../../model-function/generate-image/ImageGenerationModel.js";
|
7
7
|
import { PromptTemplateImageGenerationModel } from "../../model-function/generate-image/PromptTemplateImageGenerationModel.js";
|
8
8
|
import { Automatic1111ImageGenerationPrompt } from "./Automatic1111ImageGenerationPrompt.js";
|
9
|
+
export interface Automatic1111ImageGenerationSettings extends ImageGenerationModelSettings {
|
10
|
+
api?: ApiConfiguration;
|
11
|
+
model: string;
|
12
|
+
height?: number;
|
13
|
+
width?: number;
|
14
|
+
sampler?: string;
|
15
|
+
steps?: number;
|
16
|
+
}
|
9
17
|
/**
|
10
18
|
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
11
19
|
*
|
@@ -29,14 +37,6 @@ export declare class Automatic1111ImageGenerationModel extends AbstractModel<Aut
|
|
29
37
|
withPromptTemplate<INPUT_PROMPT>(promptTemplate: PromptTemplate<INPUT_PROMPT, Automatic1111ImageGenerationPrompt>): PromptTemplateImageGenerationModel<INPUT_PROMPT, Automatic1111ImageGenerationPrompt, Automatic1111ImageGenerationSettings, this>;
|
30
38
|
withSettings(additionalSettings: Automatic1111ImageGenerationSettings): this;
|
31
39
|
}
|
32
|
-
export interface Automatic1111ImageGenerationSettings extends ImageGenerationModelSettings {
|
33
|
-
api?: ApiConfiguration;
|
34
|
-
model: string;
|
35
|
-
height?: number;
|
36
|
-
width?: number;
|
37
|
-
sampler?: string;
|
38
|
-
steps?: number;
|
39
|
-
}
|
40
40
|
declare const Automatic1111ImageGenerationResponseSchema: z.ZodObject<{
|
41
41
|
images: z.ZodArray<z.ZodString, "many">;
|
42
42
|
parameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
@@ -25,13 +25,29 @@ export class Automatic1111ImageGenerationModel extends AbstractModel {
|
|
25
25
|
return this.settings.model;
|
26
26
|
}
|
27
27
|
async callAPI(input, options) {
|
28
|
+
const api = this.settings.api ?? new Automatic1111ApiConfiguration();
|
29
|
+
const abortSignal = options?.run?.abortSignal;
|
28
30
|
return callWithRetryAndThrottle({
|
29
|
-
retry:
|
30
|
-
throttle:
|
31
|
-
call: async () =>
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
retry: api.retry,
|
32
|
+
throttle: api.throttle,
|
33
|
+
call: async () => postJsonToApi({
|
34
|
+
url: api.assembleUrl(`/txt2img`),
|
35
|
+
headers: api.headers,
|
36
|
+
body: {
|
37
|
+
height: this.settings.height,
|
38
|
+
width: this.settings.width,
|
39
|
+
prompt: input.prompt,
|
40
|
+
negative_prompt: input.negativePrompt,
|
41
|
+
sampler_index: this.settings.sampler,
|
42
|
+
steps: this.settings.steps,
|
43
|
+
seed: input.seed,
|
44
|
+
override_settings: {
|
45
|
+
sd_model_checkpoint: this.settings.model,
|
46
|
+
},
|
47
|
+
},
|
48
|
+
failedResponseHandler: failedAutomatic1111CallResponseHandler,
|
49
|
+
successfulResponseHandler: createJsonResponseHandler(Automatic1111ImageGenerationResponseSchema),
|
50
|
+
abortSignal,
|
35
51
|
}),
|
36
52
|
});
|
37
53
|
}
|
@@ -68,24 +84,3 @@ const Automatic1111ImageGenerationResponseSchema = z.object({
|
|
68
84
|
parameters: z.object({}),
|
69
85
|
info: z.string(),
|
70
86
|
});
|
71
|
-
async function callAutomatic1111ImageGenerationAPI({ api = new Automatic1111ApiConfiguration(), abortSignal, height, width, prompt, negativePrompt, sampler, steps, seed, model, }) {
|
72
|
-
return postJsonToApi({
|
73
|
-
url: api.assembleUrl(`/txt2img`),
|
74
|
-
headers: api.headers,
|
75
|
-
body: {
|
76
|
-
height,
|
77
|
-
width,
|
78
|
-
prompt,
|
79
|
-
negative_prompt: negativePrompt,
|
80
|
-
sampler_index: sampler,
|
81
|
-
steps,
|
82
|
-
seed,
|
83
|
-
override_settings: {
|
84
|
-
sd_model_checkpoint: model,
|
85
|
-
},
|
86
|
-
},
|
87
|
-
failedResponseHandler: failedAutomatic1111CallResponseHandler,
|
88
|
-
successfulResponseHandler: createJsonResponseHandler(Automatic1111ImageGenerationResponseSchema),
|
89
|
-
abortSignal,
|
90
|
-
});
|
91
|
-
}
|
@@ -26,10 +26,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
26
|
return result;
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.automatic1111 =
|
29
|
+
exports.automatic1111 = void 0;
|
30
30
|
__exportStar(require("./Automatic1111ApiConfiguration.cjs"), exports);
|
31
|
-
var Automatic1111Error_js_1 = require("./Automatic1111Error.cjs");
|
32
|
-
Object.defineProperty(exports, "Automatic1111Error", { enumerable: true, get: function () { return Automatic1111Error_js_1.Automatic1111Error; } });
|
33
31
|
exports.automatic1111 = __importStar(require("./Automatic1111Facade.cjs"));
|
34
32
|
__exportStar(require("./Automatic1111ImageGenerationModel.cjs"), exports);
|
35
33
|
__exportStar(require("./Automatic1111ImageGenerationPrompt.cjs"), exports);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from "./Automatic1111ApiConfiguration.js";
|
2
|
-
export {
|
2
|
+
export { Automatic1111ErrorData } from "./Automatic1111Error.js";
|
3
3
|
export * as automatic1111 from "./Automatic1111Facade.js";
|
4
4
|
export * from "./Automatic1111ImageGenerationModel.js";
|
5
5
|
export * from "./Automatic1111ImageGenerationPrompt.js";
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export * from "./Automatic1111ApiConfiguration.js";
|
2
|
-
export { Automatic1111Error, } from "./Automatic1111Error.js";
|
3
2
|
export * as automatic1111 from "./Automatic1111Facade.js";
|
4
3
|
export * from "./Automatic1111ImageGenerationModel.js";
|
5
4
|
export * from "./Automatic1111ImageGenerationPrompt.js";
|