doomiaichat 7.1.16 → 7.1.18

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/corzbot.js CHANGED
@@ -129,16 +129,15 @@ class CorzBot extends gptbase_1.default {
129
129
  * @param _axiosOption
130
130
  */
131
131
  getRequestStream(client, message, callChatOption = {}) {
132
- var _a, _b;
132
+ var _a, _b, _c;
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  //简单的对话请求
135
- const conversation_id = (_a = callChatOption.session_id) !== null && _a !== void 0 ? _a : yield this.createCoversation(client);
136
135
  if (this.botid) {
137
136
  const req = {
138
137
  bot_id: this.botid,
139
138
  additional_messages: message,
140
139
  user_id: callChatOption.userid || callChatOption.cozeUserID,
141
- conversation_id,
140
+ conversation_id: (_a = callChatOption.session_id) !== null && _a !== void 0 ? _a : yield this.createCoversation(client),
142
141
  parameters: Object.assign({ request_src: 1 }, callChatOption.parameters || {}),
143
142
  };
144
143
  req.custom_variables = Object.assign({}, this.setting.customVariables || {}, callChatOption.customVariables || {});
@@ -158,7 +157,7 @@ class CorzBot extends gptbase_1.default {
158
157
  additional_messages: message,
159
158
  ext: callChatOption.ext,
160
159
  workflow_id: this.talkflowid,
161
- conversation_id,
160
+ conversation_id: (_c = callChatOption.session_id) !== null && _c !== void 0 ? _c : yield this.createCoversation(client),
162
161
  parameters: Object.assign({ request_src: 1 }, callChatOption.parameters || {}) //Object.assign({}, this.setting.customVariables || {}, callChatOption.customVariables || {}),
163
162
  //parameters: { input: message[0]?.content }
164
163
  };
@@ -316,7 +315,7 @@ class CorzBot extends gptbase_1.default {
316
315
  const stream = this.botid ? client.chat.stream(params) :
317
316
  (this.workflowid ? client.workflows.runs.stream(params) :
318
317
  client.workflows.chat.stream(params));
319
- let deltaindex = 0, fullanswer = [], followup = [], cardData = [];
318
+ let deltaindex = 0, fullanswer = [], cardfollowup = [], followup = [], cardData = [];
320
319
  let deepThinking = '', thinkingStatus = DeepThinkingStatus.None, cardResource = '', preresponseText = ''; // 是否在深度思考中
321
320
  try {
322
321
  for (var _g = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _a = stream_1_1.done, !_a;) {
@@ -354,8 +353,12 @@ class CorzBot extends gptbase_1.default {
354
353
  const allCards = cardResource.replace(/[\x00-\x1F\x7F]/g, '').split('|');
355
354
  for (const item of allCards) {
356
355
  const cardinfo = (0, querystring_1.parse)(item);
357
- if (cardinfo.type && cardinfo.tag)
358
- cardData.push(Object.assign({}, cardinfo));
356
+ if (cardinfo.type && cardinfo.tag) {
357
+ if (cardinfo.type === 'follow_up')
358
+ cardfollowup.push(cardinfo.tag);
359
+ else
360
+ cardData.push(Object.assign({}, cardinfo));
361
+ }
359
362
  }
360
363
  // 将卡片资源返回给客户端
361
364
  this.emit('chatcard', cardData);
@@ -397,7 +400,7 @@ class CorzBot extends gptbase_1.default {
397
400
  if (part.event === api_1.ChatEventType.CONVERSATION_CHAT_COMPLETED ||
398
401
  part.event === api_1.WorkflowEventType.DONE) {
399
402
  const { conversation_id, content } = (_f = (part.data)) !== null && _f !== void 0 ? _f : {};
400
- let output = { successed: true, cards: cardData.length ? cardData : null, followup, type: 'answer', content_type: 'text', role: api_1.RoleType.Assistant, requestid, segment: null, text: content !== null && content !== void 0 ? content : fullanswer.join(''), index: index++, session_id: conversation_id };
403
+ let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup, followup, type: 'answer', content_type: 'text', role: api_1.RoleType.Assistant, requestid, segment: null, text: content !== null && content !== void 0 ? content : fullanswer.join(''), index: index++, session_id: conversation_id };
401
404
  if (attach)
402
405
  output = Object.assign({}, output, attach);
403
406
  this.emit('chatdone', output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doomiaichat",
3
- "version": "7.1.16",
3
+ "version": "7.1.18",
4
4
  "description": "Doomisoft OpenAI",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/corzbot.ts CHANGED
@@ -120,13 +120,12 @@ export default class CorzBot extends GptBase {
120
120
  */
121
121
  async getRequestStream<T>(client: CozeAPI, message: EnterMessage[], callChatOption: any = {}): Promise<T> {
122
122
  //简单的对话请求
123
- const conversation_id = callChatOption.session_id ?? await this.createCoversation(client);
124
123
  if (this.botid) {
125
124
  const req: StreamChatReq = {
126
125
  bot_id: this.botid,
127
126
  additional_messages: message,
128
127
  user_id: callChatOption.userid || callChatOption.cozeUserID,
129
- conversation_id,
128
+ conversation_id: callChatOption.session_id ?? await this.createCoversation(client),
130
129
  parameters: Object.assign({ request_src: 1 }, callChatOption.parameters || {}),
131
130
  }
132
131
  req.custom_variables = Object.assign({}, this.setting.customVariables || {}, callChatOption.customVariables || {});
@@ -146,7 +145,7 @@ export default class CorzBot extends GptBase {
146
145
  additional_messages: message,
147
146
  ext: callChatOption.ext,
148
147
  workflow_id: this.talkflowid!,//callChatOption.workflowid,
149
- conversation_id,
148
+ conversation_id: callChatOption.session_id ?? await this.createCoversation(client),
150
149
  parameters: Object.assign({ request_src: 1 }, callChatOption.parameters || {}) //Object.assign({}, this.setting.customVariables || {}, callChatOption.customVariables || {}),
151
150
  //parameters: { input: message[0]?.content }
152
151
  }
@@ -291,7 +290,7 @@ export default class CorzBot extends GptBase {
291
290
  const stream = this.botid ? client.chat.stream(params as StreamChatReq) :
292
291
  (this.workflowid ? client.workflows.runs.stream(params as RunWorkflowReq) :
293
292
  client.workflows.chat.stream(params as ChatWorkflowReq));
294
- let deltaindex = 0, fullanswer: string[] = [], followup: string[] = [], cardData: CardType[] = [];
293
+ let deltaindex = 0, fullanswer: string[] = [],cardfollowup: string[] = [], followup: string[] = [], cardData: CardType[] = [];
295
294
  let deepThinking = '', thinkingStatus = DeepThinkingStatus.None, cardResource = '', preresponseText=''; // 是否在深度思考中
296
295
  for await (const part of stream) {
297
296
  if (part.event === ChatEventType.ERROR) return this.emit('chaterror', { successed: false, error: 'call failed' });
@@ -323,7 +322,12 @@ export default class CorzBot extends GptBase {
323
322
  const allCards = cardResource.replace(/[\x00-\x1F\x7F]/g, '').split('|')
324
323
  for (const item of allCards) {
325
324
  const cardinfo: any = parse(item);
326
- if (cardinfo.type && cardinfo.tag) cardData.push({ ...cardinfo })
325
+ if (cardinfo.type && cardinfo.tag) {
326
+ if (cardinfo.type === 'follow_up')
327
+ cardfollowup.push(cardinfo.tag);
328
+ else
329
+ cardData.push({ ...cardinfo })
330
+ }
327
331
  }
328
332
  // 将卡片资源返回给客户端
329
333
  this.emit('chatcard', cardData);
@@ -361,7 +365,7 @@ export default class CorzBot extends GptBase {
361
365
  part.event === WorkflowEventType.DONE
362
366
  ) {
363
367
  const { conversation_id, content } = (part.data) ?? {} as any;
364
- let output = { successed: true, cards: cardData.length ? cardData : null, followup, type: 'answer', content_type: 'text', role: RoleType.Assistant, requestid, segment: null, text: content ?? fullanswer.join(''), index: index++, session_id: conversation_id };
368
+ let output = { successed: true, cards: cardData.length ? cardData : null, cardfollowup, followup, type: 'answer', content_type: 'text', role: RoleType.Assistant, requestid, segment: null, text: content ?? fullanswer.join(''), index: index++, session_id: conversation_id };
365
369
  if (attach) output = Object.assign({}, output, attach);
366
370
  this.emit('chatdone', output)
367
371
  }