dev_该合并了 #8

Merged
yutou merged 83 commits from dev_ into master 2024-01-17 17:23:44 +08:00
2 changed files with 26 additions and 21 deletions
Showing only changes of commit 126f25af81 - Show all commits

View File

@ -60,8 +60,12 @@ public class BaiduGPTManager {
JSONObject json = new JSONObject();
json.put("messages", messages);
System.out.println("json = " + json);
String post = HttpTools.post(url + "?access_token=" + getToken()
, json.toJSONString().getBytes(StandardCharsets.UTF_8));
Map<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
map.put("Content-Length", String.valueOf(json.toJSONString().getBytes(StandardCharsets.UTF_8).length));
String post = HttpTools.http_post(url + "?access_token=" + getToken()
, json.toJSONString().getBytes(StandardCharsets.UTF_8),0,map);
System.out.println("post = " + post);
if (StringUtils.isEmpty(post)) {
clear();

View File

@ -119,10 +119,10 @@ public class HttpTools {
reader.close();
return finalStr;
} catch (Exception e) {
e.printStackTrace();
if (index < HttpRequestIndex) {
return http_post(url, body, index + 1, headers);
} else {
e.printStackTrace();
return null;
}
}
@ -153,6 +153,7 @@ public class HttpTools {
string = new StringBuilder(string.substring(1, string.length()).replaceAll(" ", ""));
return string.toString();
}
public static String toUrlParams(Map<String, String> map) {
StringBuilder builder = new StringBuilder();
for (String key : map.keySet()) {