""" 检查 Qdrant 中实际存在的 collections """ import asyncio import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) from qdrant_client import AsyncQdrantClient from app.core.config import get_settings async def check_qdrant_collections(): """检查 Qdrant 中实际存在的 collections""" settings = get_settings() client = AsyncQdrantClient(url=settings.qdrant_url) try: collections = await client.get_collections() print(f"\n{'='*80}") print(f"Qdrant 中所有 collections:") print(f"{'='*80}") for coll in collections.collections: print(f" - {coll.name}") tenant_id = "szmp@ash@2026" safe_tenant_id = tenant_id.replace('@', '_') prefix = f"kb_{safe_tenant_id}" tenant_collections = [coll.name for coll in collections.collections if coll.name.startswith(prefix)] print(f"\n租户 {tenant_id} 的 collections:") print(f"{'='*80}") for coll_name in tenant_collections: print(f" - {coll_name}") kb_id = None if coll_name.startswith(prefix): parts = coll_name.split('_') if len(parts) > 2: kb_id = parts[2] print(f" kb_id: {kb_id}") except Exception as e: print(f"错误: {e}") finally: await client.close() if __name__ == "__main__": asyncio.run(check_qdrant_collections())