Fix items.json path issue when path is empty
Browse files- handler.py +2 -1
handler.py
CHANGED
|
@@ -49,7 +49,8 @@ class EndpointHandler:
|
|
| 49 |
with contextlib.suppress(Exception):
|
| 50 |
loaded = self._load_snapshot_from_hub_latest()
|
| 51 |
if not loaded:
|
| 52 |
-
|
|
|
|
| 53 |
items = json.load(f)
|
| 54 |
prompts = [it["prompt"] for it in items]
|
| 55 |
self.class_ids = [int(it["id"]) for it in items]
|
|
|
|
| 49 |
with contextlib.suppress(Exception):
|
| 50 |
loaded = self._load_snapshot_from_hub_latest()
|
| 51 |
if not loaded:
|
| 52 |
+
items_path = "items.json" if not path else f"{path}/items.json"
|
| 53 |
+
with open(items_path, "r", encoding="utf-8") as f:
|
| 54 |
items = json.load(f)
|
| 55 |
prompts = [it["prompt"] for it in items]
|
| 56 |
self.class_ids = [int(it["id"]) for it in items]
|