Spaces:
Running
Running
| import json | |
| from backend.database.postgres.db import SessionLocal | |
| from backend.database.postgres.models import TrainingEntry | |
| def export_to_jsonl(): | |
| db = SessionLocal() | |
| output_path = "senti_ai/data/fine_tuning_pairs_backup.jsonl" | |
| entries = db.query(TrainingEntry).all() | |
| with open(output_path, "w", encoding="utf-8") as f: | |
| for entry in entries: | |
| data = { | |
| "user": entry.query, | |
| "senti": entry.response, | |
| "country_code": entry.country_code, | |
| "language": entry.language, | |
| "intent": entry.intent, | |
| "flavor": entry.flavor, | |
| "timestamp": entry.timestamp.isoformat() | |
| } | |
| f.write(json.dumps(data) + "\n") | |
| print(f"Exported {len(entries)} entries to {output_path}") | |
| db.close() | |
| if __name__ == "__main__": | |
| export_to_jsonl() | |