main
黄海 7 months ago
parent 8c4d7c8c79
commit 8df09577b9

@ -0,0 +1,44 @@
package UnitTest;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public class TestMaxKB {
public static void main(String[] args) {
String apiKey = "application-490cc01132c6f752e37d1570f562aa6c";
String applicationId = "999bf92e-c659-11ef-9f22-0242ac120003";
//根据应用id,获取会话id
String url = "http://10.10.14.206:8080/api/application/" + applicationId + "/chat/open";
String result = HttpRequest.get(url)
.header("Authorization", apiKey)
.header("Content-Type", "application/json")
.execute()
.body();
String chat_id = JSONObject.parseObject(result).getString("data");
System.out.println(chat_id);
//对话
// url = "http://10.10.14.206:8080/api/application/chat_message/" + chat_id;
// JSONObject jo = new JSONObject();
// jo.put("message", "你好!");
// jo.put("stream", true);
// jo.put("re_chat", false);
// result = HttpRequest.post(url)
// .header("Authorization", apiKey)
// .header("Content-Type", "application/json")
// .body(jo.toString())
// .execute()
// .body();
//
// for (String s : result.split("\n")) {
// JSONObject jsonObject= JSONObject.parseObject(s);
// System.out.println(jsonObject.getString("data"));
// }
}
}
Loading…
Cancel
Save