From 6181682560971d8d8f41284b0628146426ecbdfd Mon Sep 17 00:00:00 2001 From: Atharv1705 Date: Mon, 5 Oct 2026 18:15:44 +0530 Subject: [PATCH] fix: explicit None for tax_year to avoid FastAPI Query object evaluation in python context --- services/api/app/routers/chatbot.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/services/api/app/routers/chatbot.py b/services/api/app/routers/chatbot.py index e4da69e..e42c136 100644 --- a/services/api/app/routers/chatbot.py +++ b/services/api/app/routers/chatbot.py @@ -296,7 +296,7 @@ class ChatRequest(BaseModel): session_id: str | None = None def _build_admin_context(db: Session, current_user) -> str: - status = get_admin_status(db=db, current_user=current_user, _=None) + status = get_admin_status(tax_year=None, db=db, current_user=current_user, _=None) ctx = f"=== LIVE SYSTEM DATA (as of {datetime.now().strftime('%Y-%m-%d %H:%M')}) ===\n" ctx += f"Total registered users: {status['total_users']}\n" ctx += f"New users registered TODAY: {status['new_users_today']}\n" @@ -359,25 +359,15 @@ def ask_chatbot( if is_admin: context = _build_admin_context(db, current_user) system_prompt = ( - "You are the BookKeepPro Admin Assistant with live access to system data. - -" - "CAPABILITIES: Answer questions about uploads, user activity, pending docs, registration counts. -" - "WORKFLOW GUIDANCE: If asked how to do something in the app: -" - "- Send document for review: Go to Users Overview -> Click the User -> Upload under 'Filing Timeline' -> Click Submit Review. -" - "- Review user documents: Go to Users Overview -> Click the User -> Go to Personal/Business Docs -> Click Approve or Reject. -" + "You are the BookKeepPro Admin Assistant with live access to system data.\n\n" + "CAPABILITIES: Answer questions about uploads, user activity, pending docs, registration counts.\n" + "WORKFLOW GUIDANCE: If asked how to do something in the app:\n" + "- Send document for review: Go to Users Overview -> Click the User -> Upload under 'Filing Timeline' -> Click Submit Review.\n" + "- Review user documents: Go to Users Overview -> Click the User -> Go to Personal/Business Docs -> Click Approve or Reject.\n" "BULK ACTIONS: When asked to approve/reject all docs for a user, respond with a structured " - "JSON action block like: {\"bulk_action\": {\"user_id\": N, \"action\": \"approve_personal\", \"confirm\": false}} -" - "TOOLS: Use the lookup_user tool to fetch details about a specific user if their name or email is mentioned. -" - "RULES: Only answer BookKeepPro, accounting, or tax questions. Use live data. Be concise. - -" + "JSON action block like: {\"bulk_action\": {\"user_id\": N, \"action\": \"approve_personal\", \"confirm\": false}}\n" + "TOOLS: Use the lookup_user tool to fetch details about a specific user if their name or email is mentioned.\n" + "RULES: Only answer BookKeepPro, accounting, or tax questions. Use live data. Be concise.\n\n" f"{context}" ) else: