@saltcorn/large-language-model 1.0.10 → 1.0.12
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 +29 -0
- package/index.js +11 -0
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -198,6 +198,34 @@ const getAudioTranscription = async (
|
|
|
198
198
|
|
|
199
199
|
const last = (xs) => xs[xs.length - 1];
|
|
200
200
|
|
|
201
|
+
const genericResponse = async (
|
|
202
|
+
{ backend, apiKey, api_key, provider, ai_sdk_provider, responses_api },
|
|
203
|
+
role,
|
|
204
|
+
prompt,
|
|
205
|
+
opts,
|
|
206
|
+
) => {
|
|
207
|
+
let chat = opts.chat;
|
|
208
|
+
let result = opts.prompt;
|
|
209
|
+
//console.log("chat", JSON.stringify(chat, null, 2));
|
|
210
|
+
switch (opts.backend || backend) {
|
|
211
|
+
case "AI SDK":
|
|
212
|
+
if (role === "assistant" && typeof prompt === "string")
|
|
213
|
+
opts.chat.push({
|
|
214
|
+
role,
|
|
215
|
+
content: [
|
|
216
|
+
{
|
|
217
|
+
type: "text",
|
|
218
|
+
text: prompt,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
else opts.chat.push({ role, content: prompt });
|
|
223
|
+
break;
|
|
224
|
+
default:
|
|
225
|
+
opts.chat.push({ role, content: prompt });
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
201
229
|
const toolResponse = async (
|
|
202
230
|
{ backend, apiKey, api_key, provider, ai_sdk_provider, responses_api },
|
|
203
231
|
opts,
|
|
@@ -1324,5 +1352,6 @@ module.exports = {
|
|
|
1324
1352
|
getImageGeneration,
|
|
1325
1353
|
getAudioTranscription,
|
|
1326
1354
|
toolResponse,
|
|
1355
|
+
genericResponse,
|
|
1327
1356
|
addImageMesssage,
|
|
1328
1357
|
};
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
getAudioTranscription,
|
|
14
14
|
toolResponse,
|
|
15
15
|
addImageMesssage,
|
|
16
|
+
genericResponse,
|
|
16
17
|
} = require("./generate");
|
|
17
18
|
const { OPENAI_MODELS } = require("./constants.js");
|
|
18
19
|
const { eval_expression } = require("@saltcorn/data/models/expression");
|
|
@@ -91,6 +92,7 @@ ${domReady(`
|
|
|
91
92
|
type: "String",
|
|
92
93
|
required: true,
|
|
93
94
|
fieldview: "password",
|
|
95
|
+
attributes: { autocomplete: "off" },
|
|
94
96
|
showIf: { backend: "AI SDK", ai_sdk_provider: "OpenAI" },
|
|
95
97
|
},
|
|
96
98
|
{
|
|
@@ -99,6 +101,7 @@ ${domReady(`
|
|
|
99
101
|
type: "String",
|
|
100
102
|
required: true,
|
|
101
103
|
fieldview: "password",
|
|
104
|
+
attributes: { autocomplete: "off" },
|
|
102
105
|
showIf: { backend: "AI SDK", ai_sdk_provider: "Anthropic" },
|
|
103
106
|
},
|
|
104
107
|
{
|
|
@@ -154,6 +157,7 @@ ${domReady(`
|
|
|
154
157
|
type: "String",
|
|
155
158
|
required: true,
|
|
156
159
|
fieldview: "password",
|
|
160
|
+
attributes: { autocomplete: "off" },
|
|
157
161
|
showIf: { backend: "OpenAI" },
|
|
158
162
|
},
|
|
159
163
|
{
|
|
@@ -316,6 +320,8 @@ ${domReady(`
|
|
|
316
320
|
name: "api_key",
|
|
317
321
|
label: "API key",
|
|
318
322
|
type: "String",
|
|
323
|
+
fieldview: "password",
|
|
324
|
+
attributes: { autocomplete: "off" },
|
|
319
325
|
showIf: { backend: "OpenAI-compatible API" },
|
|
320
326
|
},
|
|
321
327
|
{
|
|
@@ -387,6 +393,8 @@ ${domReady(`
|
|
|
387
393
|
name: "api_key",
|
|
388
394
|
label: "API key",
|
|
389
395
|
type: "String",
|
|
396
|
+
fieldview: "password",
|
|
397
|
+
attributes: { autocomplete: "off" },
|
|
390
398
|
},
|
|
391
399
|
],
|
|
392
400
|
}),
|
|
@@ -411,6 +419,7 @@ ${domReady(`
|
|
|
411
419
|
type: "String",
|
|
412
420
|
required: true,
|
|
413
421
|
fieldview: "password",
|
|
422
|
+
attributes: { autocomplete: "off" },
|
|
414
423
|
showIf: { alt_provider: "OpenAI" },
|
|
415
424
|
},
|
|
416
425
|
{
|
|
@@ -419,6 +428,7 @@ ${domReady(`
|
|
|
419
428
|
type: "String",
|
|
420
429
|
required: true,
|
|
421
430
|
fieldview: "password",
|
|
431
|
+
attributes: { autocomplete: "off" },
|
|
422
432
|
showIf: { alt_provider: "Anthropic" },
|
|
423
433
|
},
|
|
424
434
|
{
|
|
@@ -525,6 +535,7 @@ const functions = (config) => {
|
|
|
525
535
|
case "image":
|
|
526
536
|
return await addImageMesssage(config, { prompt, ...opts });
|
|
527
537
|
default:
|
|
538
|
+
return genericResponse(config, what, prompt, opts);
|
|
528
539
|
break;
|
|
529
540
|
}
|
|
530
541
|
},
|