Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,44 +4,60 @@ 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 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
if(os.path.exists(KG_name)):
|
| 13 |
index = load_index(token,KG_name)
|
| 14 |
else:
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
if (index != None):
|
| 24 |
-
get_network_graph(index)
|
| 25 |
-
emb = get_embeddings(index)
|
| 26 |
-
fig = get_visualize_embeddings(emb)
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 4 |
|
| 5 |
token = st.text_input("Open-AI-api-key")
|
| 6 |
|
|
|
|
| 7 |
|
| 8 |
+
input_text = st.radio(
|
| 9 |
+
"Input Options for text",
|
| 10 |
+
["PDF", "Links","No_Input(Already Created)"])
|
| 11 |
+
index = None
|
| 12 |
+
if(input_text == "PDF"):
|
| 13 |
+
st.subheader("PDF")
|
| 14 |
+
with st.form("PDF_form"):
|
| 15 |
+
uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
|
| 16 |
+
KG_name = st.text_input("Give Kuzu-KG name")
|
| 17 |
+
sub = st.form_submit_button("Submit")
|
| 18 |
+
if sub:
|
| 19 |
+
save_uploadedfile(uploaded_file)
|
| 20 |
+
index = get_index_pdf(token,KG_name)
|
| 21 |
+
|
| 22 |
+
elif(input_text == "Links"):
|
| 23 |
+
st.subheader("LINKS")
|
| 24 |
+
with st.form("links_form"):
|
| 25 |
+
text = st.text_input("Input Links Seperated by ','")
|
| 26 |
+
KG_name = st.text_input("Give Kuzu-KG name")
|
| 27 |
+
submitted = st.form_submit_button("Submit")
|
| 28 |
+
if submitted:
|
| 29 |
+
links = text.split(",")
|
| 30 |
+
index = get_index(links,token,KG_name)
|
| 31 |
+
|
| 32 |
+
elif(input_text == "No_Input(Already Created)"):
|
| 33 |
+
st.subheader("NO INPUT")
|
| 34 |
+
KG_name = st.text_input("Give Kuzu-KG name")
|
| 35 |
if(os.path.exists(KG_name)):
|
| 36 |
index = load_index(token,KG_name)
|
| 37 |
else:
|
| 38 |
+
st.write("NO FOLDER BY NAME")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if (index != None):
|
| 42 |
+
get_network_graph(index)
|
| 43 |
+
emb = get_embeddings(index)
|
| 44 |
+
fig = get_visualize_embeddings(emb)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
# Plotly Chart
|
| 47 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 48 |
|
| 49 |
+
# Render the h1 block, contained in a frame of size 200x200.
|
| 50 |
+
HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8')
|
| 51 |
+
# Read the HTML file
|
| 52 |
+
with open("kuzugraph_draw3.html", 'r', encoding='utf-8') as HtmlFile:
|
| 53 |
+
source_code = HtmlFile.read()
|
| 54 |
+
# st.markdown(f'<div style="width: 800px; height: 600px">{source_code}</div>', unsafe_allow_html=True)
|
| 55 |
+
components.html(source_code,width=800, height=600, scrolling=False)
|
| 56 |
|
| 57 |
+
with st.form("my_form"):
|
| 58 |
+
user_query = st.text_input("Ask the KG ','")
|
| 59 |
|
| 60 |
+
new_submitted = st.form_submit_button("Submit")
|
| 61 |
+
if new_submitted:
|
| 62 |
+
res = query_model(index,user_query)
|
| 63 |
+
st.write(res)
|
|
|
|
|
|