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