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; } }