1
This commit is contained in:
@@ -349,6 +349,7 @@ public class SocialMediaService {
|
|||||||
*/
|
*/
|
||||||
public Map<String, Object> testLlmChat(String profileId, String message) {
|
public Map<String, Object> testLlmChat(String profileId, String message) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
long started = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
String prompt = StrUtil.isBlank(message)
|
String prompt = StrUtil.isBlank(message)
|
||||||
? "1+1等于几?请只回答一个数字或最简结果,不要多余解释。"
|
? "1+1等于几?请只回答一个数字或最简结果,不要多余解释。"
|
||||||
@@ -363,6 +364,11 @@ public class SocialMediaService {
|
|||||||
result.put("success", false);
|
result.put("success", false);
|
||||||
result.put("error", e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName());
|
result.put("error", e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
long elapsedMs = System.currentTimeMillis() - started;
|
||||||
|
result.put("elapsedMs", elapsedMs);
|
||||||
|
log.info("LLM 调用结束 success={} elapsedMs={} replyChars={}",
|
||||||
|
result.get("success"), elapsedMs,
|
||||||
|
result.get("reply") == null ? 0 : String.valueOf(result.get("reply")).length());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,7 +257,11 @@ public class SocialMediaLlmClient {
|
|||||||
|
|
||||||
log.info("请求 OpenAI 兼容 API: URL={}, model={}", endpoint, normalizeMiniMaxModel(model));
|
log.info("请求 OpenAI 兼容 API: URL={}, model={}", endpoint, normalizeMiniMaxModel(model));
|
||||||
|
|
||||||
|
long started = System.currentTimeMillis();
|
||||||
HttpResponse response = request.execute();
|
HttpResponse response = request.execute();
|
||||||
|
log.info("OpenAI 兼容 API 返回: model={} status={} elapsedMs={} bodyChars={}",
|
||||||
|
normalizeMiniMaxModel(model), response.getStatus(), System.currentTimeMillis() - started,
|
||||||
|
response.body() == null ? 0 : response.body().length());
|
||||||
if (response.getStatus() != 200) {
|
if (response.getStatus() != 200) {
|
||||||
String body = response.body();
|
String body = response.body();
|
||||||
log.error("OpenAI 兼容 API 失败: status={}, body={}", response.getStatus(), body);
|
log.error("OpenAI 兼容 API 失败: status={}, body={}", response.getStatus(), body);
|
||||||
|
|||||||
Reference in New Issue
Block a user