dev_该合并了 #8
@ -60,10 +60,12 @@ public class BaiduGPTManager {
|
|||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("messages", messages);
|
json.put("messages", messages);
|
||||||
System.out.println("json = " + json);
|
System.out.println("json = " + json);
|
||||||
String post = HttpTools.post(url + "?access_token=" + getToken()
|
HashMap<String, String> header = new HashMap<>();
|
||||||
, json.toJSONString().getBytes(StandardCharsets.UTF_8));
|
header.put("Content-Type", "application/json");
|
||||||
|
String post = HttpTools.http_post(url + "?access_token=" + getToken()
|
||||||
|
, json.toJSONString().getBytes(StandardCharsets.UTF_8), 5, header);
|
||||||
System.out.println("post = " + post);
|
System.out.println("post = " + post);
|
||||||
if(StringUtils.isEmpty(post)){
|
if (StringUtils.isEmpty(post)) {
|
||||||
clear();
|
clear();
|
||||||
return sendMessage(user, message);
|
return sendMessage(user, message);
|
||||||
}
|
}
|
||||||
@ -75,12 +77,8 @@ public class BaiduGPTManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
BaiduGPTManager.getManager().sendMessage("test", "定义个变量西瓜,它的值是5");
|
ResponseMessage message = BaiduGPTManager.getManager().sendMessage("test", "2023年创业什么赚钱?");
|
||||||
Thread.sleep(1000);
|
System.out.println(message.getResult());
|
||||||
BaiduGPTManager.getManager().sendMessage("test", "西瓜的值的多少");
|
|
||||||
Thread.sleep(1000);
|
|
||||||
BaiduGPTManager.getManager().clear();
|
|
||||||
BaiduGPTManager.getManager().sendMessage("test2", "西瓜的值的多少");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,8 @@ public class HttpTools {
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
connection.setDoInput(true);
|
connection.setDoInput(true);
|
||||||
connection.addRequestProperty("User-Agent", getExtUa());
|
connection.addRequestProperty("User-Agent", getExtUa());
|
||||||
connection.setConnectTimeout(5 * 1000);
|
// connection.setConnectTimeout(5 * 1000);
|
||||||
connection.setReadTimeout(10 * 1000);
|
// connection.setReadTimeout(10 * 1000);
|
||||||
//connection.addRequestProperty("Connection", "keep-alive");
|
//connection.addRequestProperty("Connection", "keep-alive");
|
||||||
//connection.addRequestProperty("User-Agent", getExtUa());
|
//connection.addRequestProperty("User-Agent", getExtUa());
|
||||||
//connection.addRequestProperty("content-type", "application/json");
|
//connection.addRequestProperty("content-type", "application/json");
|
||||||
|
Loading…
Reference in New Issue
Block a user