@saltcorn/large-language-model 1.0.6 → 1.0.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.
package/generate.js CHANGED
@@ -429,7 +429,9 @@ const getAiSdkModel = ({ config, alt_config, userCfg }, isEmbedding) => {
429
429
  ? config.alt_aisdk_configs?.find?.((acfg) => acfg.name === alt_config) ||
430
430
  config
431
431
  : config;
432
- const use_provider = use_config.provider;
432
+
433
+ const use_provider = use_config.alt_provider || use_config.provider;
434
+
433
435
  const model_name = isEmbedding
434
436
  ? userCfg.embed_model ||
435
437
  userCfg.model ||
@@ -440,7 +442,10 @@ const getAiSdkModel = ({ config, alt_config, userCfg }, isEmbedding) => {
440
442
  switch (use_provider) {
441
443
  case "OpenAI":
442
444
  const use_api_key =
443
- userCfg.api_key || userCfg.apiKey || use_config.api_key;
445
+ userCfg.api_key ||
446
+ userCfg.apiKey ||
447
+ use_config.api_key ||
448
+ use_config.apiKey;
444
449
  const openai = createOpenAI({ apiKey: use_api_key });
445
450
  return isEmbedding
446
451
  ? openai.textEmbeddingModel(model_name)
@@ -455,7 +460,7 @@ const getAiSdkModel = ({ config, alt_config, userCfg }, isEmbedding) => {
455
460
  });
456
461
  return anthropic(model_name);
457
462
  default:
458
- throw new Error("Provider not found: " + provider);
463
+ throw new Error("Provider not found: " + use_provider);
459
464
  }
460
465
  };
461
466
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/tests/llm.test.js CHANGED
@@ -17,7 +17,7 @@ beforeAll(async () => {
17
17
  // run with:
18
18
  // saltcorn dev:plugin-test -d ~/large-language-model/
19
19
 
20
- jest.setTimeout(30000);
20
+ jest.setTimeout(40000);
21
21
 
22
22
  for (const nameconfig of require("./configs")) {
23
23
  const { name, ...config } = nameconfig;