@saltcorn/large-language-model 0.7.4 → 0.7.5

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.
Files changed (3) hide show
  1. package/generate.js +8 -1
  2. package/index.js +29 -1
  3. package/package.json +1 -1
package/generate.js CHANGED
@@ -319,10 +319,16 @@ const getCompletionGoogleVertex = async (config, opts, oauth2Client) => {
319
319
  });
320
320
  const generativeModel = vertexAI.getGenerativeModel({
321
321
  model: config.model,
322
+ systemInstruction: {
323
+ role: "system",
324
+ parts: [{ text: opts.systemPrompt || "You are a helpful assistant." }],
325
+ },
326
+ generationCon0fig: {
327
+ temperature: config.temperature || 0.7,
328
+ },
322
329
  });
323
330
  const chatParams = {
324
331
  history: convertChatToVertex(opts.chat),
325
- systemPrompt: opts.systemPrompt || "You are a helpful assistant.",
326
332
  };
327
333
  if (opts?.tools?.length > 0) {
328
334
  chatParams.tools = [
@@ -344,6 +350,7 @@ const getCompletionGoogleVertex = async (config, opts, oauth2Client) => {
344
350
  if (part.functionCall) {
345
351
  const toolCall = {
346
352
  function: prepFuncArgsForChat(part.functionCall),
353
+ id: Math.floor(Math.random() * 1000000),
347
354
  };
348
355
  if (!result.tool_calls) result.tool_calls = [toolCall];
349
356
  else result.tool_calls.push(toolCall);
package/index.js CHANGED
@@ -95,10 +95,28 @@ ${domReady(`
95
95
  type: "String",
96
96
  showIf: { backend: "Google Vertex AI" },
97
97
  attributes: {
98
- options: ["gemini-1.5-pro", "gemini-1.5-flash"],
98
+ options: [
99
+ "gemini-1.5-pro",
100
+ "gemini-1.5-flash",
101
+ "gemini-2.0-flash",
102
+ ],
99
103
  },
100
104
  required: true,
101
105
  },
106
+ {
107
+ name: "temperature",
108
+ label: "Temperature",
109
+ type: "Float",
110
+ sublabel:
111
+ "Controls the randomness of predictions. Higher values make the output more random.",
112
+ showIf: { backend: "Google Vertex AI" },
113
+ default: 0.7,
114
+ attributes: {
115
+ min: 0,
116
+ max: 1,
117
+ decimal_places: 1,
118
+ },
119
+ },
102
120
  {
103
121
  name: "embed_model",
104
122
  label: "Embedding model",
@@ -303,6 +321,11 @@ const routes = (config) => {
303
321
  url: "/large-language-model/vertex/authorize",
304
322
  method: "get",
305
323
  callback: async (req, res) => {
324
+ const role = req?.user?.role_id || 100;
325
+ if (role > 1) {
326
+ req.flash("error", req.__("Not authorized"));
327
+ return res.redirect("/");
328
+ }
306
329
  const { client_id, client_secret } = config || {};
307
330
  const baseUrl = (
308
331
  getState().getConfig("base_url") || "http://localhost:3000"
@@ -325,6 +348,11 @@ const routes = (config) => {
325
348
  url: "/large-language-model/vertex/callback",
326
349
  method: "get",
327
350
  callback: async (req, res) => {
351
+ const role = req?.user?.role_id || 100;
352
+ if (role > 1) {
353
+ req.flash("error", req.__("Not authorized"));
354
+ return res.redirect("/");
355
+ }
328
356
  const { client_id, client_secret } = config || {};
329
357
  const baseUrl = (
330
358
  getState().getConfig("base_url") || "http://localhost:3000"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {