@saltcorn/large-language-model 0.3.2 → 0.3.4
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 +9 -2
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -100,7 +100,7 @@ const getCompletion = async (config, opts) => {
|
|
|
100
100
|
|
|
101
101
|
const getCompletionOpenAICompatible = async (
|
|
102
102
|
{ chatCompleteEndpoint, bearer, model },
|
|
103
|
-
{ systemPrompt, prompt, temperature, chat = [] }
|
|
103
|
+
{ systemPrompt, prompt, temperature, chat = [], ...rest }
|
|
104
104
|
) => {
|
|
105
105
|
const headers = {
|
|
106
106
|
"Content-Type": "application/json",
|
|
@@ -119,6 +119,7 @@ const getCompletionOpenAICompatible = async (
|
|
|
119
119
|
{ role: "user", content: prompt },
|
|
120
120
|
],
|
|
121
121
|
temperature: temperature || 0.7,
|
|
122
|
+
...rest,
|
|
122
123
|
};
|
|
123
124
|
const rawResponse = await fetch(chatCompleteEndpoint, {
|
|
124
125
|
method: "POST",
|
|
@@ -126,8 +127,14 @@ const getCompletionOpenAICompatible = async (
|
|
|
126
127
|
body: JSON.stringify(body),
|
|
127
128
|
});
|
|
128
129
|
const results = await rawResponse.json();
|
|
130
|
+
//console.log(JSON.stringify(results, null, 2));
|
|
129
131
|
|
|
130
|
-
return
|
|
132
|
+
return (
|
|
133
|
+
results?.choices?.[0]?.message?.content ||
|
|
134
|
+
(results?.choices?.[0]?.message?.tool_calls
|
|
135
|
+
? { tool_calls: results?.choices?.[0]?.message?.tool_calls }
|
|
136
|
+
: null)
|
|
137
|
+
);
|
|
131
138
|
};
|
|
132
139
|
|
|
133
140
|
const getEmbeddingOpenAICompatible = async (config, { prompt, model }) => {
|