@saltcorn/large-language-model 0.8.5 → 0.8.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/index.js +20 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const Workflow = require("@saltcorn/data/models/workflow");
|
|
2
2
|
const Form = require("@saltcorn/data/models/form");
|
|
3
3
|
const File = require("@saltcorn/data/models/file");
|
|
4
|
+
const User = require("@saltcorn/data/models/user");
|
|
4
5
|
const FieldRepeat = require("@saltcorn/data/models/fieldrepeat");
|
|
5
6
|
const Plugin = require("@saltcorn/data/models/plugin");
|
|
6
7
|
const { domReady } = require("@saltcorn/markup/tags");
|
|
@@ -594,7 +595,20 @@ module.exports = {
|
|
|
594
595
|
llm_generate_image: {
|
|
595
596
|
description: "Generate image with AI based on a text prompt",
|
|
596
597
|
requireRow: true,
|
|
597
|
-
configFields: ({ table, mode }) => {
|
|
598
|
+
configFields: async ({ table, mode }) => {
|
|
599
|
+
const roleOptions = (await User.get_roles()).map((r) => ({
|
|
600
|
+
value: r.id,
|
|
601
|
+
label: r.role,
|
|
602
|
+
}));
|
|
603
|
+
const commonFields = [
|
|
604
|
+
{
|
|
605
|
+
label: "Minimum role to access",
|
|
606
|
+
name: "min_role",
|
|
607
|
+
input_type: "select",
|
|
608
|
+
sublabel: "User must have this role or higher access image file",
|
|
609
|
+
options: roleOptions,
|
|
610
|
+
},
|
|
611
|
+
];
|
|
598
612
|
if (mode === "workflow") {
|
|
599
613
|
return [
|
|
600
614
|
{
|
|
@@ -620,6 +634,7 @@ module.exports = {
|
|
|
620
634
|
sublabel: "Override default model name",
|
|
621
635
|
type: "String",
|
|
622
636
|
},
|
|
637
|
+
...commonFields,
|
|
623
638
|
];
|
|
624
639
|
} else if (table) {
|
|
625
640
|
const textFields = table.fields
|
|
@@ -652,6 +667,7 @@ module.exports = {
|
|
|
652
667
|
required: true,
|
|
653
668
|
attributes: { options: fileFields },
|
|
654
669
|
},
|
|
670
|
+
...commonFields,
|
|
655
671
|
];
|
|
656
672
|
}
|
|
657
673
|
},
|
|
@@ -665,8 +681,7 @@ module.exports = {
|
|
|
665
681
|
prompt_formula,
|
|
666
682
|
prompt_template,
|
|
667
683
|
answer_field,
|
|
668
|
-
|
|
669
|
-
chat_history_field,
|
|
684
|
+
min_role,
|
|
670
685
|
model,
|
|
671
686
|
},
|
|
672
687
|
}) => {
|
|
@@ -700,7 +715,8 @@ module.exports = {
|
|
|
700
715
|
"generated.png",
|
|
701
716
|
"image/png",
|
|
702
717
|
imgContents,
|
|
703
|
-
user?.id
|
|
718
|
+
user?.id,
|
|
719
|
+
min_role || 1
|
|
704
720
|
);
|
|
705
721
|
upd[answer_field] = file.path_to_serve;
|
|
706
722
|
}
|