doomiaichat 3.0.2 → 3.1.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/openai.js +5 -2
- package/package.json +1 -1
- package/src/openai.ts +5 -2
package/dist/openai.js
CHANGED
|
@@ -125,12 +125,13 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
125
125
|
temperature: Number((callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.temperature) || this.temperature),
|
|
126
126
|
max_tokens: Number((callChatOption === null || callChatOption === void 0 ? void 0 : callChatOption.maxtoken) || this.maxtoken)
|
|
127
127
|
}, axiosOption);
|
|
128
|
+
let replytext = [];
|
|
128
129
|
response.data.on('data', (data) => {
|
|
129
130
|
const lines = data.toString().split('\n').filter((line) => line.trim() !== '');
|
|
130
131
|
for (const line of lines) {
|
|
131
132
|
const message = line.replace(/^data: /, '');
|
|
132
133
|
if (message === '[DONE]') {
|
|
133
|
-
this.emit('chatdone', { successed: true, finish_reason: finishreason, usage });
|
|
134
|
+
this.emit('chatdone', { successed: true, text: replytext.join(''), finish_reason: finishreason, usage });
|
|
134
135
|
return; // Stream finished
|
|
135
136
|
}
|
|
136
137
|
try {
|
|
@@ -139,7 +140,9 @@ class OpenAIGpt extends gptbase_1.default {
|
|
|
139
140
|
const parsed = JSON.parse(message);
|
|
140
141
|
finishreason = parsed.choices[0].finish_reason;
|
|
141
142
|
usage = parsed.usage;
|
|
142
|
-
|
|
143
|
+
let streamtext = parsed.choices[0].delta.content;
|
|
144
|
+
replytext.push(streamtext);
|
|
145
|
+
this.emit('chattext', { successed: true, text: streamtext, finish_reason: parsed.choices[0].finish_reason, index: parsed.choices[0].index, usage });
|
|
143
146
|
}
|
|
144
147
|
catch (error) {
|
|
145
148
|
this.emit('chaterror', { successed: false, error: 'JSON parse stream message', message });
|
package/package.json
CHANGED
package/src/openai.ts
CHANGED
|
@@ -114,12 +114,13 @@ export default class OpenAIGpt extends GptBase {
|
|
|
114
114
|
temperature: Number(callChatOption?.temperature || this.temperature),
|
|
115
115
|
max_tokens: Number(callChatOption?.maxtoken || this.maxtoken)
|
|
116
116
|
}, axiosOption);
|
|
117
|
+
let replytext:string[] = [];
|
|
117
118
|
response.data.on('data', (data:any) => {
|
|
118
119
|
const lines = data.toString().split('\n').filter((line:string) => line.trim() !== '');
|
|
119
120
|
for (const line of lines) {
|
|
120
121
|
const message = line.replace(/^data: /, '');
|
|
121
122
|
if (message === '[DONE]') {
|
|
122
|
-
this.emit('chatdone', { successed: true, finish_reason: finishreason, usage })
|
|
123
|
+
this.emit('chatdone', { successed: true, text: replytext.join(''), finish_reason: finishreason, usage })
|
|
123
124
|
return; // Stream finished
|
|
124
125
|
}
|
|
125
126
|
try {
|
|
@@ -128,7 +129,9 @@ export default class OpenAIGpt extends GptBase {
|
|
|
128
129
|
const parsed = JSON.parse(message);
|
|
129
130
|
finishreason = parsed.choices[0].finish_reason;
|
|
130
131
|
usage = parsed.usage;
|
|
131
|
-
|
|
132
|
+
let streamtext = parsed.choices[0].delta.content;
|
|
133
|
+
replytext.push(streamtext)
|
|
134
|
+
this.emit('chattext', { successed: true, text: streamtext, finish_reason: parsed.choices[0].finish_reason, index: parsed.choices[0].index, usage})
|
|
132
135
|
} catch (error) {
|
|
133
136
|
this.emit('chaterror', { successed: false, error: 'JSON parse stream message', message });
|
|
134
137
|
}
|