AD2000X commited on
Commit
dca17fd
·
verified ·
1 Parent(s): 3e89f7a

Update src/visualization.py

Browse files
Files changed (1) hide show
  1. src/visualization.py +16 -30
src/visualization.py CHANGED
@@ -1,15 +1,3 @@
1
- import streamlit as st
2
- import json
3
- import networkx as nx
4
- import pandas as pd
5
- from typing import Dict, List, Any, Optional, Set, Tuple
6
- import plotly.graph_objects as go
7
- import plotly.express as px
8
- import matplotlib.pyplot as plt
9
- import matplotlib.colors as mcolors
10
- from collections import defaultdict
11
- import math
12
-
13
  def display_reasoning_trace(query: str, retrieved_docs: List[Dict], answer: str, ontology_manager):
14
  """Display an enhanced trace of how ontological reasoning was used to answer the query."""
15
  st.subheader("🧠 Ontology-Enhanced Reasoning")
@@ -376,26 +364,24 @@ def explain_ontology_advantages(entity_mentions: List[Dict], relationship_mentio
376
 
377
  return advantages# src/visualization.py
378
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  def render_html_in_streamlit(html_content: str):
380
- """Display HTML content in Streamlit using an iframe."""
381
- import base64
382
-
383
- # Encode the HTML content
384
- encoded_html = base64.b64encode(html_content.encode()).decode()
385
-
386
- # Create an iframe with the data URL
387
- iframe_html = f"""
388
- <iframe
389
- srcdoc="{encoded_html}"
390
- width="100%"
391
- height="600px"
392
- frameborder="0"
393
- allowfullscreen>
394
- </iframe>
395
- """
396
 
397
- # Display the iframe
398
- st.markdown(iframe_html, unsafe_allow_html=True)
399
 
400
 
401
  def display_ontology_stats(ontology_manager):
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  def display_reasoning_trace(query: str, retrieved_docs: List[Dict], answer: str, ontology_manager):
2
  """Display an enhanced trace of how ontological reasoning was used to answer the query."""
3
  st.subheader("🧠 Ontology-Enhanced Reasoning")
 
364
 
365
  return advantages# src/visualization.py
366
 
367
+ import streamlit as st
368
+ import json
369
+ import networkx as nx
370
+ import pandas as pd
371
+ from typing import Dict, List, Any, Optional, Set, Tuple
372
+ import plotly.graph_objects as go
373
+ import plotly.express as px
374
+ import matplotlib.pyplot as plt
375
+ import matplotlib.colors as mcolors
376
+ from collections import defaultdict
377
+ import math
378
+
379
  def render_html_in_streamlit(html_content: str):
380
+ """Display HTML content in Streamlit using components.html."""
381
+ import streamlit.components.v1 as components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
 
383
+ # Directly render the HTML using components.html
384
+ components.html(html_content, height=600, scrolling=True)
385
 
386
 
387
  def display_ontology_stats(ontology_manager):