@@ -167,21 +167,25 @@ EOF
167167cat << 'EOF ' > ~/environment/aiagent/src/main/java/com/example/agent/WeatherTools.java
168168package com.example.agent;
169169
170+ import java.net.http.HttpClient;
170171import java.util.List;
171172import java.util.Map;
172173import org.slf4j.Logger;
173174import org.slf4j.LoggerFactory;
174175import org.springframework.ai.tool.annotation.Tool;
175176import org.springframework.ai.tool.annotation.ToolParam;
176177import org.springframework.core.ParameterizedTypeReference;
178+ import org.springframework.http.client.JdkClientHttpRequestFactory;
177179import org.springframework.web.client.RestClient;
178180
179181class WeatherTools {
180182
181183 private static final Logger log = LoggerFactory.getLogger(WeatherTools.class);
182184 private static final ParameterizedTypeReference<Map<String, Object>> MAP_TYPE =
183185 new ParameterizedTypeReference<>() {};
184- private final RestClient restClient = RestClient.create();
186+ private final RestClient restClient = RestClient.builder()
187+ .requestFactory(new JdkClientHttpRequestFactory(HttpClient.newHttpClient()))
188+ .build();
185189
186190 @Tool(description = """
187191 Get weather forecast for a city on a specific date.
343347cat << 'EOF ' > ~/environment/aiagent/src/main/java/com/example/agent/InvocationController.java
344348package com.example.agent;
345349
346- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
347350import org.springframework.http.MediaType;
348351import org.springframework.security.core.annotation.AuthenticationPrincipal;
349352import org.springframework.security.oauth2.jwt.Jwt;
@@ -352,7 +355,6 @@ import reactor.core.publisher.Flux;
352355
353356@RestController
354357@CrossOrigin(origins = "*")
355- @ConditionalOnProperty(name = "app.controller.enabled", havingValue = "true", matchIfMissing = true)
356358public class InvocationController {
357359 private final ChatService chatService;
358360
0 commit comments