@saltcorn/large-language-model 0.4.8 → 0.4.9
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 +20 -12
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -13,17 +13,21 @@ const getEmbedding = async (config, opts) => {
|
|
|
13
13
|
return await getEmbeddingOpenAICompatible(
|
|
14
14
|
{
|
|
15
15
|
embeddingsEndpoint: "https://api.openai.com/v1/embeddings",
|
|
16
|
-
bearer: config.api_key,
|
|
17
|
-
embed_model: config.embed_model,
|
|
16
|
+
bearer: opts?.api_key || config.api_key,
|
|
17
|
+
embed_model: opts?.model || config.embed_model,
|
|
18
18
|
},
|
|
19
19
|
opts
|
|
20
20
|
);
|
|
21
21
|
case "OpenAI-compatible API":
|
|
22
22
|
return await getEmbeddingOpenAICompatible(
|
|
23
23
|
{
|
|
24
|
-
embeddingsEndpoint: config.embed_endpoint,
|
|
25
|
-
bearer: config.api_key,
|
|
26
|
-
embed_model:
|
|
24
|
+
embeddingsEndpoint: opts?.endpoint || config.embed_endpoint,
|
|
25
|
+
bearer: opts?.bearer || opts?.api_key || config.api_key,
|
|
26
|
+
embed_model:
|
|
27
|
+
opts?.embed_model ||
|
|
28
|
+
opts?.model ||
|
|
29
|
+
config.embed_model ||
|
|
30
|
+
config.model,
|
|
27
31
|
},
|
|
28
32
|
opts
|
|
29
33
|
);
|
|
@@ -32,7 +36,11 @@ const getEmbedding = async (config, opts) => {
|
|
|
32
36
|
return await getEmbeddingOpenAICompatible(
|
|
33
37
|
{
|
|
34
38
|
embeddingsEndpoint: config.embed_endpoint,
|
|
35
|
-
embed_model:
|
|
39
|
+
embed_model:
|
|
40
|
+
opts?.embed_model ||
|
|
41
|
+
opts?.model ||
|
|
42
|
+
config.embed_model ||
|
|
43
|
+
config.model,
|
|
36
44
|
},
|
|
37
45
|
opts
|
|
38
46
|
);
|
|
@@ -59,17 +67,17 @@ const getCompletion = async (config, opts) => {
|
|
|
59
67
|
return await getCompletionOpenAICompatible(
|
|
60
68
|
{
|
|
61
69
|
chatCompleteEndpoint: "https://api.openai.com/v1/chat/completions",
|
|
62
|
-
bearer: config.api_key,
|
|
63
|
-
model: config.model,
|
|
70
|
+
bearer: opts?.api_key || opts?.bearer || config.api_key,
|
|
71
|
+
model: opts?.model || config.model,
|
|
64
72
|
},
|
|
65
73
|
opts
|
|
66
74
|
);
|
|
67
75
|
case "OpenAI-compatible API":
|
|
68
76
|
return await getCompletionOpenAICompatible(
|
|
69
77
|
{
|
|
70
|
-
chatCompleteEndpoint: config.endpoint,
|
|
71
|
-
bearer: config.bearer,
|
|
72
|
-
model: config.model,
|
|
78
|
+
chatCompleteEndpoint: opts?.endpoint || config.endpoint,
|
|
79
|
+
bearer: opts?.bearer || opts?.api_key || config.bearer,
|
|
80
|
+
model: opts?.model || config.model,
|
|
73
81
|
},
|
|
74
82
|
opts
|
|
75
83
|
);
|
|
@@ -80,7 +88,7 @@ const getCompletion = async (config, opts) => {
|
|
|
80
88
|
|
|
81
89
|
const ollama = new Ollama();
|
|
82
90
|
const olres = await ollama.generate({
|
|
83
|
-
model: config.model,
|
|
91
|
+
model: opts?.model || config.model,
|
|
84
92
|
...opts,
|
|
85
93
|
});
|
|
86
94
|
//console.log("the response ", olres);
|