llm-exe 2.0.0-beta.10 → 2.0.0-beta.12
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/index.js +20 -13
- package/dist/index.mjs +20 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1371,7 +1371,7 @@ var _OpenAiFunctionParser = class _OpenAiFunctionParser extends BaseParser {
|
|
|
1371
1371
|
this.parser = options.parser;
|
|
1372
1372
|
}
|
|
1373
1373
|
parse(text, _options) {
|
|
1374
|
-
const functionUse = text
|
|
1374
|
+
const functionUse = text?.find((a) => a.type === "function_use");
|
|
1375
1375
|
if (functionUse && "name" in functionUse && "input" in functionUse) {
|
|
1376
1376
|
return {
|
|
1377
1377
|
name: functionUse.name,
|
|
@@ -2485,7 +2485,15 @@ async function apiRequest(url, options) {
|
|
|
2485
2485
|
try {
|
|
2486
2486
|
const response = await fetch(url, finalOptions);
|
|
2487
2487
|
if (!response.ok) {
|
|
2488
|
-
|
|
2488
|
+
let message = `HTTP error. Status: ${response.status}. Error Message: ${response?.statusText || "Unknown error."}`;
|
|
2489
|
+
if (url.startsWith("https://api.openai.com/")) {
|
|
2490
|
+
try {
|
|
2491
|
+
const body = await response.json();
|
|
2492
|
+
message = `HTTP error. Status Code: ${response.status}. Error Message: ${body?.error?.message || "No further details provided."}`;
|
|
2493
|
+
} catch (error) {
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
throw new Error(message);
|
|
2489
2497
|
}
|
|
2490
2498
|
const responseData = await response.json();
|
|
2491
2499
|
return responseData;
|
|
@@ -2792,18 +2800,17 @@ async function useLlm_call(state, messages, _options) {
|
|
|
2792
2800
|
}));
|
|
2793
2801
|
if (_options && _options?.jsonSchema) {
|
|
2794
2802
|
if (state.provider === "openai.chat") {
|
|
2795
|
-
const curr = input["response_format"] || {};
|
|
2796
|
-
const newObj = Object.assign(curr, {
|
|
2797
|
-
type: "json_schema",
|
|
2798
|
-
json_schema: {
|
|
2799
|
-
name: "output",
|
|
2800
|
-
schema: cleanJsonSchemaFor(_options?.jsonSchema, "openai.chat")
|
|
2801
|
-
}
|
|
2802
|
-
});
|
|
2803
2803
|
if (!!functionCallStrictInput) {
|
|
2804
|
-
|
|
2804
|
+
const curr = input["response_format"] || {};
|
|
2805
|
+
input["response_format"] = Object.assign(curr, {
|
|
2806
|
+
type: "json_schema",
|
|
2807
|
+
json_schema: {
|
|
2808
|
+
name: "output",
|
|
2809
|
+
strict: true,
|
|
2810
|
+
schema: cleanJsonSchemaFor(_options?.jsonSchema, "openai.chat")
|
|
2811
|
+
}
|
|
2812
|
+
});
|
|
2805
2813
|
}
|
|
2806
|
-
input["response_format"] = newObj;
|
|
2807
2814
|
}
|
|
2808
2815
|
}
|
|
2809
2816
|
if (_options && _options?.functionCall) {
|
|
@@ -2840,7 +2847,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
2840
2847
|
function: Object.assign(props, {
|
|
2841
2848
|
parameters: cleanJsonSchemaFor(props.parameters, "openai.chat")
|
|
2842
2849
|
}, {
|
|
2843
|
-
strict:
|
|
2850
|
+
strict: functionCallStrictInput
|
|
2844
2851
|
})
|
|
2845
2852
|
};
|
|
2846
2853
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1323,7 +1323,7 @@ var _OpenAiFunctionParser = class _OpenAiFunctionParser extends BaseParser {
|
|
|
1323
1323
|
this.parser = options.parser;
|
|
1324
1324
|
}
|
|
1325
1325
|
parse(text, _options) {
|
|
1326
|
-
const functionUse = text
|
|
1326
|
+
const functionUse = text?.find((a) => a.type === "function_use");
|
|
1327
1327
|
if (functionUse && "name" in functionUse && "input" in functionUse) {
|
|
1328
1328
|
return {
|
|
1329
1329
|
name: functionUse.name,
|
|
@@ -2437,7 +2437,15 @@ async function apiRequest(url, options) {
|
|
|
2437
2437
|
try {
|
|
2438
2438
|
const response = await fetch(url, finalOptions);
|
|
2439
2439
|
if (!response.ok) {
|
|
2440
|
-
|
|
2440
|
+
let message = `HTTP error. Status: ${response.status}. Error Message: ${response?.statusText || "Unknown error."}`;
|
|
2441
|
+
if (url.startsWith("https://api.openai.com/")) {
|
|
2442
|
+
try {
|
|
2443
|
+
const body = await response.json();
|
|
2444
|
+
message = `HTTP error. Status Code: ${response.status}. Error Message: ${body?.error?.message || "No further details provided."}`;
|
|
2445
|
+
} catch (error) {
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
throw new Error(message);
|
|
2441
2449
|
}
|
|
2442
2450
|
const responseData = await response.json();
|
|
2443
2451
|
return responseData;
|
|
@@ -2744,18 +2752,17 @@ async function useLlm_call(state, messages, _options) {
|
|
|
2744
2752
|
}));
|
|
2745
2753
|
if (_options && _options?.jsonSchema) {
|
|
2746
2754
|
if (state.provider === "openai.chat") {
|
|
2747
|
-
const curr = input["response_format"] || {};
|
|
2748
|
-
const newObj = Object.assign(curr, {
|
|
2749
|
-
type: "json_schema",
|
|
2750
|
-
json_schema: {
|
|
2751
|
-
name: "output",
|
|
2752
|
-
schema: cleanJsonSchemaFor(_options?.jsonSchema, "openai.chat")
|
|
2753
|
-
}
|
|
2754
|
-
});
|
|
2755
2755
|
if (!!functionCallStrictInput) {
|
|
2756
|
-
|
|
2756
|
+
const curr = input["response_format"] || {};
|
|
2757
|
+
input["response_format"] = Object.assign(curr, {
|
|
2758
|
+
type: "json_schema",
|
|
2759
|
+
json_schema: {
|
|
2760
|
+
name: "output",
|
|
2761
|
+
strict: true,
|
|
2762
|
+
schema: cleanJsonSchemaFor(_options?.jsonSchema, "openai.chat")
|
|
2763
|
+
}
|
|
2764
|
+
});
|
|
2757
2765
|
}
|
|
2758
|
-
input["response_format"] = newObj;
|
|
2759
2766
|
}
|
|
2760
2767
|
}
|
|
2761
2768
|
if (_options && _options?.functionCall) {
|
|
@@ -2792,7 +2799,7 @@ async function useLlm_call(state, messages, _options) {
|
|
|
2792
2799
|
function: Object.assign(props, {
|
|
2793
2800
|
parameters: cleanJsonSchemaFor(props.parameters, "openai.chat")
|
|
2794
2801
|
}, {
|
|
2795
|
-
strict:
|
|
2802
|
+
strict: functionCallStrictInput
|
|
2796
2803
|
})
|
|
2797
2804
|
};
|
|
2798
2805
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-exe",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
4
|
"description": "Simplify building LLM-powered apps with easy-to-use base components, supporting text and chat-based prompts with handlebars template engine, output parsers, and flexible function calling capabilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|