@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.
Files changed (3) hide show
  1. package/generate.js +5 -1
  2. package/index.js +9 -4
  3. 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: opts?.bearer || opts?.api_key || config.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: "prompt_formula",
215
- label: "Prompt expression",
215
+ name: "prompt_template",
216
+ label: "Prompt",
216
217
  sublabel:
217
- "JavaScript expression evalutating to the text of the prompt, based on the context",
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 (prompt_field === "Formula" || mode === "workflow")
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {