| from rich import print as rprint |
| from rich.panel import Panel |
| from models import Question, FinalAnswer |
| from query_service import QueryService |
| from typing import List |
|
|
| def run_test(): |
| TEST_DOCUMENT_URL = "https://hackrx.blob.core.windows.net/assets/policy.pdf?sv=2023-01-03&st=2025-07-04T09%3A11%3A24Z&se=2027-07-05T09%3A11%3A00Z&sr=b&sp=r&sig=N4a9OU0w0QXO6AOIBiu4bpl7AXvEZogeT%2FjUHNO7HzQ%3D" |
| |
| questions = [ |
| "What is the grace period for premium payment under the National Parivar Mediclaim Plus Policy?", |
| "What is the waiting period for pre-existing diseases (PED) to be covered?", |
| "Does this policy cover maternity expenses, and what are the conditions?", |
| "What is the waiting period for cataract surgery?", |
| "Are the medical expenses for an organ donor covered under this policy?", |
| "What is the No Claim Discount (NCD) offered in this policy?", |
| "Is there a benefit for preventive health check-ups?", |
| "How does the policy define a 'Hospital'?", |
| "What is the extent of coverage for AYUSH treatments?", |
| "Are there any sub-limits on room rent and ICU charges for Plan A?" |
| ] |
|
|
| TEST_QUESTIONS = [Question(question=question) for question in questions] |
|
|
| rprint(Panel( |
| f"Document URL: [blue]{TEST_DOCUMENT_URL}[/blue]\n" |
| f"Questions: [yellow]{len(TEST_QUESTIONS)}[/yellow]", |
| title="[bold green]Starting Insurance Policy Test[/bold green]", |
| border_style="green" |
| )) |
|
|
| query_service = QueryService() |
|
|
| results: List[FinalAnswer] = query_service.process_queries( |
| document_url=TEST_DOCUMENT_URL, |
| questions=TEST_QUESTIONS |
| ) |
| |
| rprint(Panel("[bold green]Processing Complete. Displaying Final Results...[/bold green]")) |
|
|
| for i, response in enumerate(results): |
| question_panel = Panel( |
| f"[bold]Answer:[/] {response.answer}", |
| title=f"[bold magenta]Result for Question #{i+1}[/bold magenta]: {TEST_QUESTIONS[i].question}", |
| border_style="magenta", |
| expand=True |
| ) |
| rprint(question_panel) |
|
|
| if __name__ == "__main__": |
| run_test() |