@saltcorn/large-language-model 0.7.6 → 0.7.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.
Files changed (2) hide show
  1. package/generate.js +10 -12
  2. package/package.json +2 -2
package/generate.js CHANGED
@@ -9,7 +9,7 @@ const {
9
9
  } = require("@google-cloud/aiplatform");
10
10
  const { google } = require("googleapis");
11
11
  const Plugin = require("@saltcorn/data/models/plugin");
12
-
12
+ const path = require("path");
13
13
  const { features, getState } = require("@saltcorn/data/db/state");
14
14
  let ollamaMod;
15
15
  if (features.esm_plugins) ollamaMod = require("ollama");
@@ -104,17 +104,15 @@ const getCompletion = async (config, opts) => {
104
104
  opts
105
105
  );
106
106
  case "Local Ollama":
107
- if (!ollamaMod) throw new Error("Not implemented for this backend");
108
-
109
- const { Ollama } = ollamaMod;
110
-
111
- const ollama = new Ollama();
112
- const olres = await ollama.generate({
113
- model: opts?.model || config.model,
114
- ...opts,
115
- });
116
- //console.log("the response ", olres);
117
- return olres.response;
107
+ return await getCompletionOpenAICompatible(
108
+ {
109
+ chatCompleteEndpoint: config.ollama_host
110
+ ? path.join(config.ollama_host, "v1/chat/completions")
111
+ : "http://localhost:11434/v1/chat/completions",
112
+ model: opts?.model || config.model,
113
+ },
114
+ opts
115
+ );
118
116
  case "Local llama.cpp":
119
117
  //TODO only check if unsafe plugins not allowed
120
118
  const isRoot = db.getTenantSchema() === db.connectObj.default_schema;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@saltcorn/data": "^0.9.0",
8
8
  "node-fetch": "2.6.9",
9
9
  "underscore": "1.13.6",
10
- "ollama": "0.5.0",
10
+ "ollama": "0.5.15",
11
11
  "@google-cloud/vertexai": "^1.9.3",
12
12
  "@google-cloud/aiplatform": "^3.34.0",
13
13
  "googleapis": "^144.0.0"