@leikeduntech/leiai-js 3.4.0 → 3.4.3

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 (2) hide show
  1. package/build/index.js +13 -3
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -464,7 +464,7 @@ Current date: ${currentDate}`;
464
464
  delete body.max_tokens;
465
465
  headers["Authorization"] = signTencentHunyuan(body, url, keyList);
466
466
  } else if (this._manufacturer.toLowerCase() === "baidu") {
467
- if (pluginList.indexOf("zhishiku") > -1) {
467
+ if (pluginList && pluginList.indexOf("zhishiku") > -1) {
468
468
  let query = messages.splice(messages.length - 1, 1);
469
469
  body = Object.assign(body, { query: (_a2 = query[0]) == null ? void 0 : _a2.content, history: messages });
470
470
  delete body.messages;
@@ -473,7 +473,14 @@ Current date: ${currentDate}`;
473
473
  if (this._apiOrg && this._manufacturer.toLowerCase() === "openai") {
474
474
  headers["OpenAI-Organization"] = this._apiOrg;
475
475
  }
476
- if (this._manufacturer.toLowerCase() !== "baidu" || pluginList.indexOf("zhishiku") < 0) {
476
+ if (this._manufacturer.toLowerCase() === "baidu" && typeof pluginList === "string" && pluginList.indexOf("zhishiku") > -1) {
477
+ if (body.model)
478
+ delete body.model;
479
+ if (body.max_tokens)
480
+ delete body.max_tokens;
481
+ if (body.temperature)
482
+ delete body.temperature;
483
+ } else {
477
484
  if (typeof body.plugins !== void 0)
478
485
  delete body.plugins;
479
486
  }
@@ -537,6 +544,9 @@ Current date: ${currentDate}`;
537
544
  }
538
545
  try {
539
546
  const response = JSON.parse(data);
547
+ if (this._debug) {
548
+ console.log(`row data ${typeof response} : `, response, response == null ? void 0 : response.choices);
549
+ }
540
550
  if (this._manufacturer.toLowerCase() === "baidu") {
541
551
  if ((response == null ? void 0 : response.is_end) === true) {
542
552
  result.text += response.result.trim();
@@ -651,7 +661,7 @@ Current date: ${currentDate}`;
651
661
  }
652
662
  const response = await res.json();
653
663
  if (this._debug) {
654
- console.log(`row data ${typeof response} : `, response, (_b = response == null ? void 0 : response.choices[0]) == null ? void 0 : _b.message);
664
+ console.log(`row data ${typeof response} : `, response, (response == null ? void 0 : response.choices) && ((_b = response == null ? void 0 : response.choices[0]) == null ? void 0 : _b.message));
655
665
  }
656
666
  if (this._manufacturer.toLowerCase() === "aliyun") {
657
667
  if (response == null ? void 0 : response.request_id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leikeduntech/leiai-js",
3
- "version": "3.4.0",
3
+ "version": "3.4.3",
4
4
  "author": "liuhean",
5
5
  "repository": {
6
6
  "type": "git",