Spaces:
Runtime error
Runtime error
| import asyncio | |
| import json | |
| import logging | |
| from app.services.industry_ai import IndustryAI | |
| from app.services.gemini_service import get_gemini_service | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| async def test_ask_anything(): | |
| print("\n--- Testing 'Ask Anything' Medical Capability ---\n") | |
| industry_ai = IndustryAI() | |
| # Verify Gemini is enabled | |
| gemini = get_gemini_service() | |
| if not gemini.enabled: | |
| print("Error: Gemini is not enabled. Fallback will not work.") | |
| return | |
| test_queries = [ | |
| # This should hit the LLM stage as it's likely not in the 111 Q&A base | |
| "What are the latest treatments for rare variants of alopecia areata?", | |
| # This is a very specific medical question | |
| "Explain the mechanism of action of SGLT2 inhibitors for diabetic patients.", | |
| # This should also hit LLM fallback | |
| "What is the difference between a pulse oximeter and a blood gas analysis for oxygen saturation?" | |
| ] | |
| config = { | |
| 'intent': 'medical_consult', | |
| 'website_id': 1 | |
| } | |
| for query in test_queries: | |
| print(f"User Query: {query}") | |
| print("-" * 20) | |
| # Call the industry dataset response (which now has Tri-Stage logic) | |
| response, confidence, needs_contact = await industry_ai.get_industry_dataset_response( | |
| query, | |
| industry="healthcare", | |
| config=config | |
| ) | |
| print(f"Bot Response: {response}") | |
| print(f"Confidence: {confidence}") | |
| print(f"Needs Contact: {needs_contact}") | |
| print("-" * 40 + "\n") | |
| if __name__ == "__main__": | |
| asyncio.run(test_ask_anything()) | |