doomiaichat 7.1.29 → 7.1.31
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/index.esm.js +16 -0
- package/dist/index.js +16 -28
- package/dist/{aimp.d.ts → types/aimp.d.ts} +1 -0
- package/dist/types/aimp.d.ts.map +1 -0
- package/dist/{azureai.d.ts → types/azureai.d.ts} +1 -0
- package/dist/types/azureai.d.ts.map +1 -0
- package/dist/{corzauthorization.d.ts → types/corzauthorization.d.ts} +1 -0
- package/dist/types/corzauthorization.d.ts.map +1 -0
- package/dist/{corzbot.d.ts → types/corzbot.d.ts} +1 -0
- package/dist/types/corzbot.d.ts.map +1 -0
- package/dist/{declare.d.ts → types/declare.d.ts} +2 -1
- package/dist/types/declare.d.ts.map +1 -0
- package/dist/{doubaoai.d.ts → types/doubaoai.d.ts} +1 -0
- package/dist/types/doubaoai.d.ts.map +1 -0
- package/dist/{gptbase.d.ts → types/gptbase.d.ts} +1 -1
- package/dist/types/gptbase.d.ts.map +1 -0
- package/dist/{gptprovider.d.ts → types/gptprovider.d.ts} +2 -7
- package/dist/types/gptprovider.d.ts.map +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{openai.d.ts → types/openai.d.ts} +1 -0
- package/dist/types/openai.d.ts.map +1 -0
- package/dist/{openaibase.d.ts → types/openaibase.d.ts} +1 -0
- package/dist/types/openaibase.d.ts.map +1 -0
- package/dist/{openaiproxy.d.ts → types/openaiproxy.d.ts} +1 -0
- package/dist/types/openaiproxy.d.ts.map +1 -0
- package/package.json +16 -4
- package/dist/aimp.js +0 -162
- package/dist/azureai.js +0 -220
- package/dist/baiduai.d.ts +0 -28
- package/dist/baiduai.js +0 -92
- package/dist/corzauthorization.js +0 -79
- package/dist/corzbot.js +0 -490
- package/dist/declare.js +0 -51
- package/dist/deepseek.d.ts +0 -5
- package/dist/deepseek.js +0 -16
- package/dist/doubaoai.js +0 -149
- package/dist/gptbase.js +0 -58
- package/dist/gptprovider.js +0 -80
- package/dist/openai.js +0 -184
- package/dist/openaibase.js +0 -20
- package/dist/openaiprovider.d.ts +0 -20
- package/dist/openaiprovider.js +0 -43
- package/dist/openaiproxy.js +0 -108
- package/dist/stabilityai.d.ts +0 -18
- package/dist/stabilityai.js +0 -75
- package/dist/stabilityplusai.d.ts +0 -11
- package/dist/stabilityplusai.js +0 -86
- package/src/aimp.ts +0 -125
- package/src/azureai.ts +0 -180
- package/src/baiduai.ts +0 -86
- package/src/corzauthorization.ts +0 -59
- package/src/corzbot.ts +0 -434
- package/src/declare.ts +0 -152
- package/src/deepseek.ts +0 -11
- package/src/doubaoai.ts +0 -129
- package/src/gptbase.ts +0 -52
- package/src/gptprovider.ts +0 -74
- package/src/index.ts +0 -2
- package/src/openai.ts +0 -136
- package/src/openaibase.ts +0 -30
- package/src/openaiproxy.ts +0 -97
- package/src/stabilityai.ts +0 -67
- package/src/stabilityplusai.ts +0 -77
- package/tsconfig.json +0 -31
package/src/openaiproxy.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { ApiResult, OpenAIApiParameters, ProxyPatameters } from './declare';
|
|
2
|
-
import OpenAIGpt from './openai';
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
const ERROR_RESPONSE: string[] = ['[AUTHORIZATION NEEDED]', '[AUTHORIZATION ERROR]', '[BODY ERROR]','[REQUEST ERROR]']
|
|
5
|
-
export default class OpenAIProxy extends OpenAIGpt {
|
|
6
|
-
protected readonly proxySetting: ProxyPatameters;
|
|
7
|
-
constructor(apiKey: string, proxyOption: ProxyPatameters, apiOption: OpenAIApiParameters = {}) {
|
|
8
|
-
super(apiKey, apiOption);
|
|
9
|
-
this.proxySetting = proxyOption;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 重写chatRequest方法
|
|
13
|
-
* @param chatText
|
|
14
|
-
* @param callChatOption
|
|
15
|
-
* @param axiosOption
|
|
16
|
-
*/
|
|
17
|
-
override async chatRequest(chatText: string | any[], _paramOption: any, axiosOption?: any): Promise<ApiResult> {
|
|
18
|
-
const opts: any = {
|
|
19
|
-
headers: {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
'authorization': `Bearer ${this.apiKey}`
|
|
22
|
-
},
|
|
23
|
-
method: 'post',
|
|
24
|
-
url: this.proxySetting.serviceurl,
|
|
25
|
-
data: {
|
|
26
|
-
chatText,
|
|
27
|
-
option: _paramOption
|
|
28
|
-
},
|
|
29
|
-
...axiosOption
|
|
30
|
-
}
|
|
31
|
-
const requestResult = await axios(opts);
|
|
32
|
-
return requestResult.data as ApiResult;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 重写chatRequestInStream方法
|
|
36
|
-
* @param chatText
|
|
37
|
-
* @param callChatOption
|
|
38
|
-
* @param attach
|
|
39
|
-
* @param axiosOption
|
|
40
|
-
*/
|
|
41
|
-
override async chatRequestInStream(chatText:Array<any>, callChatOption: OpenAIApiParameters, attach?: any, axiosOption?: any): Promise<any> {
|
|
42
|
-
// const decoder = new TextDecoder();
|
|
43
|
-
//overContent,
|
|
44
|
-
let streamText,requestid = Math.ceil(Math.random() * (new Date().getTime() * Math.random()) / 1000);
|
|
45
|
-
const opts:any = {
|
|
46
|
-
headers: {
|
|
47
|
-
'Content-Type': 'application/json',
|
|
48
|
-
'authorization': `Bearer ${this.apiKey}`
|
|
49
|
-
},
|
|
50
|
-
method: 'post',
|
|
51
|
-
url: this.proxySetting.serviceurl +'/stream',
|
|
52
|
-
data: {
|
|
53
|
-
messages:chatText,
|
|
54
|
-
option: callChatOption,
|
|
55
|
-
axiosOption
|
|
56
|
-
},
|
|
57
|
-
responseType: 'stream',
|
|
58
|
-
}
|
|
59
|
-
let unCompleteSegment:string = '';
|
|
60
|
-
axios(opts)
|
|
61
|
-
.then(res => {
|
|
62
|
-
res.data.on('data', (chunk:any) => {
|
|
63
|
-
streamText = chunk.toString(); //decoder.decode(chunk);
|
|
64
|
-
if (streamText){
|
|
65
|
-
///请求的响应发生了错误
|
|
66
|
-
if (ERROR_RESPONSE.includes(streamText)) {
|
|
67
|
-
return this.emit('requesterror', { successed: false, requestid, error: 'Request Remote OpenAI Error : ' + streamText });
|
|
68
|
-
}
|
|
69
|
-
const fullData = (unCompleteSegment +streamText).split('*&$')
|
|
70
|
-
unCompleteSegment = '';
|
|
71
|
-
// console.log('fullData', fullData.length);
|
|
72
|
-
for (const segment of fullData){
|
|
73
|
-
if (!segment) continue;
|
|
74
|
-
try {
|
|
75
|
-
////判断接收到的不是一个完整的JSON段了,则该段作为下一次的数据段
|
|
76
|
-
if (!segment.endsWith('}')) {
|
|
77
|
-
unCompleteSegment = segment;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
const objData = Object.assign(JSON.parse(segment), attach);
|
|
81
|
-
this.emit(objData.finish_reason?'chatdone':'chattext', objData);
|
|
82
|
-
} catch (errParse) {
|
|
83
|
-
|
|
84
|
-
break;
|
|
85
|
-
//this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message' + errParse });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
return;
|
|
91
|
-
});
|
|
92
|
-
//res.data.on('end', () => { this.emit('chatdone', Object.assign(streamText, attach)); });
|
|
93
|
-
}).catch(err=>{
|
|
94
|
-
this.emit('requesterror', { successed: false, requestid, error: 'Axios Error : ' + err });
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
}
|
package/src/stabilityai.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { request, AzureOpenAIPatameters, StabilityOption, StabilityResult } from "./declare";
|
|
2
|
-
import GptBase from "./gptbase"
|
|
3
|
-
export default class StabilityAI extends GptBase {
|
|
4
|
-
|
|
5
|
-
protected readonly apiKey: string;
|
|
6
|
-
protected readonly apiSetting: AzureOpenAIPatameters
|
|
7
|
-
protected readonly apiOption:StabilityOption;
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param apiKey 调用OpenAI 的key
|
|
11
|
-
* @param azureOption 用作accesstoken的缓存
|
|
12
|
-
* @param apiOption 用作accesstoken的缓存
|
|
13
|
-
*/
|
|
14
|
-
constructor(apiKey: string, urlOption: AzureOpenAIPatameters, apiOption: StabilityOption = {}) {
|
|
15
|
-
super();
|
|
16
|
-
this.apiKey = apiKey;
|
|
17
|
-
this.apiSetting = urlOption;
|
|
18
|
-
this.apiOption = apiOption;
|
|
19
|
-
if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
|
|
20
|
-
this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 请求Stable作画的接口
|
|
25
|
-
*/
|
|
26
|
-
public async chatRequest(chatText: string, paramOption: StabilityOption, axiosOption: any = {}): Promise<StabilityResult> {
|
|
27
|
-
if (!chatText) return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
|
|
28
|
-
axiosOption = Object.assign({}, axiosOption,{
|
|
29
|
-
headers:{
|
|
30
|
-
"Content-Type": "application/json",
|
|
31
|
-
"Accept": "application/json",
|
|
32
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
try {
|
|
36
|
-
let param = {
|
|
37
|
-
...axiosOption,
|
|
38
|
-
method: "post",
|
|
39
|
-
url: `${this.apiSetting.endpoint}/v1/generation/${this.apiSetting.engine}/text-to-image`,
|
|
40
|
-
data: {
|
|
41
|
-
text_prompts: [
|
|
42
|
-
{
|
|
43
|
-
text: chatText
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
cfg_scale: paramOption.cfg_scale || this.apiOption.cfg_scale || 7,
|
|
47
|
-
clip_guidance_preset: paramOption.clip_guidance_preset || this.apiOption.clip_guidance_preset || "FAST_BLUE",
|
|
48
|
-
height: paramOption.height || this.apiOption.height || 512,
|
|
49
|
-
width: paramOption.width || this.apiOption.width || 512,
|
|
50
|
-
samples: paramOption.samples || this.apiOption.samples || 1,
|
|
51
|
-
steps: paramOption.steps || this.apiOption.steps || 30,
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
const response:any = await request(param)
|
|
56
|
-
if (response.successed) {
|
|
57
|
-
let data = response.data;
|
|
58
|
-
return { successed: true, type: 'image', data: data.artifacts, };
|
|
59
|
-
}
|
|
60
|
-
return { successed: false, ...response.data };
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.log('result is error ', error)
|
|
63
|
-
return { successed: false, error };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/stabilityplusai.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { AzureOpenAIPatameters, StabilityOption, StabilityResult, request } from "./declare";
|
|
3
|
-
import GptBase from "./gptbase";
|
|
4
|
-
export default class StabilityPlusAI extends GptBase {
|
|
5
|
-
protected readonly apiKey: string;
|
|
6
|
-
// protected readonly apiSetting: AzureOpenAIPatameters
|
|
7
|
-
protected readonly apiOption: StabilityOption;
|
|
8
|
-
constructor(apiKey: string, _urlOption: AzureOpenAIPatameters, apiOption: StabilityOption = {}) {
|
|
9
|
-
super();
|
|
10
|
-
this.apiKey = apiKey;
|
|
11
|
-
// this.apiSetting = urlOption;
|
|
12
|
-
this.apiOption = apiOption;
|
|
13
|
-
// if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
|
|
14
|
-
// this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
|
|
15
|
-
// }
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 请求Stable作画的接口
|
|
19
|
-
*/
|
|
20
|
-
public async chatRequest(chatText: string, paramOption: StabilityOption, axiosOption: any = {}): Promise<StabilityResult> {
|
|
21
|
-
if (!chatText) return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
|
|
22
|
-
axiosOption = Object.assign({}, axiosOption, {
|
|
23
|
-
headers: {
|
|
24
|
-
"Content-Type": "application/json",
|
|
25
|
-
"Accept": "application/json",
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
try {
|
|
29
|
-
const requestOption = {
|
|
30
|
-
...axiosOption,
|
|
31
|
-
method: "POST",
|
|
32
|
-
data: {
|
|
33
|
-
"enable_hr": false,
|
|
34
|
-
"denoising_strength": paramOption.denoising_strength || this.apiOption.denoising_strength || 0.5,
|
|
35
|
-
"firstphase_width": 0,
|
|
36
|
-
"firstphase_height": 0,
|
|
37
|
-
"hr_scale": paramOption.hr_scale || this.apiOption.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":["string"], //[paramOption.engine || this.apiSetting.engine || "bra_v5"], //["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 a", //"Euler",
|
|
50
|
-
"batch_size": 1,
|
|
51
|
-
"n_iter": paramOption.samples || this.apiOption.samples || 1, //生成的数量
|
|
52
|
-
"steps": paramOption.steps || this.apiOption.steps || 20,
|
|
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
|
-
},
|
|
62
|
-
url: `${paramOption.endpoint}/sdapi/v1/txt2img`,
|
|
63
|
-
};
|
|
64
|
-
// console.log('stablity param', requestOption);
|
|
65
|
-
const response: any = await request(requestOption)
|
|
66
|
-
if (response.successed) {
|
|
67
|
-
return { successed: true, type: 'image', data: response.data.images, };
|
|
68
|
-
}
|
|
69
|
-
// console.log('response result ', response.data)
|
|
70
|
-
return { successed: false, ...response.data };
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.log('result is error ', error)
|
|
73
|
-
return { successed: false, error };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": [
|
|
3
|
-
"src/index.ts"
|
|
4
|
-
],
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"target": "es2015",
|
|
7
|
-
"module": "commonjs",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"noEmit": false,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"noImplicitAny": true,
|
|
13
|
-
"strictNullChecks": true,
|
|
14
|
-
"strictFunctionTypes": true,
|
|
15
|
-
"strictBindCallApply": true,
|
|
16
|
-
"strictPropertyInitialization": true,
|
|
17
|
-
"noImplicitThis": true,
|
|
18
|
-
"alwaysStrict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"noImplicitReturns": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedIndexedAccess": true,
|
|
24
|
-
"noImplicitOverride": true,
|
|
25
|
-
"moduleResolution":"node",
|
|
26
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
27
|
-
"esModuleInterop": true,
|
|
28
|
-
"forceConsistentCasingInFileNames": true,
|
|
29
|
-
"skipLibCheck": true
|
|
30
|
-
}
|
|
31
|
-
}
|