52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
"""
|
|
检查租户的所有知识库
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from app.core.config import get_settings
|
|
from app.models.entities import KnowledgeBase
|
|
|
|
|
|
async def check_knowledge_bases():
|
|
"""检查租户的所有知识库"""
|
|
settings = get_settings()
|
|
|
|
engine = create_async_engine(settings.database_url)
|
|
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
async with async_session() as session:
|
|
tenant_id = "szmp@ash@2026"
|
|
|
|
print(f"\n{'='*80}")
|
|
print(f"检查租户 {tenant_id} 的所有知识库")
|
|
print(f"{'='*80}")
|
|
|
|
stmt = select(KnowledgeBase).where(
|
|
KnowledgeBase.tenant_id == tenant_id,
|
|
)
|
|
result = await session.execute(stmt)
|
|
kbs = result.scalars().all()
|
|
|
|
print(f"\n找到 {len(kbs)} 个知识库:")
|
|
|
|
for kb in kbs:
|
|
print(f"\n 知识库: {kb.name}")
|
|
print(f" id: {kb.id}")
|
|
print(f" kb_type: {kb.kb_type}")
|
|
print(f" description: {kb.description}")
|
|
print(f" is_enabled: {kb.is_enabled}")
|
|
print(f" doc_count: {kb.doc_count}")
|
|
print(f" created_at: {kb.created_at}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(check_knowledge_bases())
|