ai-protocol-adapters 1.0.0-alpha.7 → 1.0.0-alpha.8
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/index.js +22 -1
- package/dist/index.mjs +22 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1051,7 +1051,24 @@ var MessageConverter = class {
|
|
|
1051
1051
|
console.debug("[MessageConverter] Final converted messages count:", convertedMessages.length);
|
|
1052
1052
|
console.debug("[MessageConverter] First message:", JSON.stringify(convertedMessages[0], null, 2));
|
|
1053
1053
|
}
|
|
1054
|
-
return convertedMessages
|
|
1054
|
+
return convertedMessages.map((msg) => {
|
|
1055
|
+
if (Array.isArray(msg.tools)) {
|
|
1056
|
+
msg.tools = msg.tools.map((tool) => {
|
|
1057
|
+
if (tool?.type === "function" && tool.function) {
|
|
1058
|
+
const description = tool.function.description?.trim() || "Converted tool with no description provided.";
|
|
1059
|
+
return {
|
|
1060
|
+
...tool,
|
|
1061
|
+
function: {
|
|
1062
|
+
...tool.function,
|
|
1063
|
+
description
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
return tool;
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
return msg;
|
|
1071
|
+
});
|
|
1055
1072
|
}
|
|
1056
1073
|
/**
|
|
1057
1074
|
* 创建消息转换上下文
|
|
@@ -4373,6 +4390,8 @@ var ToolCallProcessor = class _ToolCallProcessor {
|
|
|
4373
4390
|
console.debug("[ToolProcessor] Processing tool args, calling processToolArgs");
|
|
4374
4391
|
}
|
|
4375
4392
|
_ToolCallProcessor.processToolArgs(toolId, toolArgs, state, sseLines);
|
|
4393
|
+
} else if (toolName && toolId) {
|
|
4394
|
+
_ToolCallProcessor.processToolArgs(toolId, "", state, sseLines);
|
|
4376
4395
|
} else {
|
|
4377
4396
|
console.warn("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F [ToolProcessor] No tool args to process! This will result in empty input!");
|
|
4378
4397
|
}
|
|
@@ -4408,6 +4427,8 @@ var ToolCallProcessor = class _ToolCallProcessor {
|
|
|
4408
4427
|
console.debug("[ToolProcessor] Processing batch tool args, calling processToolArgs");
|
|
4409
4428
|
}
|
|
4410
4429
|
_ToolCallProcessor.processToolArgs(toolId, toolArgs, state, sseLines);
|
|
4430
|
+
} else if (toolName && toolId) {
|
|
4431
|
+
_ToolCallProcessor.processToolArgs(toolId, "", state, sseLines);
|
|
4411
4432
|
} else {
|
|
4412
4433
|
console.warn("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F [ToolProcessor] No batch tool args to process! This will result in empty input!");
|
|
4413
4434
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -944,7 +944,24 @@ var MessageConverter = class {
|
|
|
944
944
|
console.debug("[MessageConverter] Final converted messages count:", convertedMessages.length);
|
|
945
945
|
console.debug("[MessageConverter] First message:", JSON.stringify(convertedMessages[0], null, 2));
|
|
946
946
|
}
|
|
947
|
-
return convertedMessages
|
|
947
|
+
return convertedMessages.map((msg) => {
|
|
948
|
+
if (Array.isArray(msg.tools)) {
|
|
949
|
+
msg.tools = msg.tools.map((tool) => {
|
|
950
|
+
if (tool?.type === "function" && tool.function) {
|
|
951
|
+
const description = tool.function.description?.trim() || "Converted tool with no description provided.";
|
|
952
|
+
return {
|
|
953
|
+
...tool,
|
|
954
|
+
function: {
|
|
955
|
+
...tool.function,
|
|
956
|
+
description
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
return tool;
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
return msg;
|
|
964
|
+
});
|
|
948
965
|
}
|
|
949
966
|
/**
|
|
950
967
|
* 创建消息转换上下文
|
|
@@ -4266,6 +4283,8 @@ var ToolCallProcessor = class _ToolCallProcessor {
|
|
|
4266
4283
|
console.debug("[ToolProcessor] Processing tool args, calling processToolArgs");
|
|
4267
4284
|
}
|
|
4268
4285
|
_ToolCallProcessor.processToolArgs(toolId, toolArgs, state, sseLines);
|
|
4286
|
+
} else if (toolName && toolId) {
|
|
4287
|
+
_ToolCallProcessor.processToolArgs(toolId, "", state, sseLines);
|
|
4269
4288
|
} else {
|
|
4270
4289
|
console.warn("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F [ToolProcessor] No tool args to process! This will result in empty input!");
|
|
4271
4290
|
}
|
|
@@ -4301,6 +4320,8 @@ var ToolCallProcessor = class _ToolCallProcessor {
|
|
|
4301
4320
|
console.debug("[ToolProcessor] Processing batch tool args, calling processToolArgs");
|
|
4302
4321
|
}
|
|
4303
4322
|
_ToolCallProcessor.processToolArgs(toolId, toolArgs, state, sseLines);
|
|
4323
|
+
} else if (toolName && toolId) {
|
|
4324
|
+
_ToolCallProcessor.processToolArgs(toolId, "", state, sseLines);
|
|
4304
4325
|
} else {
|
|
4305
4326
|
console.warn("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F [ToolProcessor] No batch tool args to process! This will result in empty input!");
|
|
4306
4327
|
}
|
package/package.json
CHANGED