@@ -35,7 +35,6 @@ public class WeatherTool {
3535 * @return The tool specification for the Weather tool.
3636 */
3737 public ToolSpecification getToolSpec () {
38- // Build the JSON schema using JSONObject and JSONArray
3938 Map <String , Document > latitudeMap = new HashMap <>();
4039 latitudeMap .put ("type" , Document .fromString ("string" ));
4140 latitudeMap .put ("description" , Document .fromString ("Geographical WGS84 latitude of the location." ));
@@ -99,24 +98,14 @@ public Document fetchWeatherData(String latitude, String longitude) {
9998 try {
10099 HttpResponse <String > response = httpClient .send (request , HttpResponse .BodyHandlers .ofString ());
101100 if (response .statusCode () == 200 ) {
102- // Convert response body to AWS SDK Document. At this point,
103- // its valid JSON
104101 String weatherJson = response .body ();
105102 System .out .println (weatherJson );
106-
107- // Convert JSON string to a Document
108- //Document weatherDocument = Document.fromString(weatherJson);
109103 ObjectMapper objectMapper = new ObjectMapper ();
110- //Map<String, Object> jsonMap = objectMapper.readValue(weatherJson, Map.class);
111-
112- //
113104 Map <String , Object > rawMap = objectMapper .readValue (weatherJson , new TypeReference <Map <String , Object >>() {});
114105 Map <String , Document > documentMap = convertToDocumentMap (rawMap );
115106
116- // Create a Document object from the Map<String, Document>
117- Document weatherDocument = Document .fromMap (documentMap );
118- // Document weatherDocument = Document.fromMap(jsonMap);
119107
108+ Document weatherDocument = Document .fromMap (documentMap );
120109 System .out .println (weatherDocument );
121110 return weatherDocument ;
122111 } else {
@@ -137,7 +126,6 @@ private static Map<String, Document> convertToDocumentMap(Map<String, Object> in
137126 return result ;
138127 }
139128
140- // Convert different types of Objects to Document
141129 // Convert different types of Objects to Document
142130 private static Document convertToDocument (Object value ) {
143131 if (value instanceof Map ) {
0 commit comments