Merge remote-tracking branch 'origin/dev_1.0.0' into dev_1.0.0

topo_dev
xueqingkun 9 months ago
commit 3a7054ad0b

@ -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);

@ -10,10 +10,8 @@ import org.springframework.web.service.annotation.PostExchange;
public interface LangChainChatService {
@PostExchange(url = "create_knowledge_base", contentType = "application/json")
void chat(@RequestBody CreateBaseDTO createBaseDTO);
LangChainChatRes chat(@RequestBody CreateBaseDTO createBaseDTO);
@PostExchange(url = "chat/test/testPost", contentType = "application/json")
LangChainChatRes test(@RequestBody CreateBaseDTO createBaseDTO);
}

@ -23,12 +23,8 @@ public class TestController {
public void test(){
CreateBaseDTO createBaseDTO = new CreateBaseDTO();
createBaseDTO.setKnowledge_base_name("11111111");
langChainChatClient.chat(createBaseDTO);
// log.info(JSONUtil.toJsonStr(chat));
LangChainChatRes chat = langChainChatClient.chat(createBaseDTO);
log.info(JSONUtil.toJsonStr(chat));
}
@PostMapping("testPost")
public void testPost(@RequestBody CreateBaseDTO createBaseDTO){
System.out.println(JSONUtil.toJsonStr(createBaseDTO));
}
}

Loading…
Cancel
Save