Troubleshooting
Common Error Modes
1. 401 Unauthorized / Authentication failed
- Cause: Invalid or expired Supabase JWT.
- Fix: Refresh the session in the frontend or re-run the Sign-In request in Postman.
- Check: Ensure
SUPABASE_URL and SUPABASE_KEY are correct in .env.
2. 402 Payment Required / Insufficient tokens
- Cause: User's
wallet.token_balance is below the BASE_CHAT_COST.
- Fix: Manually increment the balance in the Supabase Dashboard or implement a top-up.
3. 500 Internal Server Error (Pinecone Context)
- Cause: Dimension mismatch (e.g., trying to query a 768-dim index with 1536-dim vectors).
- Fix: Ensure
EMBEDDING_DIMENSIONS=1536 and your index matches.
- Check: Pinecone dashboard index settings.
- Cause: Retrieval score was below the 0.35 threshold.
- Reason: The question might be out of scope, or the namespace is empty.
- Fix: Ensure curriculum has been uploaded to the correct namespace (e.g.,
grade-12-math).
5. ModuleNotFoundError: No module named 'python-multipart'
- Cause: Missing dependency for FastAPI form data.
- Fix:
pip install python-multipart and update requirements.txt.
Back to Index