release: freeze Nexus One AI 1.0.0-rc1
This commit is contained in:
1 parent
63acefd890
commit
4f1419ca93
152 files changed
+9445
-828
No files matched your search
@@ -73,7 +73,7 @@ def set_status(status: str):
|
||||
# ── Dataset loading ───────────────────────────────────────────────────────────
|
||||
|
||||
def load_dataset_from_file(path: str):
|
||||
"""Load JSONL or CSV dataset into a list of dicts with 'text' or 'prompt'/'completion' keys."""
|
||||
"""Load JSON, JSONL, or CSV training records as a list of objects."""
|
||||
p = Path(path)
|
||||
rows = []
|
||||
if p.suffix.lower() == ".csv":
|
||||
@@ -82,6 +82,16 @@ def load_dataset_from_file(path: str):
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
rows.append(dict(row))
|
||||
elif p.suffix.lower() == ".json":
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
payload = json.load(f)
|
||||
if isinstance(payload, list):
|
||||
rows = payload
|
||||
elif isinstance(payload, dict):
|
||||
for key in ("samples", "data", "records"):
|
||||
if isinstance(payload.get(key), list):
|
||||
rows = payload[key]
|
||||
break
|
||||
else:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
for line in f:
|
||||
@@ -90,7 +100,11 @@ def load_dataset_from_file(path: str):
|
||||
try:
|
||||
rows.append(json.loads(line))
|
||||
except Exception:
|
||||
pass
|
||||
raise ValueError("Dataset contains an invalid JSONL row")
|
||||
if not rows:
|
||||
raise ValueError("Dataset has no training records")
|
||||
if not all(isinstance(row, dict) for row in rows):
|
||||
raise ValueError("Every training record must be a JSON object or CSV row")
|
||||
return rows
|
||||
|
||||
def format_row(row: dict) -> str:
|
||||
|
||||
Reference in new issue
Block a user