doomiaichat 3.3.0 → 3.5.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/baiduai.d.ts +1 -1
- package/dist/baiduai.js +1 -1
- package/dist/gptbase.d.ts +2 -2
- package/dist/openai.d.ts +1 -1
- package/dist/openai.js +10 -4
- package/package.json +1 -1
- package/src/baiduai.ts +1 -1
- package/src/gptbase.ts +2 -2
- package/src/openai.ts +9 -5
package/dist/baiduai.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export default class BaiduWenXinAI extends GptBase {
|
|
|
23
23
|
* 请求GPT接口
|
|
24
24
|
*/
|
|
25
25
|
chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption?: any): Promise<ApiResult>;
|
|
26
|
-
chatRequestInStream(_chatText: string | any[], _paramOption: any, _axiosOption
|
|
26
|
+
chatRequestInStream(_chatText: string | any[], _paramOption: any, _attach?: any, _axiosOption?: any): void;
|
|
27
27
|
commentQuestionAnswer(_question: string, _answer: string, _axiosOption: any): Promise<CommentResult>;
|
|
28
28
|
getScentenceEmotional(_s1: string, _axiosOption: any): Promise<EmotionResult>;
|
|
29
29
|
getScentenseSimilarity(_s1: string, _s2: string, _axiosOption: any): Promise<SimilarityResult>;
|
package/dist/baiduai.js
CHANGED
|
@@ -97,7 +97,7 @@ class BaiduWenXinAI extends gptbase_1.default {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
chatRequestInStream(_chatText, _paramOption, _axiosOption) {
|
|
100
|
+
chatRequestInStream(_chatText, _paramOption, _attach, _axiosOption) {
|
|
101
101
|
throw new Error("Method not implemented.");
|
|
102
102
|
}
|
|
103
103
|
commentQuestionAnswer(_question, _answer, _axiosOption) {
|
package/dist/gptbase.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ export default abstract class GptBase extends EventEmitter {
|
|
|
17
17
|
* @param _paramOption
|
|
18
18
|
* @param axiosOption
|
|
19
19
|
*/
|
|
20
|
-
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption
|
|
20
|
+
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption?: any): Promise<ApiResult>;
|
|
21
21
|
/**
|
|
22
22
|
* 流式的聊天模式
|
|
23
23
|
* @param chatText
|
|
24
24
|
* @param _paramOption
|
|
25
25
|
* @param axiosOption
|
|
26
26
|
*/
|
|
27
|
-
abstract chatRequestInStream(chatText: string | Array<any>, _paramOption: any, axiosOption
|
|
27
|
+
abstract chatRequestInStream(chatText: string | Array<any>, _paramOption: any, attach?: any, axiosOption?: any): any;
|
|
28
28
|
/**
|
|
29
29
|
* 点评问题回答的评价
|
|
30
30
|
* @param question 问题题干
|
package/dist/openai.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export default class OpenAIGpt extends GptBase {
|
|
|
34
34
|
* @param _paramOption
|
|
35
35
|
* @param axiosOption
|
|
36
36
|
*/
|
|
37
|
-
chatRequestInStream(chatText: string | Array<any>, callChatOption: OpenAIApiParameters, axiosOption
|
|
37
|
+
chatRequestInStream(chatText: string | Array<any>, callChatOption: OpenAIApiParameters, attach?: any, axiosOption?: any): Promise<any>;
|
|
38
38
|
/**
|
|
39
39
|
* 点评问题回答的评价
|
|
40
40
|
* @param question
|
package/dist/openai.js
CHANGED
|
@@ -106,7 +106,7 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
106
106
|
* @param _paramOption
|
|
107
107
|
* @param axiosOption
|
|
108
108
|
*/
|
|
109
|
-
chatRequestInStream(chatText, callChatOption, axiosOption) {
|
|
109
|
+
chatRequestInStream(chatText, callChatOption, attach, axiosOption) {
|
|
110
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
if (!chatText)
|
|
112
112
|
this.emit('chaterror', { successed: false, error: 'no text in chat' });
|
|
@@ -120,7 +120,7 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
120
120
|
try {
|
|
121
121
|
let finishreason = null, usage = null;
|
|
122
122
|
///便于知道返回的requestid
|
|
123
|
-
console.log('model',
|
|
123
|
+
// console.log('model', callChatOption?.model || this.chatModel,)
|
|
124
124
|
const response = yield this.aiApi.createChatCompletion({
|
|
125
125
|
model: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.model) || this.chatModel,
|
|
126
126
|
messages: message,
|
|
@@ -134,7 +134,10 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
134
134
|
for (const line of lines) {
|
|
135
135
|
const message = line.replace(/^data: /, '');
|
|
136
136
|
if (message === '[DONE]') {
|
|
137
|
-
|
|
137
|
+
let output = { successed: true, requestid, text: replytext.join(''), finish_reason: finishreason, usage };
|
|
138
|
+
if (attach)
|
|
139
|
+
output = Object.assign({}, output, attach);
|
|
140
|
+
this.emit('chatdone', output);
|
|
138
141
|
return; // Stream finished
|
|
139
142
|
}
|
|
140
143
|
try {
|
|
@@ -145,7 +148,10 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
145
148
|
usage = parsed.usage;
|
|
146
149
|
let streamtext = parsed.choices[0].delta.content;
|
|
147
150
|
replytext.push(streamtext);
|
|
148
|
-
|
|
151
|
+
let output = { successed: true, requestid, text: replytext.join(''), finish_reason: finishreason, index: parsed.choices[0].index, usage };
|
|
152
|
+
if (attach)
|
|
153
|
+
output = Object.assign({}, output, attach);
|
|
154
|
+
this.emit('chattext', output);
|
|
149
155
|
}
|
|
150
156
|
catch (error) {
|
|
151
157
|
this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message', message });
|
package/package.json
CHANGED
package/src/baiduai.ts
CHANGED
|
@@ -83,7 +83,7 @@ export default class BaiduWenXinAI extends GptBase {
|
|
|
83
83
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
chatRequestInStream(_chatText: string | any[], _paramOption: any, _axiosOption
|
|
86
|
+
chatRequestInStream(_chatText: string | any[], _paramOption: any,_attach?:any, _axiosOption?: any): void {
|
|
87
87
|
throw new Error("Method not implemented.");
|
|
88
88
|
}
|
|
89
89
|
commentQuestionAnswer(_question: string, _answer: string, _axiosOption: any): Promise<CommentResult>{
|
package/src/gptbase.ts
CHANGED
|
@@ -19,14 +19,14 @@ export default abstract class GptBase extends EventEmitter {
|
|
|
19
19
|
* @param _paramOption
|
|
20
20
|
* @param axiosOption
|
|
21
21
|
*/
|
|
22
|
-
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption
|
|
22
|
+
abstract chatRequest(chatText: string | Array<any>, _paramOption: any, axiosOption?: any): Promise<ApiResult>;
|
|
23
23
|
/**
|
|
24
24
|
* 流式的聊天模式
|
|
25
25
|
* @param chatText
|
|
26
26
|
* @param _paramOption
|
|
27
27
|
* @param axiosOption
|
|
28
28
|
*/
|
|
29
|
-
abstract chatRequestInStream(chatText: string | Array<any>, _paramOption: any, axiosOption
|
|
29
|
+
abstract chatRequestInStream(chatText: string | Array<any>, _paramOption: any,attach?:any, axiosOption?: any):any;
|
|
30
30
|
/**
|
|
31
31
|
* 点评问题回答的评价
|
|
32
32
|
* @param question 问题题干
|
package/src/openai.ts
CHANGED
|
@@ -97,7 +97,7 @@ export default class OpenAIGpt extends GptBase {
|
|
|
97
97
|
* @param _paramOption
|
|
98
98
|
* @param axiosOption
|
|
99
99
|
*/
|
|
100
|
-
async chatRequestInStream(chatText: string | Array<any>, callChatOption: OpenAIApiParameters, axiosOption
|
|
100
|
+
async chatRequestInStream(chatText: string | Array<any>, callChatOption: OpenAIApiParameters, attach?: any, axiosOption?: any):Promise<any>{
|
|
101
101
|
if (!chatText) this.emit('chaterror', { successed: false, error:'no text in chat'});
|
|
102
102
|
if (!this.aiApi) {
|
|
103
103
|
this.aiApi = this.createOpenAI(this.apiKey);
|
|
@@ -109,7 +109,7 @@ export default class OpenAIGpt extends GptBase {
|
|
|
109
109
|
try {
|
|
110
110
|
let finishreason:any = null,usage:any = null;
|
|
111
111
|
///便于知道返回的requestid
|
|
112
|
-
console.log('model', callChatOption?.model || this.chatModel,)
|
|
112
|
+
// console.log('model', callChatOption?.model || this.chatModel,)
|
|
113
113
|
const response: any = await this.aiApi.createChatCompletion({
|
|
114
114
|
model: callChatOption?.model || this.chatModel,
|
|
115
115
|
messages: message,
|
|
@@ -123,7 +123,9 @@ export default class OpenAIGpt extends GptBase {
|
|
|
123
123
|
for (const line of lines) {
|
|
124
124
|
const message = line.replace(/^data: /, '');
|
|
125
125
|
if (message === '[DONE]') {
|
|
126
|
-
|
|
126
|
+
let output = { successed: true, requestid, text: replytext.join(''), finish_reason: finishreason, usage };
|
|
127
|
+
if (attach) output = Object.assign({},output, attach);
|
|
128
|
+
this.emit('chatdone', output)
|
|
127
129
|
return; // Stream finished
|
|
128
130
|
}
|
|
129
131
|
try {
|
|
@@ -133,8 +135,10 @@ export default class OpenAIGpt extends GptBase {
|
|
|
133
135
|
finishreason = parsed.choices[0].finish_reason;
|
|
134
136
|
usage = parsed.usage;
|
|
135
137
|
let streamtext = parsed.choices[0].delta.content;
|
|
136
|
-
replytext.push(streamtext)
|
|
137
|
-
|
|
138
|
+
replytext.push(streamtext);
|
|
139
|
+
let output = { successed: true, requestid, text: replytext.join(''), finish_reason: finishreason, index: parsed.choices[0].index, usage };
|
|
140
|
+
if (attach) output = Object.assign({},output, attach);
|
|
141
|
+
this.emit('chattext', output )
|
|
138
142
|
} catch (error) {
|
|
139
143
|
this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message', message });
|
|
140
144
|
}
|