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") make_dir() 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'
{source_code}
', 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)