Compare commits
3 Commits
9e0c6d88b1
...
f02de5950e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f02de5950e | ||
|
|
2b9cd6dd2e | ||
|
|
d0d51df465 |
@@ -274,6 +274,21 @@ public class SocialMediaController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大模型连通测试(转发 Jarvis,默认问题 1+1)
|
||||
*/
|
||||
@Log(title = "大模型连通测试", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/llm-config/test")
|
||||
public AjaxResult testLlmProfile(@RequestBody(required = false) Map<String, Object> request)
|
||||
{
|
||||
try {
|
||||
return socialMediaService.testLlmProfile(request);
|
||||
} catch (Exception e) {
|
||||
logger.error("大模型连通测试失败", e);
|
||||
return AjaxResult.error("测试失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 闲鱼文案(手动):根据标题+可选型号生成代下单、教你下单文案,不依赖JD接口
|
||||
*/
|
||||
|
||||
@@ -96,5 +96,8 @@ public interface ISocialMediaService
|
||||
|
||||
/** 清空所有套及旧版单键,Jarvis 回退默认 */
|
||||
com.ruoyi.common.core.domain.AjaxResult resetAllLlmConfig();
|
||||
|
||||
/** 转发 Jarvis 做一次 LLM 连通测试(可指定 profileId 与自定义问题) */
|
||||
com.ruoyi.common.core.domain.AjaxResult testLlmProfile(Map<String, Object> request);
|
||||
}
|
||||
|
||||
|
||||
@@ -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