#!/usr/bin/env python3
import os
import sys

# Add parent dir to path so we can import GramAddict
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from GramAddict.core.qdrant_memory import UIMemoryDB


def wipe_qdrant():
    print("🧹 Initializing Qdrant connection...")
    memory = UIMemoryDB()

    if not memory.is_connected:
        print("❌ Qdrant is not connected. Make sure the container is running.")
        sys.exit(1)

    print(f"⚠️ Wiping collection: {memory.COLLECTION_NAME}")

    try:
        memory.client.delete_collection(collection_name=memory.COLLECTION_NAME)
        print("✅ Collection deleted.")

        # Reinitialize to recreate the schema
        memory._init_collection()
        print("✅ Collection recreated with clean schema.")

        print("🎉 Qdrant Memory is now completely clean and ready for fresh learning!")
    except Exception as e:
        print(f"❌ Failed to wipe Qdrant memory: {e}")
        sys.exit(1)


if __name__ == "__main__":
    wipe_qdrant()
