utilitas 1998.2.25 → 1998.2.27
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/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +9 -8
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -556,7 +556,6 @@ const buildGeminiMessage = (content, options) => {
|
|
|
556
556
|
const attachments = (options?.attachments || []).map(x => ({
|
|
557
557
|
inlineData: { mimeType: x.mime_type, data: x.data }
|
|
558
558
|
}));
|
|
559
|
-
|
|
560
559
|
return String.isString(content) ? (options?.history ? {
|
|
561
560
|
role: options?.role || user,
|
|
562
561
|
parts: buildGeminiParts(content, attachments),
|
|
@@ -697,9 +696,9 @@ const handleToolsCall = async (msg, options) => {
|
|
|
697
696
|
let content = [], preRes = [], input, packMsg;
|
|
698
697
|
if (msg?.tool_calls?.length) {
|
|
699
698
|
switch (options?.flavor) {
|
|
700
|
-
case CLAUDE: preRes.push({ role:
|
|
701
|
-
case GEMINI: preRes.push({ role:
|
|
702
|
-
case CHATGPT: default: preRes.push({ role:
|
|
699
|
+
case CLAUDE: preRes.push({ role: assistant, content: msg?.tool_calls }); break;
|
|
700
|
+
case GEMINI: preRes.push({ role: MODEL, parts: msg?.tool_calls.map(x => ({ functionCall: x })) }); break;
|
|
701
|
+
case CHATGPT: default: preRes.push({ role: assistant, ...msg }); break;
|
|
703
702
|
}
|
|
704
703
|
for (const fn of msg.tool_calls) {
|
|
705
704
|
switch (options?.flavor) {
|
|
@@ -725,6 +724,7 @@ const handleToolsCall = async (msg, options) => {
|
|
|
725
724
|
packMsg = (t, e) => ({
|
|
726
725
|
role: 'tool', tool_call_id: fn.id, [e ? 'error' : 'content']: t
|
|
727
726
|
});
|
|
727
|
+
break;
|
|
728
728
|
}
|
|
729
729
|
const name = fn?.function?.name || fn?.name;
|
|
730
730
|
const func = tools.find(x => insensitiveCompare(
|
|
@@ -741,8 +741,8 @@ const handleToolsCall = async (msg, options) => {
|
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
743
|
switch (options?.flavor) {
|
|
744
|
-
case CLAUDE: content = [{ role:
|
|
745
|
-
case GEMINI: content = [{ role:
|
|
744
|
+
case CLAUDE: content = [{ role: user, content }]; break;
|
|
745
|
+
case GEMINI: content = [{ role: user, parts: content }]; break;
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
return [...preRes, ...content];
|
|
@@ -1021,14 +1021,15 @@ const promptGemini = async (content, options) => {
|
|
|
1021
1021
|
history: [
|
|
1022
1022
|
...options?.messages && !options?.attachments?.length ? options.messages : [],
|
|
1023
1023
|
...options?.toolsResult ? [
|
|
1024
|
-
{ role:
|
|
1024
|
+
{ role: user, parts: buildGeminiMessage(content, options) },
|
|
1025
1025
|
options?.toolsResult[0]
|
|
1026
1026
|
] : [],
|
|
1027
1027
|
],
|
|
1028
1028
|
...generationConfig(options),
|
|
1029
1029
|
});
|
|
1030
1030
|
const resp = chat[options?.stream ? 'sendMessageStream' : 'sendMessage'](
|
|
1031
|
-
options?.toolsResult ?
|
|
1031
|
+
options?.toolsResult ?
|
|
1032
|
+
options?.toolsResult[1].parts : buildGeminiMessage(content, options)
|
|
1032
1033
|
);
|
|
1033
1034
|
return await handleGeminiResponse(
|
|
1034
1035
|
resp, { ...options || {}, content, model: genModel }
|
package/lib/manifest.mjs
CHANGED