1
This commit is contained in:
@@ -775,6 +775,42 @@ public class SocialMediaServiceImpl implements ISocialMediaService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult testLlmProfile(Map<String, Object> request) {
|
||||
try {
|
||||
String url = jarvisBaseUrl + "/jarvis/social-media/llm/test";
|
||||
JSONObject body = new JSONObject();
|
||||
if (request != null) {
|
||||
Object pid = request.get("profileId");
|
||||
if (pid != null && StringUtils.isNotEmpty(StringUtils.trim(pid.toString()))) {
|
||||
body.put("profileId", pid.toString().trim());
|
||||
}
|
||||
Object msg = request.get("message");
|
||||
if (msg != null && StringUtils.isNotEmpty(StringUtils.trim(msg.toString()))) {
|
||||
body.put("message", msg.toString().trim());
|
||||
}
|
||||
}
|
||||
log.info("转发 Jarvis LLM 测试: {}", url);
|
||||
String resp = HttpUtils.sendJsonPost(url, body.toJSONString());
|
||||
if (StringUtils.isEmpty(resp)) {
|
||||
return AjaxResult.error("Jarvis 返回为空,请检查 jarvis.server.jarvis-java.base-url 与 Jarvis 服务是否可达");
|
||||
}
|
||||
Object parsed = JSON.parse(resp);
|
||||
if (parsed instanceof JSONObject) {
|
||||
JSONObject jo = (JSONObject) parsed;
|
||||
if (Integer.valueOf(200).equals(jo.getInteger("code"))) {
|
||||
return AjaxResult.success(jo.get("data"));
|
||||
}
|
||||
String errMsg = jo.getString("msg");
|
||||
return AjaxResult.error(StringUtils.isNotEmpty(errMsg) ? errMsg : "测试失败");
|
||||
}
|
||||
return AjaxResult.error("Jarvis 响应格式错误");
|
||||
} catch (Exception e) {
|
||||
log.error("大模型测试转发失败", e);
|
||||
return AjaxResult.error("测试失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static String maskLlmApiKey(String secret) {
|
||||
if (StringUtils.isEmpty(StringUtils.trim(secret))) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user