doomiaichat 7.1.30 → 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.
Files changed (48) hide show
  1. package/dist/index.esm.js +16 -0
  2. package/dist/index.js +16 -28
  3. package/dist/{aimp.d.ts → types/aimp.d.ts} +1 -0
  4. package/dist/types/aimp.d.ts.map +1 -0
  5. package/dist/{azureai.d.ts → types/azureai.d.ts} +1 -0
  6. package/dist/types/azureai.d.ts.map +1 -0
  7. package/dist/{corzauthorization.d.ts → types/corzauthorization.d.ts} +1 -0
  8. package/dist/types/corzauthorization.d.ts.map +1 -0
  9. package/dist/{corzbot.d.ts → types/corzbot.d.ts} +1 -0
  10. package/dist/types/corzbot.d.ts.map +1 -0
  11. package/dist/{declare.d.ts → types/declare.d.ts} +2 -1
  12. package/dist/types/declare.d.ts.map +1 -0
  13. package/dist/{doubaoai.d.ts → types/doubaoai.d.ts} +1 -0
  14. package/dist/types/doubaoai.d.ts.map +1 -0
  15. package/dist/{gptbase.d.ts → types/gptbase.d.ts} +1 -1
  16. package/dist/types/gptbase.d.ts.map +1 -0
  17. package/dist/{gptprovider.d.ts → types/gptprovider.d.ts} +2 -7
  18. package/dist/types/gptprovider.d.ts.map +1 -0
  19. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  20. package/dist/types/index.d.ts.map +1 -0
  21. package/dist/{openai.d.ts → types/openai.d.ts} +1 -0
  22. package/dist/types/openai.d.ts.map +1 -0
  23. package/dist/{openaibase.d.ts → types/openaibase.d.ts} +1 -0
  24. package/dist/types/openaibase.d.ts.map +1 -0
  25. package/dist/{openaiproxy.d.ts → types/openaiproxy.d.ts} +1 -0
  26. package/dist/types/openaiproxy.d.ts.map +1 -0
  27. package/package.json +16 -5
  28. package/dist/aimp.js +0 -162
  29. package/dist/azureai.js +0 -220
  30. package/dist/baiduai.d.ts +0 -28
  31. package/dist/baiduai.js +0 -92
  32. package/dist/corzauthorization.js +0 -79
  33. package/dist/corzbot.js +0 -490
  34. package/dist/declare.js +0 -51
  35. package/dist/deepseek.d.ts +0 -5
  36. package/dist/deepseek.js +0 -16
  37. package/dist/doubaoai.js +0 -149
  38. package/dist/gptbase.js +0 -58
  39. package/dist/gptprovider.js +0 -80
  40. package/dist/openai.js +0 -184
  41. package/dist/openaibase.js +0 -20
  42. package/dist/openaiprovider.d.ts +0 -20
  43. package/dist/openaiprovider.js +0 -43
  44. package/dist/openaiproxy.js +0 -108
  45. package/dist/stabilityai.d.ts +0 -18
  46. package/dist/stabilityai.js +0 -75
  47. package/dist/stabilityplusai.d.ts +0 -11
  48. package/dist/stabilityplusai.js +0 -86
