diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java index 9da600a589..565c44e1d7 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java @@ -100,7 +100,7 @@ public OllamaApi() { * @param baseUrl The base url of the Ollama server. */ public OllamaApi(String baseUrl) { - this(baseUrl, RestClient.builder()); + this(baseUrl, RestClient.builder(), WebClient.builder()); } /** @@ -109,7 +109,7 @@ public OllamaApi(String baseUrl) { * @param baseUrl The base url of the Ollama server. * @param restClientBuilder The {@link RestClient.Builder} to use. */ - public OllamaApi(String baseUrl, RestClient.Builder restClientBuilder) { + public OllamaApi(String baseUrl, RestClient.Builder restClientBuilder, WebClient.Builder webClientBuilder) { this.responseErrorHandler = new OllamaResponseErrorHandler(); @@ -120,7 +120,7 @@ public OllamaApi(String baseUrl, RestClient.Builder restClientBuilder) { this.restClient = restClientBuilder.baseUrl(baseUrl).defaultHeaders(defaultHeaders).build(); - this.webClient = WebClient.builder().baseUrl(baseUrl).defaultHeaders(defaultHeaders).build(); + this.webClient = webClientBuilder.baseUrl(baseUrl).defaultHeaders(defaultHeaders).build(); } // -------------------------------------------------------------------------- diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java index 639950a740..106f04c3e5 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java @@ -37,6 +37,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestClient; +import org.springframework.web.reactive.function.client.WebClient; /** * {@link AutoConfiguration Auto-configuration} for Ollama Chat Client. @@ -61,8 +62,9 @@ public PropertiesOllamaConnectionDetails ollamaConnectionDetails(OllamaConnectio @Bean @ConditionalOnMissingBean - public OllamaApi ollamaApi(OllamaConnectionDetails connectionDetails, RestClient.Builder restClientBuilder) { - return new OllamaApi(connectionDetails.getBaseUrl(), restClientBuilder); + public OllamaApi ollamaApi(OllamaConnectionDetails connectionDetails, RestClient.Builder restClientBuilder, + WebClient.Builder webClientBuilder) { + return new OllamaApi(connectionDetails.getBaseUrl(), restClientBuilder, webClientBuilder); } @Bean