fix(gateway): resolve ClassCastException when parsing tools list in ChatController
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 6m37s
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 6m37s
This commit is contained in:
@@ -61,12 +61,18 @@ public class ChatController {
|
||||
if (toolsResponse != null && toolsResponse.getResult() instanceof Map) {
|
||||
Map<String, Object> resultMap = (Map<String, Object>) toolsResponse.getResult();
|
||||
if (resultMap.containsKey("tools")) {
|
||||
List<ToolMetadata> allTools = (List<ToolMetadata>) resultMap.get("tools");
|
||||
List<Map<String, Object>> allTools = (List<Map<String, Object>>) resultMap.get("tools");
|
||||
Set<String> addedToolNames = new HashSet<>();
|
||||
for (ToolMetadata meta : allTools) {
|
||||
if (Boolean.TRUE.equals(meta.getVisible()) && meta.getName() != null) {
|
||||
String cleanName = meta.getName().replaceAll("[^a-zA-Z0-9_-]", "_");
|
||||
for (Map<String, Object> metaMap : allTools) {
|
||||
String name = (String) metaMap.get("name");
|
||||
if (name != null) {
|
||||
String cleanName = name.replaceAll("[^a-zA-Z0-9_-]", "_");
|
||||
if (!addedToolNames.contains(cleanName)) {
|
||||
ToolMetadata meta = ToolMetadata.builder()
|
||||
.name(name)
|
||||
.description((String) metaMap.get("description"))
|
||||
.parametersSchema((Map<String, Object>) metaMap.get("inputSchema"))
|
||||
.build();
|
||||
callbacks.add(new DynamicMcpToolCallback(meta, executeService, objectMapper, effectiveTenantId));
|
||||
addedToolNames.add(cleanName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user