doomiaichat 4.1.0 → 4.3.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/dist/azureai.js +1 -2
- package/dist/gptprovider.d.ts +1 -0
- package/dist/gptprovider.js +5 -1
- package/dist/stabilityai.d.ts +3 -0
- package/dist/stabilityai.js +1 -2
- package/dist/stabilityplusai.d.ts +7 -0
- package/dist/stabilityplusai.js +85 -0
- package/package.json +1 -1
- package/src/azureai.ts +1 -2
- package/src/gptprovider.ts +5 -1
- package/src/stabilityai.ts +4 -2
- package/src/stabilityplusai.ts +74 -0
package/dist/azureai.js
CHANGED
|
@@ -20,8 +20,7 @@ class AzureAI extends openai_1.default {
|
|
|
20
20
|
constructor(apiKey, azureOption, apiOption = {}) {
|
|
21
21
|
super(apiKey, apiOption);
|
|
22
22
|
this.azureSetting = azureOption;
|
|
23
|
-
if (!this.azureSetting.endpoint.toLowerCase().startsWith('https://')
|
|
24
|
-
!this.azureSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
23
|
+
if (!this.azureSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
25
24
|
this.azureSetting.endpoint = 'https://' + this.azureSetting.endpoint;
|
|
26
25
|
}
|
|
27
26
|
}
|
package/dist/gptprovider.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const GptProviderEnum: {
|
|
|
9
9
|
readonly BAIDU: "baidu";
|
|
10
10
|
readonly GOOGLE: "google";
|
|
11
11
|
readonly STABILITY: "stability";
|
|
12
|
+
readonly STABILITY2: "stability2";
|
|
12
13
|
};
|
|
13
14
|
export type GptProviderEnum = typeof GptProviderEnum[keyof typeof GptProviderEnum];
|
|
14
15
|
/**
|
package/dist/gptprovider.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.createGpt = exports.GptProviderEnum = void 0;
|
|
|
11
11
|
const openai_1 = __importDefault(require("./openai"));
|
|
12
12
|
const azureai_1 = __importDefault(require("./azureai"));
|
|
13
13
|
const stabilityai_1 = __importDefault(require("./stabilityai"));
|
|
14
|
+
const stabilityplusai_1 = __importDefault(require("./stabilityplusai"));
|
|
14
15
|
const baiduai_1 = __importDefault(require("./baiduai"));
|
|
15
16
|
/**
|
|
16
17
|
* OpenAI/NLP 的服务提供商 OpenAI,微软,百度文心(待接入),google(待接入)
|
|
@@ -20,7 +21,8 @@ exports.GptProviderEnum = {
|
|
|
20
21
|
MICROSOFT: 'microsoft',
|
|
21
22
|
BAIDU: 'baidu',
|
|
22
23
|
GOOGLE: 'google',
|
|
23
|
-
STABILITY: 'stability'
|
|
24
|
+
STABILITY: 'stability',
|
|
25
|
+
STABILITY2: 'stability2',
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* 根据类型创建不同的TTS引擎对象
|
|
@@ -41,6 +43,8 @@ function createGpt(provider, apikey, setting) {
|
|
|
41
43
|
return new baiduai_1.default(cred);
|
|
42
44
|
case exports.GptProviderEnum.STABILITY:
|
|
43
45
|
return new stabilityai_1.default(apikey + '', { endpoint, engine }, setting);
|
|
46
|
+
case exports.GptProviderEnum.STABILITY2:
|
|
47
|
+
return new stabilityplusai_1.default(apikey + '', { endpoint, engine }, setting);
|
|
44
48
|
default: return null;
|
|
45
49
|
}
|
|
46
50
|
}
|
package/dist/stabilityai.d.ts
CHANGED
|
@@ -22,7 +22,10 @@ export interface StabilityOption {
|
|
|
22
22
|
'height'?: number;
|
|
23
23
|
'width'?: number;
|
|
24
24
|
'samples'?: number;
|
|
25
|
+
'seed'?: number;
|
|
25
26
|
'steps'?: number;
|
|
27
|
+
'sampler'?: string;
|
|
28
|
+
'negative'?: string;
|
|
26
29
|
}
|
|
27
30
|
export interface StabilityResult extends ApiResult {
|
|
28
31
|
'data'?: any;
|
package/dist/stabilityai.js
CHANGED
|
@@ -26,8 +26,7 @@ class StabilityAI extends gptbase_1.default {
|
|
|
26
26
|
this.apiKey = apiKey;
|
|
27
27
|
this.apiSetting = urlOption;
|
|
28
28
|
this.apiOption = apiOption;
|
|
29
|
-
if (!this.apiSetting.endpoint.toLowerCase().startsWith('
|
|
30
|
-
!this.apiSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
29
|
+
if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
|
|
31
30
|
this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import StabilityAI, { StabilityOption, StabilityResult } from "./stabilityai";
|
|
2
|
+
export default class StabilityPlusAI extends StabilityAI {
|
|
3
|
+
/**
|
|
4
|
+
* 请求Stable作画的接口
|
|
5
|
+
*/
|
|
6
|
+
chatRequest(chatText: string, paramOption: StabilityOption, axiosOption?: any): Promise<StabilityResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const declare_1 = require("./declare");
|
|
16
|
+
const stabilityai_1 = __importDefault(require("./stabilityai"));
|
|
17
|
+
class StabilityPlusAI extends stabilityai_1.default {
|
|
18
|
+
/**
|
|
19
|
+
* 请求Stable作画的接口
|
|
20
|
+
*/
|
|
21
|
+
chatRequest(chatText, paramOption, axiosOption = {}) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (!chatText)
|
|
24
|
+
return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
|
|
25
|
+
axiosOption = Object.assign({}, axiosOption, {
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
"Accept": "application/json",
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
let param = Object.assign(Object.assign({}, axiosOption), { method: "post", url: `${this.apiSetting.endpoint}/sdapi/v1/txt2img`, data: {
|
|
33
|
+
"enable_hr": false,
|
|
34
|
+
"denoising_strength": 0,
|
|
35
|
+
"firstphase_width": 0,
|
|
36
|
+
"firstphase_height": 0,
|
|
37
|
+
"hr_scale": 2,
|
|
38
|
+
"hr_upscaler": "string",
|
|
39
|
+
"hr_second_pass_steps": 0,
|
|
40
|
+
"hr_resize_x": 0,
|
|
41
|
+
"hr_resize_y": 0,
|
|
42
|
+
"prompt": chatText,
|
|
43
|
+
"styles": [this.apiSetting.engine || "bra_v5"],
|
|
44
|
+
"seed": paramOption.seed || this.apiOption.seed || -1,
|
|
45
|
+
"subseed": -1,
|
|
46
|
+
"subseed_strength": 0,
|
|
47
|
+
"seed_resize_from_h": -1,
|
|
48
|
+
"seed_resize_from_w": -1,
|
|
49
|
+
"sampler_name": paramOption.sampler || this.apiOption.sampler || "Euler",
|
|
50
|
+
"batch_size": 1,
|
|
51
|
+
"n_iter": paramOption.samples || this.apiOption.samples || 1,
|
|
52
|
+
"steps": paramOption.steps || this.apiOption.steps || 50,
|
|
53
|
+
"cfg_scale": paramOption.cfg_scale || this.apiOption.cfg_scale || 7,
|
|
54
|
+
"width": paramOption.width || this.apiOption.width || 512,
|
|
55
|
+
"height": paramOption.height || this.apiOption.height || 512,
|
|
56
|
+
"restore_faces": false,
|
|
57
|
+
"tiling": false,
|
|
58
|
+
"do_not_save_samples": false,
|
|
59
|
+
"do_not_save_grid": false,
|
|
60
|
+
"negative_prompt": paramOption.negative || '',
|
|
61
|
+
// "eta": 0,
|
|
62
|
+
// "s_churn": 0,
|
|
63
|
+
// "s_tmax": 0,
|
|
64
|
+
// "s_tmin": 0,
|
|
65
|
+
// "s_noise": 1,
|
|
66
|
+
// "script_args": [],
|
|
67
|
+
// "sampler_index": paramOption.sampler || this.apiOption.sampler || "Euler", //"Euler",
|
|
68
|
+
// "send_images": true,
|
|
69
|
+
// "save_images": false,
|
|
70
|
+
// "alwayson_scripts": {}
|
|
71
|
+
} });
|
|
72
|
+
const response = yield (0, declare_1.request)(param);
|
|
73
|
+
if (response.successed) {
|
|
74
|
+
return { successed: true, type: 'image', data: response.data.images, };
|
|
75
|
+
}
|
|
76
|
+
return Object.assign({ successed: false }, response.data);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.log('result is error ', error);
|
|
80
|
+
return { successed: false, error };
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.default = StabilityPlusAI;
|
package/package.json
CHANGED
package/src/azureai.ts
CHANGED
|
@@ -7,8 +7,7 @@ export default class AzureAI extends OpenAIGpt {
|
|
|
7
7
|
constructor(apiKey: string, azureOption: AzureOpenAIPatameters, apiOption: OpenAIApiParameters = {}) {
|
|
8
8
|
super(apiKey, apiOption);
|
|
9
9
|
this.azureSetting = azureOption;
|
|
10
|
-
if (!this.azureSetting.endpoint.toLowerCase().startsWith('https://')
|
|
11
|
-
!this.azureSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
10
|
+
if (!this.azureSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
12
11
|
this.azureSetting.endpoint = 'https://' + this.azureSetting.endpoint;
|
|
13
12
|
}
|
|
14
13
|
}
|
package/src/gptprovider.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import OpenAIGpt from './openai';
|
|
6
6
|
import AzureAI from './azureai'
|
|
7
7
|
import StabilityAI from './stabilityai'
|
|
8
|
+
import StabilityPlusAI from './stabilityplusai'
|
|
8
9
|
import BaiduWenXinAI, { ApiCredential } from './baiduai'
|
|
9
10
|
import GptBase from './gptbase';
|
|
10
11
|
/**
|
|
@@ -15,7 +16,8 @@ export const GptProviderEnum = {
|
|
|
15
16
|
MICROSOFT: 'microsoft',
|
|
16
17
|
BAIDU: 'baidu',
|
|
17
18
|
GOOGLE:'google',
|
|
18
|
-
STABILITY:'stability'
|
|
19
|
+
STABILITY:'stability',
|
|
20
|
+
STABILITY2: 'stability2',
|
|
19
21
|
} as const;
|
|
20
22
|
export type GptProviderEnum = typeof GptProviderEnum[keyof typeof GptProviderEnum];
|
|
21
23
|
/**
|
|
@@ -37,6 +39,8 @@ export function createGpt(provider: GptProviderEnum, apikey: string|ApiCredentia
|
|
|
37
39
|
return new BaiduWenXinAI(cred);
|
|
38
40
|
case GptProviderEnum.STABILITY:
|
|
39
41
|
return new StabilityAI(apikey + '', { endpoint, engine }, setting);
|
|
42
|
+
case GptProviderEnum.STABILITY2:
|
|
43
|
+
return new StabilityPlusAI(apikey + '', { endpoint, engine }, setting);
|
|
40
44
|
default: return null;
|
|
41
45
|
}
|
|
42
46
|
};
|
package/src/stabilityai.ts
CHANGED
|
@@ -16,8 +16,7 @@ export default class StabilityAI extends GptBase {
|
|
|
16
16
|
this.apiKey = apiKey;
|
|
17
17
|
this.apiSetting = urlOption;
|
|
18
18
|
this.apiOption = apiOption;
|
|
19
|
-
if (!this.apiSetting.endpoint.toLowerCase().startsWith('
|
|
20
|
-
!this.apiSetting.endpoint.toLowerCase().startsWith('https://')) {
|
|
19
|
+
if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
|
|
21
20
|
this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
@@ -73,7 +72,10 @@ export interface StabilityOption {
|
|
|
73
72
|
'height'?: number,
|
|
74
73
|
'width'?: number,
|
|
75
74
|
'samples'?: number,
|
|
75
|
+
'seed'?:number,
|
|
76
76
|
'steps'?: number,
|
|
77
|
+
'sampler'?:string,
|
|
78
|
+
'negative'?:string
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
export interface StabilityResult extends ApiResult {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import { request } from "./declare";
|
|
3
|
+
import StabilityAI, { StabilityOption, StabilityResult } from "./stabilityai"
|
|
4
|
+
export default class StabilityPlusAI extends StabilityAI {
|
|
5
|
+
/**
|
|
6
|
+
* 请求Stable作画的接口
|
|
7
|
+
*/
|
|
8
|
+
public override async chatRequest(chatText: string, paramOption: StabilityOption, axiosOption: any = {}): Promise<StabilityResult> {
|
|
9
|
+
if (!chatText) return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
|
|
10
|
+
axiosOption = Object.assign({}, axiosOption, {
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
"Accept": "application/json",
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
try {
|
|
17
|
+
let param = {
|
|
18
|
+
...axiosOption,
|
|
19
|
+
method: "post",
|
|
20
|
+
url: `${this.apiSetting.endpoint}/sdapi/v1/txt2img`,
|
|
21
|
+
data: {
|
|
22
|
+
"enable_hr": false,
|
|
23
|
+
"denoising_strength": 0,
|
|
24
|
+
"firstphase_width": 0,
|
|
25
|
+
"firstphase_height": 0,
|
|
26
|
+
"hr_scale": 2,
|
|
27
|
+
"hr_upscaler": "string",
|
|
28
|
+
"hr_second_pass_steps": 0,
|
|
29
|
+
"hr_resize_x": 0,
|
|
30
|
+
"hr_resize_y": 0,
|
|
31
|
+
"prompt": chatText,
|
|
32
|
+
"styles": [this.apiSetting.engine || "bra_v5"], //["bra_v5"], //模型
|
|
33
|
+
"seed": paramOption.seed || this.apiOption.seed || -1,
|
|
34
|
+
"subseed": -1,
|
|
35
|
+
"subseed_strength": 0,
|
|
36
|
+
"seed_resize_from_h": -1,
|
|
37
|
+
"seed_resize_from_w": -1,
|
|
38
|
+
"sampler_name": paramOption.sampler || this.apiOption.sampler || "Euler", //"Euler",
|
|
39
|
+
"batch_size": 1,
|
|
40
|
+
"n_iter": paramOption.samples || this.apiOption.samples || 1, //生成的数量
|
|
41
|
+
"steps": paramOption.steps || this.apiOption.steps || 50,
|
|
42
|
+
"cfg_scale": paramOption.cfg_scale || this.apiOption.cfg_scale || 7,
|
|
43
|
+
"width": paramOption.width || this.apiOption.width || 512,
|
|
44
|
+
"height": paramOption.height || this.apiOption.height || 512,
|
|
45
|
+
"restore_faces": false,
|
|
46
|
+
"tiling": false,
|
|
47
|
+
"do_not_save_samples": false,
|
|
48
|
+
"do_not_save_grid": false,
|
|
49
|
+
"negative_prompt": paramOption.negative || '',
|
|
50
|
+
// "eta": 0,
|
|
51
|
+
// "s_churn": 0,
|
|
52
|
+
// "s_tmax": 0,
|
|
53
|
+
// "s_tmin": 0,
|
|
54
|
+
// "s_noise": 1,
|
|
55
|
+
// "script_args": [],
|
|
56
|
+
// "sampler_index": paramOption.sampler || this.apiOption.sampler || "Euler", //"Euler",
|
|
57
|
+
// "send_images": true,
|
|
58
|
+
// "save_images": false,
|
|
59
|
+
// "alwayson_scripts": {}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
const response: any = await request(param)
|
|
64
|
+
if (response.successed) {
|
|
65
|
+
return { successed: true, type: 'image', data: response.data.images, };
|
|
66
|
+
}
|
|
67
|
+
return { successed: false, ...response.data };
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.log('result is error ', error)
|
|
70
|
+
return { successed: false, error };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
}
|