BDR-Agent-Factory / ui /capability_browser.py
Bader Alabddan
Add complete BDR Agent Factory structure with docs, UI, and capability registry
32a5a16
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 "<div style='padding: 20px; text-align: center;'><h3>No capabilities found matching your criteria.</h3></div>"
html_output = f"<div style='padding: 20px;'><h3>Found {len(filtered_caps)} Capability(ies)</h3>"
for cap in filtered_caps:
html_output += f"""
<div style='border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin: 15px 0; background: #f9f9f9;'>
<h3 style='margin-top: 0; color: #2c3e50;'>πŸ”Ή {cap['capability_name']}</h3>
<p><strong>Category:</strong> {cap['category']}</p>
<p><strong>Used in Spaces:</strong> {', '.join(cap['used_in_spaces'])}</p>
<p><strong>Models:</strong> {', '.join(cap['models'])}</p>
<p><strong>Datasets:</strong> {', '.join(cap['datasets'])}</p>
<p><strong>Insurance Decisions:</strong> {', '.join(cap['insurance_decisions'])}</p>
<p><strong>Governance Required:</strong> {'βœ… Yes' if cap['governance_required'] else '❌ No'}</p>
</div>
"""
html_output += "</div>"
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()