@wzyjs/utils 0.3.26 → 0.3.27

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/node.cjs.js CHANGED
@@ -36321,7 +36321,13 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
36321
36321
  const errorText = await response.text();
36322
36322
  throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
36323
36323
  }
36324
- const data = await response.json();
36324
+ const responseText = await response.text();
36325
+ let data;
36326
+ try {
36327
+ data = JSON.parse(responseText);
36328
+ } catch (e) {
36329
+ throw new Error(`Failed to parse API response as JSON: ${e.message}. Raw response: ${responseText.slice(0, 500)}`);
36330
+ }
36325
36331
  const content = data?.choices?.[0]?.message?.content || data?.output || "";
36326
36332
  if (!content) {
36327
36333
  throw new Error("No content in response");
package/dist/node.esm.js CHANGED
@@ -35417,7 +35417,13 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
35417
35417
  const errorText = await response.text();
35418
35418
  throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
35419
35419
  }
35420
- const data = await response.json();
35420
+ const responseText = await response.text();
35421
+ let data;
35422
+ try {
35423
+ data = JSON.parse(responseText);
35424
+ } catch (e) {
35425
+ throw new Error(`Failed to parse API response as JSON: ${e.message}. Raw response: ${responseText.slice(0, 500)}`);
35426
+ }
35421
35427
  const content = data?.choices?.[0]?.message?.content || data?.output || "";
35422
35428
  if (!content) {
35423
35429
  throw new Error("No content in response");
package/dist/web.cjs.js CHANGED
@@ -19645,7 +19645,13 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
19645
19645
  const errorText = await response.text();
19646
19646
  throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
19647
19647
  }
19648
- const data = await response.json();
19648
+ const responseText = await response.text();
19649
+ let data;
19650
+ try {
19651
+ data = JSON.parse(responseText);
19652
+ } catch (e) {
19653
+ throw new Error(`Failed to parse API response as JSON: ${e.message}. Raw response: ${responseText.slice(0, 500)}`);
19654
+ }
19649
19655
  const content = data?.choices?.[0]?.message?.content || data?.output || "";
19650
19656
  if (!content) {
19651
19657
  throw new Error("No content in response");
package/dist/web.esm.js CHANGED
@@ -19454,7 +19454,13 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
19454
19454
  const errorText = await response.text();
19455
19455
  throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
19456
19456
  }
19457
- const data = await response.json();
19457
+ const responseText = await response.text();
19458
+ let data;
19459
+ try {
19460
+ data = JSON.parse(responseText);
19461
+ } catch (e) {
19462
+ throw new Error(`Failed to parse API response as JSON: ${e.message}. Raw response: ${responseText.slice(0, 500)}`);
19463
+ }
19458
19464
  const content = data?.choices?.[0]?.message?.content || data?.output || "";
19459
19465
  if (!content) {
19460
19466
  throw new Error("No content in response");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/utils",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "sideEffects": false,
@@ -70,7 +70,7 @@
70
70
  "@types/nodemailer": "^6.4.7",
71
71
  "@types/papaparse": "^5.3.15"
72
72
  },
73
- "gitHead": "cf770d4d9e94b1000eab84ce34f91a4e6ee912f6",
73
+ "gitHead": "f9e5dcf56fea3b93a2614ad468ecb466e5da7945",
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  }