|
@@ -177,15 +177,31 @@ public class OllamaUtil {
|
|
/*
|
|
/*
|
|
---------------------- [Chat] line ----------------------
|
|
---------------------- [Chat] line ----------------------
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-18T07:37:06.483163789Z","message":{"role":"assistant","content":"\u003cthink\u003e"},"done":false}
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-18T07:37:06.483163789Z","message":{"role":"assistant","content":"\u003cthink\u003e"},"done":false}
|
|
- ---------------------- [Generate] line ----------------------
|
|
|
|
|
|
+
|
|
|
|
+ ---------------------- [Generate] line ------------------
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-05T10:51:17.443189986Z","response":"\u003cthink\u003e","done":false}
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-05T10:51:17.443189986Z","response":"\u003cthink\u003e","done":false}
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-06T11:08:30.9219611Z","response":"\n\n","done":false}
|
|
{"model":"deepseek-r1:1.5b","created_at":"2025-03-06T11:08:30.9219611Z","response":"\n\n","done":false}
|
|
- -------------------------------------------------------------
|
|
|
|
|
|
+
|
|
|
|
+ ---------------------- [Error] line ---------------------
|
|
|
|
+ {"error":"llama runner process has terminated: error loading model: unable to allocate CUDA0 buffer"}
|
|
*/
|
|
*/
|
|
|
|
|
|
// 每行数据可以是一个JSON对象,根据实际情况处理
|
|
// 每行数据可以是一个JSON对象,根据实际情况处理
|
|
JSONObject resJson = JSONObject.parseObject(line);
|
|
JSONObject resJson = JSONObject.parseObject(line);
|
|
|
|
|
|
|
|
+ // -- 判断内容是否为空 (或报错) --------------------------------------
|
|
|
|
+ if (resJson == null) return null;
|
|
|
|
+ String errJsonMessage = resJson.getString("error");
|
|
|
|
+ if (errJsonMessage != null) {
|
|
|
|
+ // [SSE] 发送消息
|
|
|
|
+ sseUtil.send(user_id, new SseResponse(SseResponseEnum.DEEPSEEK, new ChatSseMessage("REPLY", errJsonMessage, contentDuration)).toJsonStr());
|
|
|
|
+ // [SSE] 发送消息 (完成)
|
|
|
|
+ sseUtil.send(user_id, new SseResponse(SseResponseEnum.DEEPSEEK, new ChatSseMessage("REPLY", "[DONE][REPLY]", contentDuration)).toJsonStr());
|
|
|
|
+ //
|
|
|
|
+ chatResult.setContent(errJsonMessage);
|
|
|
|
+ return chatResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
// --------------------------------------------------------------
|
|
// --------------------------------------------------------------
|
|
// [Chat]
|
|
// [Chat]
|
|
JSONObject resJsonMessage = resJson.getJSONObject("message");
|
|
JSONObject resJsonMessage = resJson.getJSONObject("message");
|