|
|
|
@ -6,8 +6,11 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.web.client.RestClient;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
import org.springframework.web.client.support.RestClientAdapter;
|
|
|
|
|
import org.springframework.web.client.support.RestTemplateAdapter;
|
|
|
|
|
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
|
|
|
|
|
import org.springframework.web.util.DefaultUriBuilderFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
@ -21,13 +24,16 @@ public class LangChainChatConfig {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public RestClient restClient() {
|
|
|
|
|
return RestClient.builder().baseUrl(LangChainChatClientUrl).build();
|
|
|
|
|
}
|
|
|
|
|
@Bean
|
|
|
|
|
public LangChainChatService langChainChatClient(RestClient restClient) {
|
|
|
|
|
public LangChainChatService langChainChatClient() {
|
|
|
|
|
|
|
|
|
|
// RestClientAdapter adapter = RestClientAdapter.create(restClient);
|
|
|
|
|
// HttpServiceProxyFactory factory = HttpServiceProxyFactory.builderFor(adapter).build();
|
|
|
|
|
//
|
|
|
|
|
// return factory.createClient(LangChainChatService.class);
|
|
|
|
|
|
|
|
|
|
RestClientAdapter adapter = RestClientAdapter.create(restClient);
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(LangChainChatClientUrl));
|
|
|
|
|
RestTemplateAdapter adapter = RestTemplateAdapter.create(restTemplate);
|
|
|
|
|
HttpServiceProxyFactory factory = HttpServiceProxyFactory.builderFor(adapter).build();
|
|
|
|
|
|
|
|
|
|
return factory.createClient(LangChainChatService.class);
|
|
|
|
|