test(config): 新增模型配置字段并重构测试语言解析
refactor(service): 抽取动态模型配置与聊天选项构造 feat(config): 支持运行时切换 LLM 模型
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.yolo.keyborad;
|
||||
|
||||
import com.apple.itunes.storekit.signature.JWSSignatureCreator;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/*
|
||||
@@ -14,19 +16,43 @@ import java.util.UUID;
|
||||
*/
|
||||
public class test {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
String jwt = AppStoreJWT.generateJWT();
|
||||
// try {
|
||||
// String jwt = AppStoreJWT.generateJWT();
|
||||
//
|
||||
// URL url = new URL("https://api.storekit.itunes.apple.com/inApps/v1/subscriptions"); // 你需要访问的 Apple API URL
|
||||
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// connection.setRequestMethod("GET");
|
||||
// connection.setRequestProperty("Authorization", "Bearer " + jwt); // 设置 JWT 为 Bearer Token
|
||||
//
|
||||
// // 处理响应
|
||||
// int responseCode = connection.getResponseCode();
|
||||
// System.out.println("Response Code: " + responseCode);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
System.out.println(resolveLanguage("zh-Hant-Bopomofo"));
|
||||
}
|
||||
|
||||
URL url = new URL("https://api.storekit.itunes.apple.com/inApps/v1/subscriptions"); // 你需要访问的 Apple API URL
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + jwt); // 设置 JWT 为 Bearer Token
|
||||
|
||||
// 处理响应
|
||||
int responseCode = connection.getResponseCode();
|
||||
System.out.println("Response Code: " + responseCode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public static String resolveLanguage(String acceptLanguage) {
|
||||
if (!StringUtils.hasText(acceptLanguage)) {
|
||||
return defaultLanguage();
|
||||
}
|
||||
|
||||
String preferredLanguage = acceptLanguage.split(",")[0].split(";")[0].trim();
|
||||
if (!StringUtils.hasText(preferredLanguage)) {
|
||||
return defaultLanguage();
|
||||
}
|
||||
|
||||
String normalizedTag = preferredLanguage.replace('_', '-');
|
||||
Locale locale = Locale.forLanguageTag(normalizedTag);
|
||||
String resolvedTag = locale.toLanguageTag();
|
||||
if (!StringUtils.hasText(resolvedTag) || "und".equalsIgnoreCase(resolvedTag)) {
|
||||
return normalizedTag;
|
||||
}
|
||||
return resolvedTag;
|
||||
}
|
||||
|
||||
private static String defaultLanguage() {
|
||||
return Locale.getDefault().getLanguage().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user