Spaces:
Sleeping
Sleeping
| """InsuranceKnowledgeAgent - RAG-Powered Policy Q&A | |
| Built using BDR Agent Factory v1 | |
| """ | |
| import gradio as gr | |
| from agents.retrieval_agent import RetrievalAgent | |
| class InsuranceKnowledgeAgent: | |
| def __init__(self): | |
| self.retrieval_agent = RetrievalAgent() | |
| def answer_question(self, question: str): | |
| results = self.retrieval_agent.process(question) | |
| answer_text = f"**Answer:**\n{results['answer']}" | |
| clauses_text = f"**Supporting Clauses:**\n" | |
| if results['supporting_clauses']: | |
| clauses_text += "\n".join("- " + c for c in results['supporting_clauses']) | |
| else: | |
| clauses_text += "No clauses cited" | |
| confidence_text = f"**Confidence:** {results['confidence']:.1%}" | |
| return answer_text, clauses_text, confidence_text | |
| app = InsuranceKnowledgeAgent() | |
| with gr.Blocks(title="InsuranceKnowledgeAgent", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(""" | |
| # π InsuranceKnowledgeAgent | |
| ## RAG-Powered Insurance Policy Knowledge | |
| **Clause citation | Version-aware | Policy conflict resolution** | |
| *Built using [BDR Agent Factory v1](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory)* | |
| """) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### β Ask a Question") | |
| question_input = gr.Textbox(label="Question", placeholder="What does the policy cover?", lines=3) | |
| ask_btn = gr.Button("π Get Answer", variant="primary", size="lg") | |
| with gr.Column(): | |
| gr.Markdown("### π‘ Answer") | |
| answer_output = gr.Textbox(label="Answer", lines=3) | |
| clauses_output = gr.Textbox(label="Supporting Clauses", lines=3) | |
| confidence_output = gr.Textbox(label="Confidence", lines=1) | |
| gr.Examples( | |
| examples=[ | |
| ["What does the policy cover?"], | |
| ["What are the exclusions?"], | |
| ["How do I file a claim?"], | |
| ], | |
| inputs=[question_input] | |
| ) | |
| ask_btn.click( | |
| fn=app.answer_question, | |
| inputs=[question_input], | |
| outputs=[answer_output, clauses_output, confidence_output] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |