Spaces:
Sleeping
Sleeping
Add AI Model Council tab: app.py
Browse files
app.py
CHANGED
|
@@ -375,7 +375,82 @@ Both operations are idempotent and logged.
|
|
| 375 |
interactive=False,
|
| 376 |
)
|
| 377 |
|
| 378 |
-
# ββ Tab 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
with gr.Tab("π Audit Log"):
|
| 380 |
gr.Markdown("### Taxonomy Audit Trail\nEvery domain change, migration, and rollback is logged.")
|
| 381 |
|
|
|
|
| 375 |
interactive=False,
|
| 376 |
)
|
| 377 |
|
| 378 |
+
# ββ Tab 5: AI Model Council ββββββββββββββββββββββ
|
| 379 |
+
with gr.Tab("ποΈ AI Model Council"):
|
| 380 |
+
gr.Markdown("""### AI Model Council β Multi-Agent Claim Extraction
|
| 381 |
+
|
| 382 |
+
The Council is a 4-member deliberation pipeline that produces higher-quality claim extraction:
|
| 383 |
+
|
| 384 |
+
| Member | Role | What It Does |
|
| 385 |
+
|--------|------|-------------|
|
| 386 |
+
| **Query Planner** | Decomposer | Breaks complex questions into 2-4 search queries |
|
| 387 |
+
| **Extractor** | Claim Miner | Extracts atomic claims with epistemic tags |
|
| 388 |
+
| **Critic** | Challenger | Reviews claims against source, flags errors |
|
| 389 |
+
| **Chairman** | Synthesizer | Produces final claims with 0.7 completeness penalty |
|
| 390 |
+
""")
|
| 391 |
+
|
| 392 |
+
with gr.Row():
|
| 393 |
+
council_text = gr.Textbox(
|
| 394 |
+
label="Scientific Text",
|
| 395 |
+
placeholder="Paste a paragraph from a scientific paper...",
|
| 396 |
+
lines=8,
|
| 397 |
+
)
|
| 398 |
+
council_query = gr.Textbox(
|
| 399 |
+
label="Research Question (optional)",
|
| 400 |
+
placeholder="e.g., What is the detection limit for GFET cardiac sensors?",
|
| 401 |
+
)
|
| 402 |
+
council_btn = gr.Button("ποΈ Convene Council", variant="primary")
|
| 403 |
+
|
| 404 |
+
with gr.Row():
|
| 405 |
+
council_claims = gr.JSON(label="Final Claims (Chairman Output)")
|
| 406 |
+
|
| 407 |
+
with gr.Accordion("Council Deliberation Details", open=False):
|
| 408 |
+
council_queries = gr.JSON(label="Query Plan (Planner)")
|
| 409 |
+
council_raw = gr.JSON(label="Raw Extraction (Extractor)")
|
| 410 |
+
council_critique = gr.JSON(label="Critique (Critic)")
|
| 411 |
+
council_meta = gr.JSON(label="Round Metadata")
|
| 412 |
+
|
| 413 |
+
def run_council_ui(text, query):
|
| 414 |
+
if not text or len(text.strip()) < 50:
|
| 415 |
+
return (
|
| 416 |
+
[{"error": "Please provide at least 50 characters of scientific text"}],
|
| 417 |
+
[], [], {}, {}
|
| 418 |
+
)
|
| 419 |
+
from phd_research_os.council import ModelCouncil
|
| 420 |
+
council = ModelCouncil(brain=None, db_path=DB_PATH)
|
| 421 |
+
result = council.deliberate(text, query=query if query else None)
|
| 422 |
+
return (
|
| 423 |
+
result.final_claims,
|
| 424 |
+
result.query_plan,
|
| 425 |
+
result.raw_extraction,
|
| 426 |
+
result.critique,
|
| 427 |
+
result.metadata,
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
council_btn.click(
|
| 431 |
+
run_council_ui,
|
| 432 |
+
inputs=[council_text, council_query],
|
| 433 |
+
outputs=[council_claims, council_queries, council_raw, council_critique, council_meta],
|
| 434 |
+
)
|
| 435 |
+
|
| 436 |
+
gr.Markdown("---\n### Council History")
|
| 437 |
+
history_btn = gr.Button("π Load History")
|
| 438 |
+
history_display = gr.Dataframe(
|
| 439 |
+
headers=["Round ID", "Claims", "Tokens", "Started"],
|
| 440 |
+
value=[],
|
| 441 |
+
)
|
| 442 |
+
|
| 443 |
+
def load_council_history():
|
| 444 |
+
from phd_research_os.council import ModelCouncil
|
| 445 |
+
council = ModelCouncil(brain=None, db_path=DB_PATH)
|
| 446 |
+
history = council.get_council_history(limit=10)
|
| 447 |
+
return [[h["round_id"], h.get("final_claim_count", 0),
|
| 448 |
+
h.get("total_tokens", 0), h.get("started_at", "")[:19]]
|
| 449 |
+
for h in history]
|
| 450 |
+
|
| 451 |
+
history_btn.click(load_council_history, outputs=history_display)
|
| 452 |
+
|
| 453 |
+
# ββ Tab 6: Audit Log βββββββββββββββββββββββββββββ
|
| 454 |
with gr.Tab("π Audit Log"):
|
| 455 |
gr.Markdown("### Taxonomy Audit Trail\nEvery domain change, migration, and rollback is logged.")
|
| 456 |
|