@saltcorn/large-language-model 0.9.5 → 0.9.6
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/generate.js +6 -6
- package/index.js +17 -3
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -213,6 +213,7 @@ const getCompletionAISDK = async (
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
const body = {
|
|
216
|
+
...rest,
|
|
216
217
|
model: model_obj,
|
|
217
218
|
messages: [
|
|
218
219
|
{
|
|
@@ -222,7 +223,6 @@ const getCompletionAISDK = async (
|
|
|
222
223
|
...chat,
|
|
223
224
|
...(prompt ? [{ role: "user", content: prompt }] : []),
|
|
224
225
|
],
|
|
225
|
-
...rest,
|
|
226
226
|
};
|
|
227
227
|
if (rest.temperature || temperature) {
|
|
228
228
|
const str_or_num = rest.temperature || temperature;
|
|
@@ -257,7 +257,7 @@ const getCompletionAISDK = async (
|
|
|
257
257
|
const debugRequest = { ...body, model: use_model_name };
|
|
258
258
|
if (debugResult)
|
|
259
259
|
console.log("AI SDK request", JSON.stringify(debugRequest, null, 2));
|
|
260
|
-
getState().log(6, `
|
|
260
|
+
getState().log(6, `AI SDK request ${JSON.stringify(debugRequest)} `);
|
|
261
261
|
if (debugCollector) debugCollector.request = debugRequest;
|
|
262
262
|
const reqTimeStart = Date.now();
|
|
263
263
|
|
|
@@ -270,8 +270,8 @@ const getCompletionAISDK = async (
|
|
|
270
270
|
}
|
|
271
271
|
} else results = await generateText(body);
|
|
272
272
|
if (debugResult)
|
|
273
|
-
console.log("
|
|
274
|
-
else getState().log(6, `
|
|
273
|
+
console.log("AI SDK response", JSON.stringify(results, null, 2));
|
|
274
|
+
else getState().log(6, `AI SDK response ${JSON.stringify(results)}`);
|
|
275
275
|
if (debugCollector) {
|
|
276
276
|
debugCollector.response = results;
|
|
277
277
|
debugCollector.response_time_ms = Date.now() - reqTimeStart;
|
|
@@ -669,11 +669,11 @@ const getEmbeddingAISDK = async (config, { prompt, model, debugResult }) => {
|
|
|
669
669
|
providerOptions,
|
|
670
670
|
};
|
|
671
671
|
if (Array.isArray(prompt)) {
|
|
672
|
-
body.values = prompt
|
|
672
|
+
body.values = prompt;
|
|
673
673
|
const { embeddings } = await embedMany(body);
|
|
674
674
|
return embeddings;
|
|
675
675
|
} else {
|
|
676
|
-
body.value = prompt
|
|
676
|
+
body.value = prompt;
|
|
677
677
|
const { embedding } = await embed(body);
|
|
678
678
|
return embedding;
|
|
679
679
|
}
|
package/index.js
CHANGED
|
@@ -809,6 +809,7 @@ module.exports = {
|
|
|
809
809
|
{
|
|
810
810
|
name: "name",
|
|
811
811
|
label: "Name",
|
|
812
|
+
class: "validate-identifier",
|
|
812
813
|
sublabel: "The field name, as a valid JavaScript identifier",
|
|
813
814
|
type: "String",
|
|
814
815
|
required: true,
|
|
@@ -828,6 +829,13 @@ module.exports = {
|
|
|
828
829
|
options: ["string", "integer", "number", "boolean"],
|
|
829
830
|
},
|
|
830
831
|
},
|
|
832
|
+
{
|
|
833
|
+
name: "options",
|
|
834
|
+
label: "Options",
|
|
835
|
+
type: "String",
|
|
836
|
+
sublabel: "Optional. Comma-separated list of values",
|
|
837
|
+
showIf: { type: "string" },
|
|
838
|
+
},
|
|
831
839
|
],
|
|
832
840
|
});
|
|
833
841
|
|
|
@@ -943,6 +951,10 @@ module.exports = {
|
|
|
943
951
|
type: field.type,
|
|
944
952
|
description: field.description,
|
|
945
953
|
};
|
|
954
|
+
if (field.type === "string" && field.options)
|
|
955
|
+
fieldArgs[field.name].enum = field.options
|
|
956
|
+
.split(",")
|
|
957
|
+
.map((s) => s.trim());
|
|
946
958
|
});
|
|
947
959
|
const argObj = { type: "object", properties: fieldArgs };
|
|
948
960
|
const args = {
|
|
@@ -969,9 +981,11 @@ module.exports = {
|
|
|
969
981
|
...opts,
|
|
970
982
|
...toolargs,
|
|
971
983
|
});
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
]
|
|
984
|
+
console.log(JSON.stringify(compl, null, 2));
|
|
985
|
+
|
|
986
|
+
const ans = compl.tool_calls[0].input
|
|
987
|
+
? compl.tool_calls[0].input[answer_field]
|
|
988
|
+
: JSON.parse(compl.tool_calls[0].function.arguments)[answer_field];
|
|
975
989
|
const upd = { [answer_field]: ans };
|
|
976
990
|
if (chat_history_field) {
|
|
977
991
|
upd[chat_history_field] = [
|