@@ -35,7 +35,6 @@ public class WeatherTool {
35
35
* @return The tool specification for the Weather tool.
36
36
*/
37
37
public ToolSpecification getToolSpec () {
38
- // Build the JSON schema using JSONObject and JSONArray
39
38
Map <String , Document > latitudeMap = new HashMap <>();
40
39
latitudeMap .put ("type" , Document .fromString ("string" ));
41
40
latitudeMap .put ("description" , Document .fromString ("Geographical WGS84 latitude of the location." ));
@@ -99,24 +98,14 @@ public Document fetchWeatherData(String latitude, String longitude) {
99
98
try {
100
99
HttpResponse <String > response = httpClient .send (request , HttpResponse .BodyHandlers .ofString ());
101
100
if (response .statusCode () == 200 ) {
102
- // Convert response body to AWS SDK Document. At this point,
103
- // its valid JSON
104
101
String weatherJson = response .body ();
105
102
System .out .println (weatherJson );
106
-
107
- // Convert JSON string to a Document
108
- //Document weatherDocument = Document.fromString(weatherJson);
109
103
ObjectMapper objectMapper = new ObjectMapper ();
110
- //Map<String, Object> jsonMap = objectMapper.readValue(weatherJson, Map.class);
111
-
112
- //
113
104
Map <String , Object > rawMap = objectMapper .readValue (weatherJson , new TypeReference <Map <String , Object >>() {});
114
105
Map <String , Document > documentMap = convertToDocumentMap (rawMap );
115
106
116
- // Create a Document object from the Map<String, Document>
117
- Document weatherDocument = Document .fromMap (documentMap );
118
- // Document weatherDocument = Document.fromMap(jsonMap);
119
107
108
+ Document weatherDocument = Document .fromMap (documentMap );
120
109
System .out .println (weatherDocument );
121
110
return weatherDocument ;
122
111
} else {
@@ -137,7 +126,6 @@ private static Map<String, Document> convertToDocumentMap(Map<String, Object> in
137
126
return result ;
138
127
}
139
128
140
- // Convert different types of Objects to Document
141
129
// Convert different types of Objects to Document
142
130
private static Document convertToDocument (Object value ) {
143
131
if (value instanceof Map ) {
0 commit comments