@saltcorn/large-language-model 0.7.8 → 0.7.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 +9 -1
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -171,7 +171,7 @@ const getCompletionOpenAICompatible = async (
|
|
|
171
171
|
content: systemPrompt || "You are a helpful assistant.",
|
|
172
172
|
},
|
|
173
173
|
...chat,
|
|
174
|
-
{ role: "user", content: prompt },
|
|
174
|
+
...(prompt ? [{ role: "user", content: prompt }] : []),
|
|
175
175
|
],
|
|
176
176
|
temperature: temperature || 0.7,
|
|
177
177
|
...rest,
|
|
@@ -185,6 +185,13 @@ const getCompletionOpenAICompatible = async (
|
|
|
185
185
|
"headers",
|
|
186
186
|
JSON.stringify(headers)
|
|
187
187
|
);
|
|
188
|
+
else
|
|
189
|
+
getState().log(
|
|
190
|
+
6,
|
|
191
|
+
`OpenAI request ${JSON.stringify(
|
|
192
|
+
body
|
|
193
|
+
)} to ${chatCompleteEndpoint} headers ${JSON.stringify(headers)}`
|
|
194
|
+
);
|
|
188
195
|
const rawResponse = await fetch(chatCompleteEndpoint, {
|
|
189
196
|
method: "POST",
|
|
190
197
|
headers,
|
|
@@ -193,6 +200,7 @@ const getCompletionOpenAICompatible = async (
|
|
|
193
200
|
const results = await rawResponse.json();
|
|
194
201
|
if (debugResult)
|
|
195
202
|
console.log("OpenAI response", JSON.stringify(results, null, 2));
|
|
203
|
+
else getState().log(6, `OpenAI response ${JSON.stringify(results)}`);
|
|
196
204
|
if (results.error) throw new Error(`OpenAI error: ${results.error.message}`);
|
|
197
205
|
|
|
198
206
|
return results?.choices?.[0]?.message?.tool_calls
|