@saltcorn/large-language-model 0.7.4 → 0.7.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/constants.js +7 -6
- package/generate.js +11 -2
- package/index.js +36 -1
- package/package.json +1 -1
package/constants.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
const OPENAI_MODELS = [
|
|
2
2
|
"gpt-3.5-turbo",
|
|
3
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
4
|
"gpt-4o-mini",
|
|
9
5
|
"gpt-4",
|
|
10
6
|
"gpt-4-32k",
|
|
11
7
|
"gpt-4-turbo-preview",
|
|
12
|
-
"gpt-4-1106-preview",
|
|
13
|
-
"gpt-4-0125-preview",
|
|
14
8
|
"gpt-4-turbo",
|
|
15
9
|
"gpt-4o",
|
|
10
|
+
"gpt-4.1",
|
|
11
|
+
"gpt-4.1-mini",
|
|
12
|
+
"gpt-4.1-nano",
|
|
13
|
+
"o1",
|
|
14
|
+
"o3",
|
|
15
|
+
"o3-mini",
|
|
16
|
+
"o4-mini",
|
|
16
17
|
];
|
|
17
18
|
|
|
18
19
|
// https://github.com/ollama/ollama/blob/main/docs/faq.md#where-are-models-stored
|
package/generate.js
CHANGED
|
@@ -56,7 +56,9 @@ const getEmbedding = async (config, opts) => {
|
|
|
56
56
|
if (!ollamaMod) throw new Error("Not implemented for this backend");
|
|
57
57
|
|
|
58
58
|
const { Ollama } = ollamaMod;
|
|
59
|
-
const ollama = new Ollama(
|
|
59
|
+
const ollama = new Ollama(
|
|
60
|
+
config.ollama_host ? { host: config.ollama_host } : undefined
|
|
61
|
+
);
|
|
60
62
|
const olres = await ollama.embeddings({
|
|
61
63
|
model: opts?.model || config.embed_model || config.model,
|
|
62
64
|
prompt: opts.prompt,
|
|
@@ -319,10 +321,16 @@ const getCompletionGoogleVertex = async (config, opts, oauth2Client) => {
|
|
|
319
321
|
});
|
|
320
322
|
const generativeModel = vertexAI.getGenerativeModel({
|
|
321
323
|
model: config.model,
|
|
324
|
+
systemInstruction: {
|
|
325
|
+
role: "system",
|
|
326
|
+
parts: [{ text: opts.systemPrompt || "You are a helpful assistant." }],
|
|
327
|
+
},
|
|
328
|
+
generationCon0fig: {
|
|
329
|
+
temperature: config.temperature || 0.7,
|
|
330
|
+
},
|
|
322
331
|
});
|
|
323
332
|
const chatParams = {
|
|
324
333
|
history: convertChatToVertex(opts.chat),
|
|
325
|
-
systemPrompt: opts.systemPrompt || "You are a helpful assistant.",
|
|
326
334
|
};
|
|
327
335
|
if (opts?.tools?.length > 0) {
|
|
328
336
|
chatParams.tools = [
|
|
@@ -344,6 +352,7 @@ const getCompletionGoogleVertex = async (config, opts, oauth2Client) => {
|
|
|
344
352
|
if (part.functionCall) {
|
|
345
353
|
const toolCall = {
|
|
346
354
|
function: prepFuncArgsForChat(part.functionCall),
|
|
355
|
+
id: Math.floor(Math.random() * 1000000),
|
|
347
356
|
};
|
|
348
357
|
if (!result.tool_calls) result.tool_calls = [toolCall];
|
|
349
358
|
else result.tool_calls.push(toolCall);
|
package/index.js
CHANGED
|
@@ -65,6 +65,13 @@ ${domReady(`
|
|
|
65
65
|
onChange: "backendChange(this)",
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
name: "ollama_host",
|
|
70
|
+
label: "Host",
|
|
71
|
+
sublabel: "Optional, for remote ollama server",
|
|
72
|
+
type: "String",
|
|
73
|
+
showIf: { backend: "Local Ollama" },
|
|
74
|
+
},
|
|
68
75
|
{
|
|
69
76
|
name: "client_id",
|
|
70
77
|
label: "Client ID",
|
|
@@ -95,10 +102,28 @@ ${domReady(`
|
|
|
95
102
|
type: "String",
|
|
96
103
|
showIf: { backend: "Google Vertex AI" },
|
|
97
104
|
attributes: {
|
|
98
|
-
options: [
|
|
105
|
+
options: [
|
|
106
|
+
"gemini-1.5-pro",
|
|
107
|
+
"gemini-1.5-flash",
|
|
108
|
+
"gemini-2.0-flash",
|
|
109
|
+
],
|
|
99
110
|
},
|
|
100
111
|
required: true,
|
|
101
112
|
},
|
|
113
|
+
{
|
|
114
|
+
name: "temperature",
|
|
115
|
+
label: "Temperature",
|
|
116
|
+
type: "Float",
|
|
117
|
+
sublabel:
|
|
118
|
+
"Controls the randomness of predictions. Higher values make the output more random.",
|
|
119
|
+
showIf: { backend: "Google Vertex AI" },
|
|
120
|
+
default: 0.7,
|
|
121
|
+
attributes: {
|
|
122
|
+
min: 0,
|
|
123
|
+
max: 1,
|
|
124
|
+
decimal_places: 1,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
102
127
|
{
|
|
103
128
|
name: "embed_model",
|
|
104
129
|
label: "Embedding model",
|
|
@@ -303,6 +328,11 @@ const routes = (config) => {
|
|
|
303
328
|
url: "/large-language-model/vertex/authorize",
|
|
304
329
|
method: "get",
|
|
305
330
|
callback: async (req, res) => {
|
|
331
|
+
const role = req?.user?.role_id || 100;
|
|
332
|
+
if (role > 1) {
|
|
333
|
+
req.flash("error", req.__("Not authorized"));
|
|
334
|
+
return res.redirect("/");
|
|
335
|
+
}
|
|
306
336
|
const { client_id, client_secret } = config || {};
|
|
307
337
|
const baseUrl = (
|
|
308
338
|
getState().getConfig("base_url") || "http://localhost:3000"
|
|
@@ -325,6 +355,11 @@ const routes = (config) => {
|
|
|
325
355
|
url: "/large-language-model/vertex/callback",
|
|
326
356
|
method: "get",
|
|
327
357
|
callback: async (req, res) => {
|
|
358
|
+
const role = req?.user?.role_id || 100;
|
|
359
|
+
if (role > 1) {
|
|
360
|
+
req.flash("error", req.__("Not authorized"));
|
|
361
|
+
return res.redirect("/");
|
|
362
|
+
}
|
|
328
363
|
const { client_id, client_secret } = config || {};
|
|
329
364
|
const baseUrl = (
|
|
330
365
|
getState().getConfig("base_url") || "http://localhost:3000"
|