This commit is contained in:
zhouwentao 2025-03-01 15:15:18 +08:00
parent 002d15fa3d
commit 80776bcd13
1 changed files with 36 additions and 26 deletions

View File

@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.RestUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.Scanner;
/**
* @Description
@ -20,34 +21,43 @@ public class IpKit {
private final static String UNKNOWN = "unknown";
public static void main(String[] args) {
String url = "http://ai.izcsz.com/api/v1/chat/completions";
String authorization = "Bearer fastgpt-MBOxnysyhuzMMuLijtq1qYQa6dwIo6AsB0lR5L2r5ommMhBrRd0g9OKNwx4E6";
String contentType = "application/json";
// String url = "http://ai.izcsz.com/api/v1/chat/completions";
// String authorization = "Bearer fastgpt-MBOxnysyhuzMMuLijtq1qYQa6dwIo6AsB0lR5L2r5ommMhBrRd0g9OKNwx4E6";
// String contentType = "application/json";
//
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("chatId", "abcd");
// jsonObject.put("stream", false);
// jsonObject.put("detail", false);
// JSONObject variables = new JSONObject();
// variables.put("nick", "亮亮");
// jsonObject.put("variables", variables);
//
// // 创建一个 JSONArray 来包含消息对象
// JSONArray messagesArray = new JSONArray();
// JSONObject messageObject = new JSONObject();
// messageObject.put("content", "坦克700北京多少钱能买");
// messageObject.put("role", "user");
// // 将消息对象添加到数组中
// messagesArray.add(messageObject);
//
// // 将数组赋值给 "messages" 字段
// jsonObject.put("messages", messagesArray);
//
// JSONObject headerJson = new JSONObject();
// headerJson.put("Authorization", authorization);
// headerJson.put("Content-Type", contentType);
// JSONObject post = RestUtil.post(url, null, jsonObject,headerJson);
// System.out.println(post);
JSONObject jsonObject = new JSONObject();
jsonObject.put("chatId", "abcd");
jsonObject.put("stream", false);
jsonObject.put("detail", false);
JSONObject variables = new JSONObject();
variables.put("nick", "亮亮");
jsonObject.put("variables", variables);
// 创建一个 JSONArray 来包含消息对象
JSONArray messagesArray = new JSONArray();
JSONObject messageObject = new JSONObject();
messageObject.put("content", "坦克700北京多少钱能买");
messageObject.put("role", "user");
// 将消息对象添加到数组中
messagesArray.add(messageObject);
// 将数组赋值给 "messages" 字段
jsonObject.put("messages", messagesArray);
JSONObject headerJson = new JSONObject();
headerJson.put("Authorization", authorization);
headerJson.put("Content-Type", contentType);
JSONObject post = RestUtil.post(url, null, jsonObject,headerJson);
System.out.println(post);
Scanner scan = new Scanner(System.in);
//在此输入您的代码...
String[] strs= scan.next().split(""); // 直接输入后转为字符串数组
for(int i=strs.length-1;i>0;i++){
System.out.print(strs[i]);
}
scan.close();
}
public static String getRealIp(HttpServletRequest request) {