52 lines
1.6 KiB
Python
52 lines
1.6 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.models.entities import IntentRule
|
|
from app.core.config import get_settings
|
|
|
|
|
|
async def check_all_rules():
|
|
"""获取所有意图规则"""
|
|
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:
|
|
# 查询所有规则(包括未启用的)
|
|
result = await session.execute(
|
|
select(IntentRule).where(
|
|
IntentRule.tenant_id == "szmp@ash@2026"
|
|
)
|
|
)
|
|
rules = result.scalars().all()
|
|
|
|
print("=" * 80)
|
|
print(f"数据库中的所有意图规则 (tenant=szmp@ash@2026):")
|
|
print(f"总计: {len(rules)} 条")
|
|
print("=" * 80)
|
|
|
|
for rule in rules:
|
|
print(f"\n规则: {rule.name}")
|
|
print(f" ID: {rule.id}")
|
|
print(f" 响应类型: {rule.response_type}")
|
|
print(f" 关键词: {rule.keywords}")
|
|
print(f" 目标知识库: {rule.target_kb_ids}")
|
|
print(f" 优先级: {rule.priority}")
|
|
print(f" 启用状态: {'✅ 启用' if rule.is_enabled else '❌ 禁用'}")
|
|
|
|
print("\n" + "=" * 80)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(check_all_rules())
|