@saltcorn/large-language-model 0.2.0 → 0.2.1
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/generate.js +11 -7
- package/package.json +2 -2
package/generate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fetch = require("node-fetch");
|
|
2
2
|
const util = require("util");
|
|
3
3
|
const exec = util.promisify(require("child_process").exec);
|
|
4
4
|
const db = require("@saltcorn/data/db");
|
|
@@ -52,12 +52,10 @@ const getCompletionOpenAICompatible = async (
|
|
|
52
52
|
) => {
|
|
53
53
|
const headers = {
|
|
54
54
|
"Content-Type": "application/json",
|
|
55
|
+
Accept: "application/json",
|
|
55
56
|
};
|
|
56
57
|
if (bearer) headers.Authorization = "Bearer " + bearer;
|
|
57
|
-
const
|
|
58
|
-
headers,
|
|
59
|
-
});
|
|
60
|
-
const params = {
|
|
58
|
+
const body = {
|
|
61
59
|
//prompt: "How are you?",
|
|
62
60
|
model,
|
|
63
61
|
messages: [
|
|
@@ -69,9 +67,15 @@ const getCompletionOpenAICompatible = async (
|
|
|
69
67
|
],
|
|
70
68
|
temperature: temperature || 0.7,
|
|
71
69
|
};
|
|
70
|
+
const rawResponse = await fetch(chatCompleteEndpoint, {
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers,
|
|
73
|
+
body: JSON.stringify(body),
|
|
74
|
+
});
|
|
75
|
+
const results = await rawResponse.json();
|
|
76
|
+
console.log(results);
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
return results?.data?.choices?.[0]?.message?.content;
|
|
78
|
+
return results?.choices?.[0]?.message?.content;
|
|
75
79
|
};
|
|
76
80
|
|
|
77
81
|
module.exports = { getCompletion };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/large-language-model",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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
10
|
},
|
|
11
11
|
"author": "Tom Nielsen",
|