@saltcorn/large-language-model 0.8.0 → 0.8.2
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 +18 -1
- package/package.json +1 -1
package/generate.js
CHANGED
|
@@ -200,6 +200,12 @@ const getCompletionOpenAICompatible = async (
|
|
|
200
200
|
filename: undefined,
|
|
201
201
|
});
|
|
202
202
|
});
|
|
203
|
+
} else if (c.content?.mcp_calls) {
|
|
204
|
+
c.content.mcp_calls.forEach((ic) => {
|
|
205
|
+
newChat.push({
|
|
206
|
+
...ic,
|
|
207
|
+
});
|
|
208
|
+
});
|
|
203
209
|
} else if (c.role === "tool") {
|
|
204
210
|
newChat.push({
|
|
205
211
|
type: "function_call_output",
|
|
@@ -232,6 +238,8 @@ const getCompletionOpenAICompatible = async (
|
|
|
232
238
|
...(prompt ? [{ role: "user", content: prompt }] : []),
|
|
233
239
|
];
|
|
234
240
|
} else {
|
|
241
|
+
// not response api
|
|
242
|
+
if (body.tools) body.tools = body.tools.filter((t) => t.function);
|
|
235
243
|
body.messages = [
|
|
236
244
|
{
|
|
237
245
|
role: "system",
|
|
@@ -274,7 +282,11 @@ const getCompletionOpenAICompatible = async (
|
|
|
274
282
|
.map((o) => o.content.map((c) => c.text).join(""))
|
|
275
283
|
.join("");
|
|
276
284
|
return results.output.some(
|
|
277
|
-
(o) =>
|
|
285
|
+
(o) =>
|
|
286
|
+
o.type === "function_call" ||
|
|
287
|
+
o.type === "image_generation_call" ||
|
|
288
|
+
o.type === "mcp_list_tools" ||
|
|
289
|
+
o.type === "mcp_call"
|
|
278
290
|
)
|
|
279
291
|
? {
|
|
280
292
|
tool_calls: emptyToUndefined(
|
|
@@ -288,6 +300,11 @@ const getCompletionOpenAICompatible = async (
|
|
|
288
300
|
image_calls: emptyToUndefined(
|
|
289
301
|
results.output.filter((o) => o.type === "image_generation_call")
|
|
290
302
|
),
|
|
303
|
+
mcp_calls: emptyToUndefined(
|
|
304
|
+
results.output.filter(
|
|
305
|
+
(o) => o.type === "mcp_call" || o.type === "mcp_list_tools"
|
|
306
|
+
)
|
|
307
|
+
),
|
|
291
308
|
content: textOutput || null,
|
|
292
309
|
}
|
|
293
310
|
: textOutput || null;
|