@saltcorn/large-language-model 0.6.2 → 0.6.3
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 +5 -1
- package/index.js +9 -4
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -77,7 +77,11 @@ const getCompletion = async (config, opts) => {
|
|
|
77
77
|
return await getCompletionOpenAICompatible(
|
|
78
78
|
{
|
|
79
79
|
chatCompleteEndpoint: opts?.endpoint || config.endpoint,
|
|
80
|
-
bearer:
|
|
80
|
+
bearer:
|
|
81
|
+
opts?.bearer ||
|
|
82
|
+
opts?.api_key ||
|
|
83
|
+
config.bearer_auth ||
|
|
84
|
+
config.bearer,
|
|
81
85
|
apiKey: opts?.api_key || config.api_key,
|
|
82
86
|
model: opts?.model || config.model,
|
|
83
87
|
},
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const db = require("@saltcorn/data/db");
|
|
|
5
5
|
const { getCompletion, getEmbedding } = require("./generate");
|
|
6
6
|
const { OPENAI_MODELS } = require("./constants.js");
|
|
7
7
|
const { eval_expression } = require("@saltcorn/data/models/expression");
|
|
8
|
+
const { interpolate } = require("@saltcorn/data/utils");
|
|
8
9
|
|
|
9
10
|
const configuration_workflow = () =>
|
|
10
11
|
new Workflow({
|
|
@@ -211,11 +212,12 @@ module.exports = {
|
|
|
211
212
|
if (mode === "workflow") {
|
|
212
213
|
return [
|
|
213
214
|
{
|
|
214
|
-
name: "
|
|
215
|
-
label: "Prompt
|
|
215
|
+
name: "prompt_template",
|
|
216
|
+
label: "Prompt",
|
|
216
217
|
sublabel:
|
|
217
|
-
"
|
|
218
|
+
"Prompt text. Use interpolations {{ }} to access variables in the context",
|
|
218
219
|
type: "String",
|
|
220
|
+
fieldview: "textarea",
|
|
219
221
|
required: true,
|
|
220
222
|
},
|
|
221
223
|
{
|
|
@@ -268,12 +270,15 @@ module.exports = {
|
|
|
268
270
|
configuration: {
|
|
269
271
|
prompt_field,
|
|
270
272
|
prompt_formula,
|
|
273
|
+
prompt_template,
|
|
271
274
|
answer_field,
|
|
272
275
|
override_config,
|
|
273
276
|
},
|
|
274
277
|
}) => {
|
|
275
278
|
let prompt;
|
|
276
|
-
if (
|
|
279
|
+
if (mode === "workflow")
|
|
280
|
+
prompt = interpolate(prompt_template, row, user);
|
|
281
|
+
else if (prompt_field === "Formula" || mode === "workflow")
|
|
277
282
|
prompt = eval_expression(
|
|
278
283
|
prompt_formula,
|
|
279
284
|
row,
|