update gpt
This commit is contained in:
parent
c48db62d00
commit
126f25af81
@ -60,8 +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()
|
|
||||||
, 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);
|
System.out.println("post = " + post);
|
||||||
if (StringUtils.isEmpty(post)) {
|
if (StringUtils.isEmpty(post)) {
|
||||||
clear();
|
clear();
|
||||||
|
@ -119,10 +119,10 @@ public class HttpTools {
|
|||||||
reader.close();
|
reader.close();
|
||||||
return finalStr;
|
return finalStr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
if (index < HttpRequestIndex) {
|
if (index < HttpRequestIndex) {
|
||||||
return http_post(url, body, index + 1, headers);
|
return http_post(url, body, index + 1, headers);
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,6 +153,7 @@ public class HttpTools {
|
|||||||
string = new StringBuilder(string.substring(1, string.length()).replaceAll(" ", ""));
|
string = new StringBuilder(string.substring(1, string.length()).replaceAll(" ", ""));
|
||||||
return string.toString();
|
return string.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toUrlParams(Map<String, String> map) {
|
public static String toUrlParams(Map<String, String> map) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (String key : map.keySet()) {
|
for (String key : map.keySet()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user