|
5 | 5 | package com.oracle.bmc.adk.agent; |
6 | 6 |
|
7 | 7 | import com.fasterxml.jackson.core.JsonProcessingException; |
8 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
9 | 8 | import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; |
10 | 9 | import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; |
11 | 10 | import com.google.gson.Gson; |
|
18 | 17 | import com.oracle.bmc.adk.tools.prebuilt.AgenticRagTool; |
19 | 18 | import com.oracle.bmc.adk.utils.Console; |
20 | 19 | import com.oracle.bmc.adk.utils.Constants; |
| 20 | +import com.oracle.bmc.adk.utils.JsonUtils; |
21 | 21 | import com.oracle.bmc.generativeaiagent.model.AgentEndpoint; |
22 | 22 | import com.oracle.bmc.generativeaiagent.model.Function; |
23 | 23 | import com.oracle.bmc.generativeaiagent.model.FunctionCallingToolConfig; |
@@ -62,8 +62,6 @@ public class Agent { |
62 | 62 | private final List<FunctionTool> localFunctionTools; |
63 | 63 | private final AgenticRagTool localRagTool; |
64 | 64 |
|
65 | | - private static final ObjectMapper objectMapper = new ObjectMapper(); |
66 | | - |
67 | 65 | /** |
68 | 66 | * Constructor to initialize Agent with basic parameters only. Internal fields (like handler |
69 | 67 | * functions, rag tools, and endpoint) are not initialized. |
@@ -946,7 +944,7 @@ private FunctionCallingPerformedAction executeFunctionCall( |
946 | 944 | String functionArgsObj = functionCall.getArguments(); |
947 | 945 |
|
948 | 946 | Map<String, Object> functionArgs = |
949 | | - objectMapper.readValue((String) functionArgsObj, Map.class); |
| 947 | + JsonUtils.OBJECT_MAPPER.readValue((String) functionArgsObj, Map.class); |
950 | 948 |
|
951 | 949 | // Find the appropriate function handler |
952 | 950 | FunctionTool handler = null; |
@@ -975,7 +973,7 @@ private FunctionCallingPerformedAction executeFunctionCall( |
975 | 973 | // Return the performed action details |
976 | 974 | return FunctionCallingPerformedAction.builder() |
977 | 975 | .actionId(action.getActionId()) |
978 | | - .functionCallOutput(objectMapper.writeValueAsString(result)) |
| 976 | + .functionCallOutput(JsonUtils.OBJECT_MAPPER.writeValueAsString(result)) |
979 | 977 | .build(); |
980 | 978 |
|
981 | 979 | } catch (JsonProcessingException e) { |
@@ -1056,7 +1054,7 @@ private Map<String, Object> responseToMap(ChatResponse response) { |
1056 | 1054 | SimpleFilterProvider filterProvider = new SimpleFilterProvider(); |
1057 | 1055 | filterProvider.addFilter("explicitlySetFilter", SimpleBeanPropertyFilter.serializeAll()); |
1058 | 1056 |
|
1059 | | - objectMapper.setFilterProvider(filterProvider); |
1060 | | - return objectMapper.convertValue(response, Map.class); |
| 1057 | + JsonUtils.OBJECT_MAPPER.setFilterProvider(filterProvider); |
| 1058 | + return JsonUtils.OBJECT_MAPPER.convertValue(response, Map.class); |
1061 | 1059 | } |
1062 | 1060 | } |
0 commit comments