doomiaichat 6.0.3 → 6.0.4
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 +0 -1
- package/dist/openai.js +1 -1
- package/dist/openaiproxy.js +9 -10
- package/package.json +1 -1
- package/src/azureai.ts +0 -1
- package/src/openai.ts +1 -1
- package/src/openaiproxy.ts +11 -11
package/dist/azureai.js
CHANGED
|
@@ -152,7 +152,6 @@ class AzureAI extends openaibase_1.default {
|
|
|
152
152
|
for (const choice of event.choices) {
|
|
153
153
|
const { finishReason: finishreason, index } = choice;
|
|
154
154
|
const toolCalls = (_d = choice.delta) === null || _d === void 0 ? void 0 : _d.toolCalls;
|
|
155
|
-
console.log('toolCalls', toolCalls);
|
|
156
155
|
///存在了toolCalls
|
|
157
156
|
if (toolCalls && toolCalls.length) {
|
|
158
157
|
currentIndex = toolCalls[0].index;
|
package/dist/openai.js
CHANGED
|
@@ -115,7 +115,7 @@ class OpenAIGpt extends openaibase_1.default {
|
|
|
115
115
|
try {
|
|
116
116
|
// let finishreason: any = null, usage: any = null,errtxt = '';
|
|
117
117
|
///便于知道返回的requestid
|
|
118
|
-
// console.log('model', callChatOption?.model
|
|
118
|
+
// console.log('model', callChatOption?.model,this.chatModel,)
|
|
119
119
|
//const response: any = await this.aiApi.chat.completions.create({
|
|
120
120
|
const response = yield this.aiApi.chat.completions.create({
|
|
121
121
|
model: (callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.model) || this.chatModel,
|
package/dist/openaiproxy.js
CHANGED
|
@@ -65,6 +65,7 @@ class OpenAIProxy extends openai_1.default {
|
|
|
65
65
|
},
|
|
66
66
|
responseType: 'stream',
|
|
67
67
|
};
|
|
68
|
+
// let lastResponse:any = null;
|
|
68
69
|
(0, axios_1.default)(opts)
|
|
69
70
|
.then(res => {
|
|
70
71
|
res.data.on('data', (chunk) => {
|
|
@@ -74,19 +75,17 @@ class OpenAIProxy extends openai_1.default {
|
|
|
74
75
|
if (ERROR_RESPONSE.includes(streamText)) {
|
|
75
76
|
return this.emit('requesterror', { successed: false, requestid, error: 'Request Remote OpenAI Error : ' + streamText });
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
///持续的文字输出中
|
|
78
|
+
const fullData = streamText.split('*&$');
|
|
79
|
+
// console.log('fullData', fullData.length);
|
|
80
|
+
for (const segment of fullData) {
|
|
81
|
+
if (!segment)
|
|
82
|
+
continue;
|
|
83
83
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return this.emit('chattext', Object.assign(streamText, attach));
|
|
84
|
+
const objData = Object.assign(JSON.parse(segment), attach);
|
|
85
|
+
this.emit(objData.finish_reason ? 'chatdone' : 'chattext', objData);
|
|
87
86
|
}
|
|
88
87
|
catch (errParse) {
|
|
89
|
-
|
|
88
|
+
this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message' + errParse });
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
}
|
package/package.json
CHANGED
package/src/azureai.ts
CHANGED
|
@@ -134,7 +134,6 @@ export default class AzureAI extends OpenAIBase<OpenAIClient> {
|
|
|
134
134
|
for (const choice of event.choices) {
|
|
135
135
|
const { finishReason: finishreason, index } = choice;
|
|
136
136
|
const toolCalls = choice.delta?.toolCalls;
|
|
137
|
-
console.log('toolCalls', toolCalls);
|
|
138
137
|
///存在了toolCalls
|
|
139
138
|
if (toolCalls && toolCalls.length){
|
|
140
139
|
currentIndex = toolCalls[0].index;
|
package/src/openai.ts
CHANGED
|
@@ -87,7 +87,7 @@ export default class OpenAIGpt extends OpenAIBase<OpenAI> {
|
|
|
87
87
|
try {
|
|
88
88
|
// let finishreason: any = null, usage: any = null,errtxt = '';
|
|
89
89
|
///便于知道返回的requestid
|
|
90
|
-
// console.log('model', callChatOption?.model
|
|
90
|
+
// console.log('model', callChatOption?.model,this.chatModel,)
|
|
91
91
|
//const response: any = await this.aiApi.chat.completions.create({
|
|
92
92
|
const response: any = await this.aiApi.chat.completions.create(
|
|
93
93
|
{
|
package/src/openaiproxy.ts
CHANGED
|
@@ -56,6 +56,7 @@ export default class OpenAIProxy extends OpenAIGpt {
|
|
|
56
56
|
},
|
|
57
57
|
responseType: 'stream',
|
|
58
58
|
}
|
|
59
|
+
// let lastResponse:any = null;
|
|
59
60
|
axios(opts)
|
|
60
61
|
.then(res => {
|
|
61
62
|
res.data.on('data', (chunk:any) => {
|
|
@@ -65,19 +66,18 @@ export default class OpenAIProxy extends OpenAIGpt {
|
|
|
65
66
|
if (ERROR_RESPONSE.includes(streamText)) {
|
|
66
67
|
return this.emit('requesterror', { successed: false, requestid, error: 'Request Remote OpenAI Error : ' + streamText });
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}catch(errParse){
|
|
78
|
-
return this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message', streamText });
|
|
69
|
+
const fullData = streamText.split('*&$')
|
|
70
|
+
// console.log('fullData', fullData.length);
|
|
71
|
+
for (const segment of fullData){
|
|
72
|
+
if (!segment) continue;
|
|
73
|
+
try {
|
|
74
|
+
const objData = Object.assign(JSON.parse(segment), attach);
|
|
75
|
+
this.emit(objData.finish_reason?'chatdone':'chattext', objData);
|
|
76
|
+
} catch (errParse) {
|
|
77
|
+
this.emit('chaterror', { successed: false, requestid, error: 'JSON parse stream message' + errParse });
|
|
79
78
|
}
|
|
80
79
|
}
|
|
80
|
+
|
|
81
81
|
}
|
|
82
82
|
return;
|
|
83
83
|
});
|