Adi12345 commited on
Commit
8a920ae
·
verified ·
1 Parent(s): b09fc5e

Update dvnc_ai_v2_hf/app.py

Browse files
Files changed (1) hide show
  1. dvnc_ai_v2_hf/app.py +109 -34
dvnc_ai_v2_hf/app.py CHANGED
@@ -1566,37 +1566,112 @@ with gr.Blocks(css=CSS, head=HEAD, theme=gr.themes.Base(), fill_height=True) as
1566
  </div>
1567
  """
1568
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1569
 
1570
- with gr.Tab("Discovery Engine"):
1571
- model_html = gr.HTML(build_models_html("DVNC Sovereign"))
1572
- with gr.Row():
1573
- with gr.Column(scale=2):
1574
- model = gr.Dropdown(
1575
- choices=[m["name"] for m in MODELS],
1576
- value="DVNC Sovereign",
1577
- label="Model tier",
1578
  )
1579
- query = gr.Textbox(
1580
- label="Discovery query",
1581
- elem_classes=["querybox"],
1582
- placeholder="Enter a scientific question, anomaly, or breakthrough direction…",
1583
- lines=4,
1584
  )
 
 
1585
  with gr.Row():
1586
- run_btn = gr.Button("Run discovery", variant="primary")
1587
- example_btn = gr.Button("Load example", variant="secondary")
1588
- chat = gr.HTML(
1589
- """
1590
- <div class="panel chat-panel">
1591
- <div class="chat-thread">
1592
- <div class="bubble bubble-ai">
1593
- <span class="role">DVNC</span>
1594
- <p>Enter a query to activate the 7-agent discovery stack and illuminate the chosen path through the 3D connectome.</p>
1595
- </div>
1596
- </div>
1597
- </div>
1598
- """
1599
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1600
  with gr.Column(scale=3):
1601
  connectome = gr.HTML(build_connectome_html(DEFAULT_PATH))
1602
 
@@ -1717,15 +1792,15 @@ with gr.Blocks(css=CSS, head=HEAD, theme=gr.themes.Base(), fill_height=True) as
1717
  example_btn.click(fn=load_example, outputs=query)
1718
 
1719
  run_btn.click(
1720
- fn=run_discovery,
1721
- inputs=[query, model],
1722
- outputs=[chat, connectome, timeline, cards, output, model_html, route_state],
1723
- )
1724
 
1725
  route_swap_apply.click(
1726
- fn=apply_route_swap,
1727
- inputs=[query, model, route_swap_payload, route_state],
1728
- outputs=[chat, connectome, timeline, output, route_state],
1729
  )
1730
 
1731
  load_topic_btn.click(fn=load_paper_topic, outputs=paper_query)
 
1566
  </div>
1567
  """
1568
  )
1569
+
1570
+ with gr.Tabs():
1571
+ with gr.Tab("Discovery Engine"):
1572
+ model_html = gr.HTML(build_models_html("DVNC Sovereign"))
1573
+ with gr.Row():
1574
+ with gr.Column(scale=2):
1575
+ model = gr.Dropdown(
1576
+ choices=[m["name"] for m in MODELS],
1577
+ value="DVNC Sovereign",
1578
+ label="Model tier",
1579
+ )
1580
+ query = gr.Textbox(
1581
+ label="Discovery query",
1582
+ elem_classes=["querybox"],
1583
+ placeholder="Enter a scientific question, anomaly, or breakthrough direction…",
1584
+ lines=4,
1585
+ )
1586
+ with gr.Row():
1587
+ run_btn = gr.Button("Run discovery", variant="primary")
1588
+ example_btn = gr.Button("Load example", variant="secondary")
1589
+ chat = gr.HTML(
1590
+ """
1591
+ <div class="panel chat-panel">
1592
+ <div class="chat-thread">
1593
+ <div class="bubble bubble-ai">
1594
+ <span class="role">DVNC</span>
1595
+ <p>Enter a query to activate the 7-agent discovery stack and illuminate the chosen path through the 3D connectome.</p>
1596
+ </div>
1597
+ </div>
1598
+ </div>
1599
+ """
1600
+ )
1601
+ with gr.Column(scale=3):
1602
+ connectome = gr.HTML(build_connectome_html(DEFAULT_PATH))
1603
+
1604
+ # Legacy placeholder retained for rollback.
1605
+ # cards = gr.HTML('<div class="panel" style="padding:20px"><div class="candidate-grid"></div></div>')
1606
+ cards = gr.HTML("")
1607
 
