|
|
@@ -37,6 +37,8 @@ public class BaiduChatUtils {
|
|
|
private static final String BAIDU_CHAT_WXYY_URL="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?access_token=";
|
|
|
/*Ernie-Lite地址*/
|
|
|
private static final String BAIDU_CHAT_ERNIE_LITE_URL="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=";
|
|
|
+ /*ERNIE_BOT_4*/
|
|
|
+ private static final String ERNIE_BOT_4="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=";
|
|
|
/*accessToken获取地址*/
|
|
|
private static final String BAIDU_ACCESSTOKEN_URL="https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&";
|
|
|
|
|
|
@@ -45,9 +47,20 @@ public class BaiduChatUtils {
|
|
|
.readTimeout(120000, TimeUnit.MILLISECONDS)
|
|
|
.build();
|
|
|
|
|
|
-
|
|
|
@Async
|
|
|
public void sendBaiduAiStream(InputSendChat inputSendChat) throws IOException {
|
|
|
+ LoggerUtils.debug(getClass(),"ERNIE Bot");
|
|
|
+ sendStream(inputSendChat,BAIDU_CHAT_WXYY_URL);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void sendERNIEBOT4Stream(InputSendChat inputSendChat) throws IOException {
|
|
|
+ LoggerUtils.debug(getClass(),"ERNIE_BOT_4");
|
|
|
+ sendStream(inputSendChat,ERNIE_BOT_4);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void sendStream(InputSendChat inputSendChat,String httpUrl) throws IOException {
|
|
|
SseResult res = SseMap.sseEmitterMap.get(inputSendChat.getUserId());
|
|
|
// if (checkIp()){
|
|
|
// res.sseEmitter.send(new OutChatER(4004,"访问超过最大限制,陌生游客每天最多访问5次"));
|
|
|
@@ -60,7 +73,7 @@ public class BaiduChatUtils {
|
|
|
OutputStream outputStream=null;
|
|
|
try {
|
|
|
|
|
|
- String baidu_url=BAIDU_CHAT_WXYY_URL+getRedisBaiduAccessToken();
|
|
|
+ String baidu_url=httpUrl+getRedisBaiduAccessToken();
|
|
|
URL url = new URL(baidu_url);
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
connection.setRequestMethod("POST");
|