Polo123 commited on
Commit
74cb18d
1 Parent(s): beaea9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -11
app.py CHANGED
@@ -1,22 +1,42 @@
1
  import streamlit as st
2
  import streamlit.components.v1 as components # Import Streamlit
 
3
 
4
- from logic import get_index,get_network_graph,get_embeddings,get_visualize_embeddings
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- token = st.text_input("Open-AI-api-key-3.5-GPT")
7
- if (token != ''):
8
- text = st.text_input("Input Links Seperated by ','")
9
- links = text.split(",")
10
-
11
- index = get_index(links,token)
12
  get_network_graph(index)
13
  emb = get_embeddings(index)
14
  fig = get_visualize_embeddings(emb)
15
-
16
  # Plotly Chart
17
  st.plotly_chart(fig, use_container_width=True)
18
-
19
  # Render the h1 block, contained in a frame of size 200x200.
20
  HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8')
21
- source_code = HtmlFile.read()
22
- components.html(source_code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components # Import Streamlit
3
+ from logic import *
4
 
5
+ token = st.text_input("Open-AI-api-key")
6
+
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:
14
+ text = st.text_input("Input Links Seperated by ','")
15
+ if(text != ""):
16
+ links = text.split(",")
17
+ index = get_index(links,token,KG_name)
18
 
 
 
 
 
 
 
19
  get_network_graph(index)
20
  emb = get_embeddings(index)
21
  fig = get_visualize_embeddings(emb)
22
+
23
  # Plotly Chart
24
  st.plotly_chart(fig, use_container_width=True)
25
+
26
  # Render the h1 block, contained in a frame of size 200x200.
27
  HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8')
28
+ # Read the HTML file
29
+ with open("kuzugraph_draw3.html", 'r', encoding='utf-8') as HtmlFile:
30
+ source_code = HtmlFile.read()
31
+ # st.markdown(f'<div style="width: 800px; height: 600px">{source_code}</div>', unsafe_allow_html=True)
32
+ components.html(source_code,width=800, height=600, scrolling=False)
33
+
34
+ with st.form("my_form"):
35
+ user_query = st.text_input("Ask the KG ','")
36
+
37
+ submitted = st.form_submit_button("Submit")
38
+ if submitted:
39
+ res = query_model(index,user_query)
40
+ st.write(res)
41
+
42
+