@saltcorn/large-language-model 0.4.9 → 0.5.0
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 +6 -2
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -23,6 +23,7 @@ const getEmbedding = async (config, opts) => {
|
|
|
23
23
|
{
|
|
24
24
|
embeddingsEndpoint: opts?.endpoint || config.embed_endpoint,
|
|
25
25
|
bearer: opts?.bearer || opts?.api_key || config.api_key,
|
|
26
|
+
apiKey: opts?.api_key || config.api_key,
|
|
26
27
|
embed_model:
|
|
27
28
|
opts?.embed_model ||
|
|
28
29
|
opts?.model ||
|
|
@@ -77,6 +78,7 @@ const getCompletion = async (config, opts) => {
|
|
|
77
78
|
{
|
|
78
79
|
chatCompleteEndpoint: opts?.endpoint || config.endpoint,
|
|
79
80
|
bearer: opts?.bearer || opts?.api_key || config.bearer,
|
|
81
|
+
apiKey: opts?.api_key || config.api_key,
|
|
80
82
|
model: opts?.model || config.model,
|
|
81
83
|
},
|
|
82
84
|
opts
|
|
@@ -117,7 +119,7 @@ const getCompletion = async (config, opts) => {
|
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
const getCompletionOpenAICompatible = async (
|
|
120
|
-
{ chatCompleteEndpoint, bearer, model },
|
|
122
|
+
{ chatCompleteEndpoint, bearer, apiKey, model },
|
|
121
123
|
{ systemPrompt, prompt, temperature, debugResult, chat = [], ...rest }
|
|
122
124
|
) => {
|
|
123
125
|
const headers = {
|
|
@@ -125,6 +127,7 @@ const getCompletionOpenAICompatible = async (
|
|
|
125
127
|
Accept: "application/json",
|
|
126
128
|
};
|
|
127
129
|
if (bearer) headers.Authorization = "Bearer " + bearer;
|
|
130
|
+
if (apiKey) headers["api-key"] = apiKey;
|
|
128
131
|
const body = {
|
|
129
132
|
//prompt: "How are you?",
|
|
130
133
|
model: rest.model || model,
|
|
@@ -162,12 +165,13 @@ const getEmbeddingOpenAICompatible = async (
|
|
|
162
165
|
config,
|
|
163
166
|
{ prompt, model, debugResult }
|
|
164
167
|
) => {
|
|
165
|
-
const { embeddingsEndpoint, bearer, embed_model } = config;
|
|
168
|
+
const { embeddingsEndpoint, bearer, apiKey, embed_model } = config;
|
|
166
169
|
const headers = {
|
|
167
170
|
"Content-Type": "application/json",
|
|
168
171
|
Accept: "application/json",
|
|
169
172
|
};
|
|
170
173
|
if (bearer) headers.Authorization = "Bearer " + bearer;
|
|
174
|
+
if (apiKey) headers["api-key"] = apiKey;
|
|
171
175
|
const body = {
|
|
172
176
|
//prompt: "How are you?",
|
|
173
177
|
model: model || embed_model || "text-embedding-3-small",
|