Polo123 commited on
Commit
1c29888
1 Parent(s): 2878a9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -8,6 +8,7 @@ KG_name = st.text_input("Give Kuzu-KG name")
8
 
9
 
10
  if (token != '' and KG_name != ""):
 
11
  if(os.path.exists(KG_name)):
12
  index = load_index(token,KG_name)
13
  else:
@@ -19,28 +20,28 @@ if (token != '' and KG_name != ""):
19
  links = text.split(",")
20
  index = get_index(links,token,KG_name)
21
 
 
 
 
 
22
 
23
- get_network_graph(index)
24
- emb = get_embeddings(index)
25
- fig = get_visualize_embeddings(emb)
26
-
27
- # Plotly Chart
28
- st.plotly_chart(fig, use_container_width=True)
29
-
30
- # Render the h1 block, contained in a frame of size 200x200.
31
- HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8')
32
- # Read the HTML file
33
- with open("kuzugraph_draw3.html", 'r', encoding='utf-8') as HtmlFile:
34
- source_code = HtmlFile.read()
35
- # st.markdown(f'<div style="width: 800px; height: 600px">{source_code}</div>', unsafe_allow_html=True)
36
- components.html(source_code,width=800, height=600, scrolling=False)
37
-
38
- with st.form("my_form"):
39
- user_query = st.text_input("Ask the KG ','")
40
-
41
- submitted = st.form_submit_button("Submit")
42
- if submitted:
43
- res = query_model(index,user_query)
44
- st.write(res)
45
 
46
 
 
8
 
9
 
10
  if (token != '' and KG_name != ""):
11
+ index = None
12
  if(os.path.exists(KG_name)):
13
  index = load_index(token,KG_name)
14
  else:
 
20
  links = text.split(",")
21
  index = get_index(links,token,KG_name)
22
 
23
+ if (index != None):
24
+ get_network_graph(index)
25
+ emb = get_embeddings(index)
26
+ fig = get_visualize_embeddings(emb)
27
 
28
+ # Plotly Chart
29
+ st.plotly_chart(fig, use_container_width=True)
30
+
31
+ # Render the h1 block, contained in a frame of size 200x200.
32
+ HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8')
33
+ # Read the HTML file
34
+ with open("kuzugraph_draw3.html", 'r', encoding='utf-8') as HtmlFile:
35
+ source_code = HtmlFile.read()
36
+ # st.markdown(f'<div style="width: 800px; height: 600px">{source_code}</div>', unsafe_allow_html=True)
37
+ components.html(source_code,width=800, height=600, scrolling=False)
38
+
39
+ with st.form("my_form"):
40
+ user_query = st.text_input("Ask the KG ','")
41
+
42
+ submitted = st.form_submit_button("Submit")
43
+ if submitted:
44
+ res = query_model(index,user_query)
45
+ st.write(res)
 
 
 
 
46
 
47