From 8df09577b9210016f40cb2c8c8eb539a8188708b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Mon, 30 Dec 2024 14:38:00 +0800 Subject: [PATCH] 'commit' --- src/main/java/UnitTest/TestMaxKB.java | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/main/java/UnitTest/TestMaxKB.java diff --git a/src/main/java/UnitTest/TestMaxKB.java b/src/main/java/UnitTest/TestMaxKB.java new file mode 100644 index 00000000..8adbfdb9 --- /dev/null +++ b/src/main/java/UnitTest/TestMaxKB.java @@ -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")); +// } + + } +}