mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
fix(routes): await trained words extraction
This commit is contained in:
@@ -320,9 +320,14 @@ class TrainedWordsHandler:
|
|||||||
if not file_path.endswith(".safetensors"):
|
if not file_path.endswith(".safetensors"):
|
||||||
return web.json_response({"success": False, "error": "File must be a safetensors file"}, status=400)
|
return web.json_response({"success": False, "error": "File must be a safetensors file"}, status=400)
|
||||||
|
|
||||||
trained_words = extract_trained_words(file_path)
|
trained_words, class_tokens = await extract_trained_words(file_path)
|
||||||
sorted_words = sorted(trained_words, key=lambda w: w.get("count", 0), reverse=True)
|
return web.json_response(
|
||||||
return web.json_response({"success": True, "trained_words": sorted_words})
|
{
|
||||||
|
"success": True,
|
||||||
|
"trained_words": trained_words,
|
||||||
|
"class_tokens": class_tokens,
|
||||||
|
}
|
||||||
|
)
|
||||||
except Exception as exc: # pragma: no cover - defensive logging
|
except Exception as exc: # pragma: no cover - defensive logging
|
||||||
logger.error("Failed to get trained words: %s", exc, exc_info=True)
|
logger.error("Failed to get trained words: %s", exc, exc_info=True)
|
||||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||||
|
|||||||
Reference in New Issue
Block a user