FA3-Datafetch/backend/check_db_logs.py
2026-01-13 14:49:36 +08:00

26 lines
977 B
Python

import asyncio
from sqlalchemy import select, desc
from app.database import get_db, SessionLocal
from app.models import LLMUsageLog
async def check_logs():
async with SessionLocal() as session:
result = await session.execute(
select(LLMUsageLog).order_by(desc(LLMUsageLog.timestamp)).limit(5)
)
logs = result.scalars().all()
print(f"Found {len(logs)} recent logs:")
for log in logs:
print("-" * 50)
print(f"ID: {log.id}")
print(f"Time: {log.timestamp}")
print(f"Model: {log.model}")
print(f"Used Search: {log.used_google_search}")
print(f"Prompt (first 50): {log.prompt[:50]}...")
print(f"Response (first 50): {log.response[:50]}..." if log.response else "No Response")
# Note: We don't store grounding metadata in the DB currently, only in the API return.
if __name__ == "__main__":
asyncio.run(check_logs())