"""
删除课程知识库的 Qdrant Collection
"""

import asyncio
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent))

from app.core.config import get_settings
from app.core.qdrant_client import QdrantClient


async def delete_course_kb_collection():
    """删除课程知识库的 Qdrant Collection"""
    settings = get_settings()
    client = QdrantClient()
    qdrant = await client.get_client()
    
    tenant_id = "szmp@ash@2026"
    kb_id = "75c465fe-277d-455d-a30b-4b168adcc03b"
    
    collection_name = client.get_kb_collection_name(tenant_id, kb_id)
    
    print(f"\n{'='*80}")
    print(f"删除课程知识库的 Qdrant Collection")
    print(f"{'='*80}")
    print(f"租户 ID: {tenant_id}")
    print(f"知识库 ID: {kb_id}")
    print(f"Collection 名称: {collection_name}")
    
    exists = await qdrant.collection_exists(collection_name)
    if exists:
        await qdrant.delete_collection(collection_name)
        print(f"\n✅ Collection {collection_name} 已删除!")
    else:
        print(f"\n⚠️ Collection {collection_name} 不存在，无需删除")


if __name__ == "__main__":
    asyncio.run(delete_course_kb_collection())
