v0.0.34: вывод токенов и времени LLM в UI (суммарно за прогон)
Deploy drhider / validate (push) Canceled after 0s
Deploy drhider / validate (push) Canceled after 0s
This commit is contained in:
+10
-3
@@ -87,7 +87,11 @@ def process_stream(sid):
|
||||
zip_data, csv_str = obfuscate_files(
|
||||
all_files, llm_client=llm, progress_cb=progress
|
||||
)
|
||||
q.put(("result", zip_data, csv_str))
|
||||
stats = {
|
||||
"tokens": llm.tokens_total,
|
||||
"llm_sec": round(llm.llm_sec, 1),
|
||||
}
|
||||
q.put(("result", zip_data, csv_str, stats))
|
||||
except Exception as e:
|
||||
q.put(("error", repr(e)))
|
||||
|
||||
@@ -115,7 +119,7 @@ def process_stream(sid):
|
||||
return
|
||||
|
||||
elif kind == "result":
|
||||
_, zip_data, csv_str = evt
|
||||
_, zip_data, csv_str, stats = evt
|
||||
store_result(sid, zip_data)
|
||||
if csv_str:
|
||||
store_csv(sid, csv_str)
|
||||
@@ -123,7 +127,10 @@ def process_stream(sid):
|
||||
with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
|
||||
count = len([n for n in zf.namelist() if n != "mapping.csv"])
|
||||
try:
|
||||
yield f"event: complete\ndata: {json.dumps({'total': count})}\n\n"
|
||||
yield (
|
||||
f"event: complete\n"
|
||||
f"data: {json.dumps({'total': count, **stats})}\n\n"
|
||||
)
|
||||
except _disconnect_exceptions():
|
||||
return
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user