@saltcorn/large-language-model 0.4.5 → 0.4.8
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/constants.js +25 -0
- package/index.js +4 -14
- package/model.js +6 -14
- package/package.json +1 -1
package/constants.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const OPENAI_MODELS = [
|
|
2
|
+
"gpt-3.5-turbo",
|
|
3
|
+
"gpt-3.5-turbo-16k",
|
|
4
|
+
"gpt-3.5-turbo-1106",
|
|
5
|
+
"gpt-3.5-turbo-0125",
|
|
6
|
+
"gpt-3.5-turbo-0613",
|
|
7
|
+
"gpt-3.5-turbo-16k-0613",
|
|
8
|
+
"gpt-4o-mini",
|
|
9
|
+
"gpt-4",
|
|
10
|
+
"gpt-4-32k",
|
|
11
|
+
"gpt-4-turbo-preview",
|
|
12
|
+
"gpt-4-1106-preview",
|
|
13
|
+
"gpt-4-0125-preview",
|
|
14
|
+
"gpt-4-turbo",
|
|
15
|
+
"gpt-4o",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// https://github.com/ollama/ollama/blob/main/docs/faq.md#where-are-models-stored
|
|
19
|
+
const OLLAMA_MODELS_PATH = {
|
|
20
|
+
Darwin: `${process.env.HOME}/.ollama/models`,
|
|
21
|
+
Linux: "/usr/share/ollama/.ollama/models",
|
|
22
|
+
Windows_NT: "C:\\Users\\%username%\\.ollama\\models.",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = { OPENAI_MODELS, OLLAMA_MODELS_PATH };
|
package/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const Workflow = require("@saltcorn/data/models/workflow");
|
|
2
2
|
const Form = require("@saltcorn/data/models/form");
|
|
3
|
-
const { getCompletion, getEmbedding } = require("./generate");
|
|
4
3
|
const db = require("@saltcorn/data/db");
|
|
4
|
+
const { getCompletion, getEmbedding } = require("./generate");
|
|
5
|
+
const { OPENAI_MODELS } = require("./constants.js");
|
|
5
6
|
|
|
6
7
|
const configuration_workflow = () =>
|
|
7
8
|
new Workflow({
|
|
@@ -55,18 +56,7 @@ const configuration_workflow = () =>
|
|
|
55
56
|
required: true,
|
|
56
57
|
showIf: { backend: "OpenAI" },
|
|
57
58
|
attributes: {
|
|
58
|
-
options:
|
|
59
|
-
"gpt-3.5-turbo",
|
|
60
|
-
"gpt-3.5-turbo-16k",
|
|
61
|
-
"gpt-3.5-turbo-1106",
|
|
62
|
-
"gpt-3.5-turbo-0125",
|
|
63
|
-
"gpt-4",
|
|
64
|
-
"gpt-4-32k",
|
|
65
|
-
"gpt-4-turbo-preview",
|
|
66
|
-
"gpt-4-1106-preview",
|
|
67
|
-
"gpt-4-0125-preview",
|
|
68
|
-
"gpt-4-turbo",
|
|
69
|
-
],
|
|
59
|
+
options: OPENAI_MODELS,
|
|
70
60
|
},
|
|
71
61
|
},
|
|
72
62
|
{
|
|
@@ -121,7 +111,7 @@ const configuration_workflow = () =>
|
|
|
121
111
|
label: "Embedding endpoint",
|
|
122
112
|
type: "String",
|
|
123
113
|
sublabel:
|
|
124
|
-
"Optional.
|
|
114
|
+
"Optional. Example: http://localhost:11434/api/embeddings",
|
|
125
115
|
showIf: { backend: "Local Ollama" },
|
|
126
116
|
},
|
|
127
117
|
],
|
package/model.js
CHANGED
|
@@ -12,6 +12,7 @@ const fs = require("fs");
|
|
|
12
12
|
const _ = require("underscore");
|
|
13
13
|
|
|
14
14
|
const { getCompletion } = require("./generate");
|
|
15
|
+
const { OPENAI_MODELS, OLLAMA_MODELS_PATH } = require("./constants");
|
|
15
16
|
|
|
16
17
|
const configuration_workflow = (config) => (req) =>
|
|
17
18
|
new Workflow({
|
|
@@ -32,18 +33,9 @@ const configuration_workflow = (config) => (req) =>
|
|
|
32
33
|
if (config.backend === "Local llama.cpp") {
|
|
33
34
|
models = fs.readdirSync(path.join(config.llama_dir, "models"));
|
|
34
35
|
} else if (config.backend === "OpenAI") {
|
|
35
|
-
models =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"gpt-3.5-turbo-1106",
|
|
39
|
-
"gpt-3.5-turbo-0125",
|
|
40
|
-
"gpt-4",
|
|
41
|
-
"gpt-4-32k",
|
|
42
|
-
"gpt-4-turbo-preview",
|
|
43
|
-
"gpt-4-1106-preview",
|
|
44
|
-
"gpt-4-0125-preview",
|
|
45
|
-
"gpt-4-turbo",
|
|
46
|
-
];
|
|
36
|
+
models = OPENAI_MODELS;
|
|
37
|
+
} else if (config.backend === "Local Ollama") {
|
|
38
|
+
models = fs.readdirSync(path.join(OLLAMA_MODELS_PATH[os.type()], "manifests/registry.ollama.ai/library"));
|
|
47
39
|
}
|
|
48
40
|
return new Form({
|
|
49
41
|
fields: [
|
|
@@ -108,7 +100,7 @@ const modelpatterns = (config) => ({
|
|
|
108
100
|
name: "repeat_penalty",
|
|
109
101
|
label: "Repeat penalty",
|
|
110
102
|
type: "Float",
|
|
111
|
-
attributes: { min: 0 },
|
|
103
|
+
attributes: { min: 0, decimal_places: 1 },
|
|
112
104
|
default: 1.1,
|
|
113
105
|
},
|
|
114
106
|
]
|
|
@@ -117,7 +109,7 @@ const modelpatterns = (config) => ({
|
|
|
117
109
|
name: "temp",
|
|
118
110
|
label: "Temperature",
|
|
119
111
|
type: "Float",
|
|
120
|
-
attributes: { min: 0 },
|
|
112
|
+
attributes: { min: 0, max: 1, decimal_places: 1 },
|
|
121
113
|
default: 0.8,
|
|
122
114
|
},
|
|
123
115
|
],
|