Spaces:
Runtime error
Runtime error
| import sys | |
| import os | |
| import asyncio | |
| import numpy as np | |
| # Add server directory to path | |
| sys.path.append('/Users/mac/Projects/customerAgent/server') | |
| from app.services.nlp_processor import NLPService | |
| async def test_truth_domains(): | |
| nlp = NLPService() | |
| test_cases = [ | |
| { | |
| "text": "What are your opening hours? We are open from 9 AM to 9 PM daily.", | |
| "url": "https://example.com/faq", | |
| "title": "Frequently Asked Questions", | |
| "expected_truth": "high", | |
| "expected_yes_no": True | |
| }, | |
| { | |
| "text": "CareHome provides premium telemedicine services in Lahore and Karachi.", | |
| "url": "https://example.com/services", | |
| "title": "Our Services", | |
| "expected_truth": "medium", | |
| "expected_yes_no": False | |
| } | |
| ] | |
| for case in test_cases: | |
| chunks = nlp.semantic_chunk_v3(case['text'], url=case['url'], title=case['title']) | |
| if not chunks: | |
| print(f"FAILED: No chunks generated for {case['url']}") | |
| continue | |
| chunk = chunks[0] | |
| truth = chunk.get('truth_level') | |
| yes_no = chunk.get('can_answer_yes_no') | |
| print(f"URL: {case['url']}") | |
| print(f" Truth: {truth} (Expected: {case['expected_truth']})") | |
| print(f" Yes/No: {yes_no} (Expected: {case['expected_yes_no']})") | |
| assert truth == case['expected_truth'] | |
| assert yes_no == case['expected_yes_no'] | |
| print("\n✅ Metadata enrichment verification PASSED!") | |
| if __name__ == "__main__": | |
| asyncio.run(test_truth_domains()) | |