|
import streamlit as st |
|
import streamlit.components.v1 as components |
|
from logic import * |
|
import os |
|
|
|
token = st.text_input("Open-AI-api-key") |
|
base_url = st.text_input("Open-AI-api-base_url") |
|
|
|
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("KG name") |
|
sub = st.form_submit_button("Submit") |
|
if sub: |
|
save_uploadedfile(uploaded_file) |
|
index = get_index_pdf(token, KG_name, base_url) |
|
|
|
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("KG name") |
|
submitted = st.form_submit_button("Submit") |
|
if submitted: |
|
links = text.split(",") |
|
index = get_index(links, token, KG_name, base_url) |
|
|
|
elif(input_text == "No_Input(Already Created)"): |
|
st.subheader("NO INPUT") |
|
KG_name = st.text_input(" KG name") |
|
if(os.path.exists(KG_name)): |
|
index = load_index(token, KG_name, base_url) |
|
else: |
|
st.write("NO FOLDER BY NAME") |
|
|
|
|
|
if (index != None): |
|
get_network_graph(index) |
|
emb = get_embeddings(index) |
|
fig = get_visualize_embeddings(emb) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
st.plotly_chart(fig, use_container_width=True) |
|
|
|
|
|
HtmlFile = open("kuzugraph_draw3.html", 'r', encoding='utf-8') |
|
|
|
with open("kuzugraph_draw3.html", 'r', encoding='utf-8') as HtmlFile: |
|
source_code = HtmlFile.read() |
|
|
|
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) |