yangdx
commited on
Commit
·
3a5c6c3
1
Parent(s):
f55e12d
修复测试用例流结束判断
Browse files- lightrag/api/lightrag_ollama.py +12 -12
- test_lightrag_ollama_chat.py +1 -1
lightrag/api/lightrag_ollama.py
CHANGED
@@ -743,12 +743,12 @@ def create_app(args):
|
|
743 |
"model": LIGHTRAG_MODEL,
|
744 |
"created_at": LIGHTRAG_CREATED_AT,
|
745 |
"done": True,
|
746 |
-
"total_duration":
|
747 |
-
"load_duration":
|
748 |
-
"prompt_eval_count":
|
749 |
-
"prompt_eval_duration":
|
750 |
-
"eval_count":
|
751 |
-
"eval_duration":
|
752 |
}
|
753 |
yield f"data: {json.dumps(data, ensure_ascii=False)}\n\n"
|
754 |
return # 确保生成器在发送完成标记后立即结束
|
@@ -789,12 +789,12 @@ def create_app(args):
|
|
789 |
"images": None
|
790 |
},
|
791 |
"done": True,
|
792 |
-
"total_duration":
|
793 |
-
"load_duration":
|
794 |
-
"prompt_eval_count":
|
795 |
-
"prompt_eval_duration":
|
796 |
-
"eval_count":
|
797 |
-
"eval_duration":
|
798 |
}
|
799 |
except Exception as e:
|
800 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
743 |
"model": LIGHTRAG_MODEL,
|
744 |
"created_at": LIGHTRAG_CREATED_AT,
|
745 |
"done": True,
|
746 |
+
"total_duration": 1, # 由于我们没有实际统计这些指标,暂时使用默认值
|
747 |
+
"load_duration": 1,
|
748 |
+
"prompt_eval_count": 999,
|
749 |
+
"prompt_eval_duration": 1,
|
750 |
+
"eval_count": 999,
|
751 |
+
"eval_duration": 1
|
752 |
}
|
753 |
yield f"data: {json.dumps(data, ensure_ascii=False)}\n\n"
|
754 |
return # 确保生成器在发送完成标记后立即结束
|
|
|
789 |
"images": None
|
790 |
},
|
791 |
"done": True,
|
792 |
+
"total_duration": 1, # 由于我们没有实际统计这些指标,暂时使用默认值
|
793 |
+
"load_duration": 1,
|
794 |
+
"prompt_eval_count": 999,
|
795 |
+
"prompt_eval_duration": 1,
|
796 |
+
"eval_count": 999,
|
797 |
+
"eval_duration": 1
|
798 |
}
|
799 |
except Exception as e:
|
800 |
raise HTTPException(status_code=500, detail=str(e))
|
test_lightrag_ollama_chat.py
CHANGED
@@ -70,7 +70,7 @@ def test_stream_chat():
|
|
70 |
for event in client.events():
|
71 |
try:
|
72 |
data = json.loads(event.data)
|
73 |
-
if data.get("done",
|
74 |
if "total_duration" in data: # 最终的性能统计消息
|
75 |
print("\n=== 性能统计 ===")
|
76 |
print(json.dumps(data, ensure_ascii=False, indent=2))
|
|
|
70 |
for event in client.events():
|
71 |
try:
|
72 |
data = json.loads(event.data)
|
73 |
+
if data.get("done", True): # 如果是完成标记
|
74 |
if "total_duration" in data: # 最终的性能统计消息
|
75 |
print("\n=== 性能统计 ===")
|
76 |
print(json.dumps(data, ensure_ascii=False, indent=2))
|