Autowire WebClient.Builder into OllamaApi
This commit is contained in:
committed by
Mark Pollack
parent
bf8dabfb11
commit
3cab5bd009
@@ -100,7 +100,7 @@ public class 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 class OllamaApi {
|
||||
* @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 class OllamaApi {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
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 class OllamaAutoConfiguration {
|
||||
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user