@saltcorn/large-language-model 0.6.5 → 0.6.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 +5 -3
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -174,12 +174,12 @@ const getCompletionOpenAICompatible = async (
|
|
|
174
174
|
console.log("OpenAI response", JSON.stringify(results, null, 2));
|
|
175
175
|
if (results.error) throw new Error(`OpenAI error: ${results.error.message}`);
|
|
176
176
|
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
return results?.choices?.[0]?.message?.tool_calls
|
|
178
|
+
? {
|
|
179
|
+
tool_calls: results?.choices?.[0]?.message?.tool_calls,
|
|
180
|
+
content: results?.choices?.[0]?.message?.content || null,
|
|
181
|
+
}
|
|
182
|
+
: results?.choices?.[0]?.message?.content || null;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
const getEmbeddingOpenAICompatible = async (
|
package/index.js
CHANGED
|
@@ -194,6 +194,7 @@ module.exports = {
|
|
|
194
194
|
actions: (config) => ({
|
|
195
195
|
llm_function_call: require("./function-insert-action.js")(config),
|
|
196
196
|
llm_generate: {
|
|
197
|
+
description: "Generate text with AI based on a text prompt",
|
|
197
198
|
requireRow: true,
|
|
198
199
|
configFields: ({ table, mode }) => {
|
|
199
200
|
const override_fields =
|
|
@@ -317,7 +318,7 @@ module.exports = {
|
|
|
317
318
|
upd[chat_history_field] = [
|
|
318
319
|
...history,
|
|
319
320
|
{ role: "user", content: prompt },
|
|
320
|
-
{ role: "
|
|
321
|
+
{ role: "assistant", content: ans },
|
|
321
322
|
];
|
|
322
323
|
}
|
|
323
324
|
if (mode === "workflow") return upd;
|
|
@@ -325,6 +326,7 @@ module.exports = {
|
|
|
325
326
|
},
|
|
326
327
|
},
|
|
327
328
|
llm_generate_json: {
|
|
329
|
+
description: "Generate JSON with AI based on a text prompt. You must sppecify the JSON fields in the configuration.",
|
|
328
330
|
requireRow: true,
|
|
329
331
|
configFields: ({ table, mode }) => {
|
|
330
332
|
const override_fields =
|
|
@@ -427,7 +429,7 @@ module.exports = {
|
|
|
427
429
|
label: "Multiple",
|
|
428
430
|
type: "Bool",
|
|
429
431
|
sublabel:
|
|
430
|
-
"Select to generate an array of objects. Unselect for a single object",
|
|
432
|
+
"Select (true) to generate an array of objects. Unselect (false) for a single object",
|
|
431
433
|
},
|
|
432
434
|
{
|
|
433
435
|
name: "gen_description",
|
|
@@ -512,7 +514,7 @@ module.exports = {
|
|
|
512
514
|
upd[chat_history_field] = [
|
|
513
515
|
...history,
|
|
514
516
|
{ role: "user", content: prompt },
|
|
515
|
-
{ role: "
|
|
517
|
+
{ role: "assistant", content: ans },
|
|
516
518
|
];
|
|
517
519
|
}
|
|
518
520
|
if (mode === "workflow") return upd;
|