@@ -1,108 +0,0 @@
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 openai_1 = __importDefault(require("./openai"));
16
- const axios_1 = __importDefault(require("axios"));
17
- const ERROR_RESPONSE = ['[AUTHORIZATION NEEDED]', '[AUTHORIZATION ERROR]', '[BODY ERROR]', '[REQUEST ERROR]'];
18
- class OpenAIProxy extends openai_1.default {
19
- constructor(apiKey, proxyOption, apiOption = {}) {
20
- super(apiKey, apiOption);
21
- this.proxySetting = proxyOption;
22
- }
23
- /**
24
- * 重写chatRequest方法
25
- * @param chatText
26
- * @param callChatOption
27
- * @param axiosOption
28
- */
29
- chatRequest(chatText, _paramOption, axiosOption) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const opts = Object.assign({ headers: {
32
- 'Content-Type': 'application/json',
33
- 'authorization': `Bearer ${this.apiKey}`
34
- }, method: 'post', url: this.proxySetting.serviceurl, data: {
35
- chatText,
36
- option: _paramOption
37
- } }, axiosOption);
38
- const requestResult = yield (0, axios_1.default)(opts);
39
- return requestResult.data;
40
- });
41
- }
42
- /**
43
- * 重写chatRequestInStream方法
44
- * @param chatText
45
- * @param callChatOption
46
- * @param attach
47
- * @param axiosOption
48
- */
49
- chatRequestInStream(chatText, callChatOption, attach, axiosOption) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- // const decoder = new TextDecoder();
52
- //overContent,
53
- let streamText, requestid = Math.ceil(Math.random() * (new Date().getTime() * Math.random()) / 1000);
54
- const opts = {
55
- headers: {
56
- 'Content-Type': 'application/json',
57
- 'authorization': `Bearer ${this.apiKey}`
58
- },
59
- method: 'post',
60
- url: this.proxySetting.serviceurl + '/stream',
61
- data: {
62
- messages: chatText,
63
- option: callChatOption,
64
- axiosOption
65
- },
66
- responseType: 'stream',
67
- };
68
- let unCompleteSegment = '';
69
- (0, axios_1.default)(opts)
70
- .then(res => {
71
- res.data.on('data', (chunk) => {
72
- streamText = chunk.toString(); //decoder.decode(chunk);
73
- if (streamText) {
74
- ///请求的响应发生了错误
75
- if (ERROR_RESPONSE.includes(streamText)) {
76
- return this.emit('requesterror', { successed: false, requestid, error: 'Request Remote OpenAI Error : ' + streamText });
77
- }
78
- const fullData = (unCompleteSegment + streamText).split('*&$');
79
- unCompleteSegment = '';
80
- // console.log('fullData', fullData.length);
81
- for (const segment of fullData) {
82
- if (!segment)
83
- continue;
84
- try {
85
- ////判断接收到的不是一个完整的JSON段了,则该段作为下一次的数据段
86
- if (!segment.endsWith('}')) {
87
- unCompleteSegment = segment;
88
- break;
89
- }
90
- const objData = Object.assign(JSON.parse(segment), attach);
91
- this.emit(objData.finish_reason ? 'chatdone' : 'chattext', objData);
92
- }
93
- catch (errParse) {
94
- break;
95
- //this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message' + errParse });
96
- }
97
- }
98
- }
99
- return;
100
- });
101
- //res.data.on('end', () => { this.emit('chatdone', Object.assign(streamText, attach)); });
102
- }).catch(err => {
103
- this.emit('requesterror', { successed: false, requestid, error: 'Axios Error : ' + err });
104
- });
105
- });
106
- }
107
- }
108
- exports.default = OpenAIProxy;
@@ -1,18 +0,0 @@
1
- import { AzureOpenAIPatameters, StabilityOption, StabilityResult } from "./declare";
2
- import GptBase from "./gptbase";
3
- export default class StabilityAI extends GptBase {
4
- protected readonly apiKey: string;
5
- protected readonly apiSetting: AzureOpenAIPatameters;
6
- protected readonly apiOption: StabilityOption;
7
- /**
8
- *
9
- * @param apiKey 调用OpenAI 的key
10
- * @param azureOption 用作accesstoken的缓存
11
- * @param apiOption 用作accesstoken的缓存
12
- */
13
- constructor(apiKey: string, urlOption: AzureOpenAIPatameters, apiOption?: StabilityOption);
14
- /**
15
- * 请求Stable作画的接口
16
- */
17
- chatRequest(chatText: string, paramOption: StabilityOption, axiosOption?: any): Promise<StabilityResult>;
18
- }
@@ -1,75 +0,0 @@
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 gptbase_1 = __importDefault(require("./gptbase"));
17
- class StabilityAI extends gptbase_1.default {
18
- /**
19
- *
20
- * @param apiKey 调用OpenAI 的key
21
- * @param azureOption 用作accesstoken的缓存
22
- * @param apiOption 用作accesstoken的缓存
23
- */
24
- constructor(apiKey, urlOption, apiOption = {}) {
25
- super();
26
- this.apiKey = apiKey;
27
- this.apiSetting = urlOption;
28
- this.apiOption = apiOption;
29
- if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
30
- this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
31
- }
32
- }
33
- /**
34
- * 请求Stable作画的接口
35
- */
36
- chatRequest(chatText, paramOption, axiosOption = {}) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- if (!chatText)
39
- return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
40
- axiosOption = Object.assign({}, axiosOption, {
41
- headers: {
42
- "Content-Type": "application/json",
43
- "Accept": "application/json",
44
- "Authorization": `Bearer ${this.apiKey}`
45
- }
46
- });
47
- try {
48
- let param = Object.assign(Object.assign({}, axiosOption), { method: "post", url: `${this.apiSetting.endpoint}/v1/generation/${this.apiSetting.engine}/text-to-image`, data: {
49
- text_prompts: [
50
- {
51
- text: chatText
52
- }
53
- ],
54
- cfg_scale: paramOption.cfg_scale || this.apiOption.cfg_scale || 7,
55
- clip_guidance_preset: paramOption.clip_guidance_preset || this.apiOption.clip_guidance_preset || "FAST_BLUE",
56
- height: paramOption.height || this.apiOption.height || 512,
57
- width: paramOption.width || this.apiOption.width || 512,
58
- samples: paramOption.samples || this.apiOption.samples || 1,
59
- steps: paramOption.steps || this.apiOption.steps || 30,
60
- } });
61
- const response = yield (0, declare_1.request)(param);
62
- if (response.successed) {
63
- let data = response.data;
64
- return { successed: true, type: 'image', data: data.artifacts, };
65
- }
66
- return Object.assign({ successed: false }, response.data);
67
- }
68
- catch (error) {
69
- console.log('result is error ', error);
70
- return { successed: false, error };
71
- }
72
- });
73
- }
74
- }
75
- exports.default = StabilityAI;
@@ -1,11 +0,0 @@
1
- import { AzureOpenAIPatameters, StabilityOption, StabilityResult } from "./declare";
2
- import GptBase from "./gptbase";
3
- export default class StabilityPlusAI extends GptBase {
4
- protected readonly apiKey: string;
5
- protected readonly apiOption: StabilityOption;
6
- constructor(apiKey: string, _urlOption: AzureOpenAIPatameters, apiOption?: StabilityOption);
7
- /**
8
- * 请求Stable作画的接口
9
- */
10
- chatRequest(chatText: string, paramOption: StabilityOption, axiosOption?: any): Promise<StabilityResult>;
11
- }
@@ -1,86 +0,0 @@
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 gptbase_1 = __importDefault(require("./gptbase"));
17
- class StabilityPlusAI extends gptbase_1.default {
18
- constructor(apiKey, _urlOption, apiOption = {}) {
19
- super();
20
- this.apiKey = apiKey;
21
- // this.apiSetting = urlOption;
22
- this.apiOption = apiOption;
23
- // if (!this.apiSetting.endpoint.toLowerCase().startsWith('http')) {
24
- // this.apiSetting.endpoint = 'https://' + this.apiSetting.endpoint;
25
- // }
26
- }
27
- /**
28
- * 请求Stable作画的接口
29
- */
30
- chatRequest(chatText, paramOption, axiosOption = {}) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- if (!chatText)
33
- return { successed: false, error: { errcode: 2, errmsg: '缺失聊天的内容' } };
34
- axiosOption = Object.assign({}, axiosOption, {
35
- headers: {
36
- "Content-Type": "application/json",
37
- "Accept": "application/json",
38
- }
39
- });
40
- try {
41
- const requestOption = Object.assign(Object.assign({}, axiosOption), { method: "POST", data: {
42
- "enable_hr": false,
43
- "denoising_strength": paramOption.denoising_strength || this.apiOption.denoising_strength || 0.5,
44
- "firstphase_width": 0,
45
- "firstphase_height": 0,
46
- "hr_scale": paramOption.hr_scale || this.apiOption.hr_scale || 2,
47
- "hr_upscaler": "string",
48
- "hr_second_pass_steps": 0,
49
- "hr_resize_x": 0,
50
- "hr_resize_y": 0,
51
- "prompt": chatText,
52
- "styles": ["string"],
53
- "seed": paramOption.seed || this.apiOption.seed || -1,
54
- "subseed": -1,
55
- "subseed_strength": 0,
56
- "seed_resize_from_h": -1,
57
- "seed_resize_from_w": -1,
58
- "sampler_name": paramOption.sampler || this.apiOption.sampler || "Euler a",
59
- "batch_size": 1,
60
- "n_iter": paramOption.samples || this.apiOption.samples || 1,
61
- "steps": paramOption.steps || this.apiOption.steps || 20,
62
- "cfg_scale": paramOption.cfg_scale || this.apiOption.cfg_scale || 7,
63
- "width": paramOption.width || this.apiOption.width || 512,
64
- "height": paramOption.height || this.apiOption.height || 512,
65
- "restore_faces": false,
66
- "tiling": false,
67
- "do_not_save_samples": false,
68
- "do_not_save_grid": false,
69
- "negative_prompt": paramOption.negative || ''
70
- }, url: `${paramOption.endpoint}/sdapi/v1/txt2img` });
71
- // console.log('stablity param', requestOption);
72
- const response = yield (0, declare_1.request)(requestOption);
73
- if (response.successed) {
74
- return { successed: true, type: 'image', data: response.data.images, };
75
- }
76
- // console.log('response result ', response.data)
77
- return Object.assign({ successed: false }, response.data);
78
- }
79
- catch (error) {
80
- console.log('result is error ', error);
81
- return { successed: false, error };
82
- }
83
- });
84
- }
85
- }
86
- exports.default = StabilityPlusAI;