import gradio as gr import json import os # Load capability registry def load_registry(): registry_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'capability_registry.json') with open(registry_path, 'r') as f: return json.load(f) registry = load_registry() capabilities = registry['capabilities'] # Extract unique values for filters all_categories = sorted(list(set([cap['category'] for cap in capabilities]))) all_spaces = sorted(list(set([space for cap in capabilities for space in cap['used_in_spaces']]))) all_models = sorted(list(set([model for cap in capabilities for model in cap['models']]))) all_datasets = sorted(list(set([dataset for cap in capabilities for dataset in cap['datasets']]))) def search_capabilities(search_text, category_filter, space_filter, model_filter, dataset_filter): """Search and filter capabilities based on user inputs""" filtered_caps = capabilities # Apply search text filter if search_text: search_lower = search_text.lower() filtered_caps = [ cap for cap in filtered_caps if search_lower in cap['capability_name'].lower() or search_lower in cap['category'].lower() or search_lower in ' '.join(cap['insurance_decisions']).lower() ] # Apply category filter if category_filter and category_filter != "All": filtered_caps = [cap for cap in filtered_caps if cap['category'] == category_filter] # Apply space filter if space_filter and space_filter != "All": filtered_caps = [cap for cap in filtered_caps if space_filter in cap['used_in_spaces']] # Apply model filter if model_filter and model_filter != "All": filtered_caps = [cap for cap in filtered_caps if model_filter in cap['models']] # Apply dataset filter if dataset_filter and dataset_filter != "All": filtered_caps = [cap for cap in filtered_caps if dataset_filter in cap['datasets']] # Generate HTML output if not filtered_caps: return "

No capabilities found matching your criteria.

" html_output = f"

Found {len(filtered_caps)} Capability(ies)

" for cap in filtered_caps: html_output += f"""

🔹 {cap['capability_name']}

Category: {cap['category']}

Used in Spaces: {', '.join(cap['used_in_spaces'])}

Models: {', '.join(cap['models'])}

Datasets: {', '.join(cap['datasets'])}

Insurance Decisions: {', '.join(cap['insurance_decisions'])}

Governance Required: {'✅ Yes' if cap['governance_required'] else '❌ No'}

""" html_output += "
" return html_output def create_capability_browser(): """Create the Gradio interface for capability browsing""" with gr.Blocks(title="BDR Agent Factory - Capability Browser", theme=gr.themes.Soft()) as demo: gr.Markdown(""" # 🏭 BDR Agent Factory — Capability Browser **Enterprise Decision Intelligence Architecture for Insurance & Regulated Markets** Browse and search AI capabilities used across the Bader AI platform. Filter by category, system, model, or dataset to understand how capabilities map to insurance decisions. """) with gr.Row(): with gr.Column(scale=2): search_box = gr.Textbox( label="🔍 Search Capabilities", placeholder="Search by capability name, category, or decision...", lines=1 ) with gr.Row(): category_dropdown = gr.Dropdown( choices=["All"] + all_categories, value="All", label="📂 Filter by Category", interactive=True ) space_dropdown = gr.Dropdown( choices=["All"] + all_spaces, value="All", label="🚀 Filter by Space", interactive=True ) model_dropdown = gr.Dropdown( choices=["All"] + all_models, value="All", label="🤖 Filter by Model", interactive=True ) dataset_dropdown = gr.Dropdown( choices=["All"] + all_datasets, value="All", label="📊 Filter by Dataset", interactive=True ) search_button = gr.Button("Search", variant="primary", size="lg") results_html = gr.HTML( value=search_capabilities("", "All", "All", "All", "All"), label="Results" ) # Set up event handlers search_button.click( fn=search_capabilities, inputs=[search_box, category_dropdown, space_dropdown, model_dropdown, dataset_dropdown], outputs=results_html ) # Also trigger search on Enter key in search box search_box.submit( fn=search_capabilities, inputs=[search_box, category_dropdown, space_dropdown, model_dropdown, dataset_dropdown], outputs=results_html ) gr.Markdown(""" --- ## 📚 Documentation - **[Overview](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory/blob/main/docs/00_OVERVIEW.md)**: What is BDR Agent Factory? - **[Capability Dictionary](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory/blob/main/docs/01_CAPABILITY_DICTIONARY.md)**: Full catalog of AI capabilities (A–N) - **[Capability Map](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory/blob/main/docs/02_CAPABILITY_MAP.md)**: Mappings to systems, models, datasets, decisions - **[Governance Standards](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory/blob/main/docs/03_GOVERNANCE.md)**: Unified governance policies - **[Extension Guide](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory/blob/main/docs/04_EXTENSION_GUIDE.md)**: How to add new capabilities ## 🔗 Linked Systems - **[ClaimsGPT](https://huggingface.co/spaces/bdr-ai-org/ClaimsGPT)**: AI-powered claim decision intelligence - **[FraudSimulator-AI](https://huggingface.co/spaces/bdr-ai-org/FraudSimulator-AI)**: Fraud risk and anomaly detection - **[AutoRiskScoreEngine](https://huggingface.co/spaces/bdr-ai-org/AutoRiskScoreEngine)**: IFRS-ready underwriting risk assessment - **[InsuranceKnowledgeAgent](https://huggingface.co/spaces/bdr-ai-org/InsuranceKnowledgeAgent)**: RAG-powered policy knowledge --- **BDR Agent Factory** — The authoritative capability registry for Bader AI, the GCC Insurance Decision Intelligence Platform. """) return demo if __name__ == "__main__": demo = create_capability_browser() demo.launch()