Spaces:
Sleeping
Sleeping
Fix: Resolve 0-entity extraction error by adding NVIDIA LLM integration and robust error handling
feca495 | import os | |
| import shutil | |
| import django | |
| # Set up Django settings context | |
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') | |
| django.setup() | |
| from django.conf import settings | |
| from graphrag.services.neo4j_client import Neo4jClient | |
| def wipe_all_data(): | |
| print("=== STARTING FULL CLEANUP ===") | |
| # 1. Wipe Neo4j Database | |
| try: | |
| print("Connecting to Neo4j...") | |
| neo4j_client = Neo4jClient() | |
| print("Wiping all nodes and relationships in Neo4j...") | |
| neo4j_client.execute_query("MATCH (n) DETACH DELETE n") | |
| print("β Neo4j database successfully wiped.") | |
| except Exception as e: | |
| print(f"β Failed to wipe Neo4j: {e}") | |
| # 2. Delete ChromaDB folder | |
| chroma_dir = settings.CHROMADB_DIR | |
| if os.path.exists(chroma_dir): | |
| try: | |
| print(f"Removing ChromaDB directory: {chroma_dir}...") | |
| shutil.rmtree(chroma_dir) | |
| print("β ChromaDB vectors successfully wiped.") | |
| except Exception as e: | |
| print(f"β Failed to delete ChromaDB folder: {e}") | |
| else: | |
| print("ChromaDB directory does not exist, skipping.") | |
| # 3. Delete Uploaded Documents | |
| media_root = settings.MEDIA_ROOT | |
| if os.path.exists(media_root): | |
| try: | |
| print(f"Emptying media root directory: {media_root}...") | |
| shutil.rmtree(media_root) | |
| os.makedirs(media_root, exist_ok=True) | |
| print("β Uploaded documents successfully wiped.") | |
| except Exception as e: | |
| print(f"β Failed to empty media root: {e}") | |
| else: | |
| print("Media root directory does not exist, skipping.") | |
| # 4. Delete SQLite Database file | |
| sqlite_db = settings.DATABASES['default'].get('NAME') | |
| if sqlite_db and os.path.exists(sqlite_db): | |
| try: | |
| print(f"Removing SQLite database: {sqlite_db}...") | |
| os.remove(sqlite_db) | |
| print("β Django SQLite database successfully wiped.") | |
| except Exception as e: | |
| print(f"β Failed to delete SQLite file: {e}") | |
| else: | |
| print("SQLite database file not found, skipping.") | |
| print("\n=== CLEANUP COMPLETE ===") | |
| print("To finalize the fresh start, run the migrations to rebuild your database tables:") | |
| print(" python manage.py migrate") | |
| print("=========================") | |
| if __name__ == "__main__": | |
| wipe_all_data() | |