1608
+ output = gr.Markdown("# Discovery Output\n\nAwaiting query.")
1609
+ timeline = gr.HTML(get_initial_discovery_timeline_html())
1610
+
1611
+ route_swap_payload = gr.Textbox(
1612
+ value="",
1613
+ visible=False,
1614
+ elem_id="route_swap_payload",
 
1615
  )
1616
+ route_swap_apply = gr.Button(
1617
+ "Apply route swap",
1618
+ visible=False,
1619
+ elem_id="route_swap_apply",
 
1620
  )
1621
+
1622
+ with gr.Tab("Self-Learning Graph"):
1623
  with gr.Row():
1624
+ with gr.Column(scale=2):
1625
+ paper_query = gr.Textbox(
1626
+ label="Research topic / title / DOI / link",
1627
+ elem_classes=["querybox"],
1628
+ placeholder="e.g. self-assembling conductive biomaterials for cardiac repair",
1629
+ lines=3,
1630
+ )
1631
+ search_mode = gr.Dropdown(
1632
+ choices=SEARCH_MODES,
1633
+ value="topic",
1634
+ label="Search mode"
1635
+ )
1636
+ source_selector = gr.CheckboxGroup(
1637
+ choices=SOURCE_OPTIONS,
1638
+ value=DEFAULT_SOURCES,
1639
+ label="Sources"
1640
+ )
1641
+ pdf_upload = gr.File(label="Upload PDF papers", file_types=[".pdf"], file_count="single")
1642
+
1643
+ with gr.Row():
1644
+ learn_btn = gr.Button("Discover papers", variant="primary")
1645
+ load_topic_btn = gr.Button("Load example topic", variant="secondary")
1646
+
1647
+ upload_status = gr.Markdown("No PDF uploaded yet.")
1648
+ discovery_status = gr.Markdown("### No discovery results yet.")
1649
+ journal_panel = gr.HTML(build_journal_html("biomaterials cardiac repair"))
1650
+
1651
+ gr.HTML('<div class="panel selection-panel"><h3 style="margin:0 0 12px;">Select papers to ingest</h3></div>')
1652
+ selection_box = gr.CheckboxGroup(
1653
+ choices=[],
1654
+ value=[],
1655
+ label="Candidate papers"
1656
+ )
1657
+
1658
+ parser_order = gr.CheckboxGroup(
1659
+ choices=["grobid", "docling", "pymupdf"],
1660
+ value=["grobid", "docling", "pymupdf"],
1661
+ label="Parser routing order"
1662
+ )
1663
+
1664
+ with gr.Row():
1665
+ parse_btn = gr.Button("Parse uploaded PDF", variant="secondary")
1666
+ ingest_btn = gr.Button("Ingest selected into graph", variant="primary")
1667
+
1668
+ with gr.Column(scale=3):
1669
+ learning_graph = gr.HTML(build_learning_graph_html([], []))
1670
+ papers_panel = gr.HTML('<div class="panel papers-panel" style="padding:18px"><p>Search by topic, title, DOI, or link, then select papers before graph ingestion.</p></div>')
1671
+ parse_summary = gr.Markdown("### PDF parse status\n\nAwaiting upload.")
1672
+ parse_panel = gr.HTML('<div class="panel" style="padding:18px"><p>No parsed document yet.</p></div>')
1673
+ ingest_summary = gr.Markdown("### Graph ingest status\n\nAwaiting paper selection.")
1674
+ ingest_payload = gr.JSON(label="Graph ingest payload", value={"status": "empty", "nodes": [], "edges": []})
1675
  with gr.Column(scale=3):
1676
  connectome = gr.HTML(build_connectome_html(DEFAULT_PATH))
1677
 
 
1792
  example_btn.click(fn=load_example, outputs=query)
1793
 
1794
  run_btn.click(
1795
+ fn=run_discovery,
1796
+ inputs=[query, model],
1797
+ outputs=[chat, connectome, timeline, cards, output, model_html, route_state],
1798
+ )
1799
 
1800
  route_swap_apply.click(
1801
+ fn=apply_route_swap,
1802
+ inputs=[query, model, route_swap_payload, route_state],
1803
+ outputs=[chat, connectome, timeline, output, route_state],
1804
  )
1805
 
1806
  load_topic_btn.click(fn=load_paper_topic, outputs=paper_query)