You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fu-hsi-service/src/main/java/com/supervision/chat/client/LangChainChatServiceImpl.java

33 lines
1.1 KiB
Java

9 months ago
package com.supervision.chat.client;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.supervision.chat.client.dto.CreateBaseDTO;
import com.supervision.chat.client.dto.LangChainChatRes;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
public class LangChainChatServiceImpl{
@Value("${langChain-chat.url}")
private String LangChainChatClientUrl;
public LangChainChatRes chat(CreateBaseDTO createBaseDTO) {
String post = HttpUtil.post(LangChainChatClientUrl + "create_knowledge_base", JSONUtil.toJsonStr(createBaseDTO));
if (JSONUtil.isTypeJSON(post)) {
return JSONUtil.toBean(post, LangChainChatRes.class);
}
return null;
}
}