Skip to content

Commit ae969e0

Browse files
committed
rolled in review comments
1 parent c2511b8 commit ae969e0

File tree

1 file changed

+1
-13
lines changed
  • javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/scenario

1 file changed

+1
-13
lines changed

javav2/example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/scenario/WeatherTool.java

+1-13
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)