This commit is contained in:
van
2026-04-05 21:35:06 +08:00
parent 26550c033b
commit 0d408d66c3
2 changed files with 51 additions and 0 deletions

View File

@@ -153,6 +153,35 @@ public class SocialMediaController {
return response;
}
/**
* 调试:测试大模型连通性。
* POST /jarvis/social-media/llm/test
* body: { "profileId": "可选,不传则用当前激活或 yml 默认", "message": "可选,默认问 1+1" }
*/
@PostMapping("/llm/test")
public JSONObject testLlm(@RequestBody(required = false) Map<String, Object> request) {
JSONObject response = new JSONObject();
try {
Map<String, Object> req = request != null ? request : new HashMap<>();
Object pid = req.get("profileId");
String profileId = pid == null ? null : pid.toString().trim();
if (profileId != null && profileId.isEmpty()) {
profileId = null;
}
Object msg = req.get("message");
String message = msg == null ? null : msg.toString();
Map<String, Object> data = socialMediaService.testLlmChat(profileId, message);
response.put("code", 200);
response.put("msg", "操作成功");
response.put("data", data);
} catch (Exception e) {
log.error("LLM 测试接口异常", e);
response.put("code", 500);
response.put("msg", "测试失败: " + e.getMessage());
}
return response;
}
/**
* 解析Double值
*/