Polo123's picture
Update app.py
2878a9e verified
raw
history blame
1.52 kB
import streamlit as st
import streamlit.components.v1 as components # Import Streamlit
from logic import *
token = st.text_input("Open-AI-api-key")
KG_name = st.text_input("Give Kuzu-KG name")
if (token != '' and KG_name != ""):
if(os.path.exists(KG_name)):
index = load_index(token,KG_name)
else:
with st.form("links_form"):
text = st.text_input("Input Links Seperated by ','")
submitted = st.form_submit_button("Submit")
if submitted:
links = text.split(",")
index = get_index(links,token,KG_name)
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 ','")
submitted = st.form_submit_button("Submit")
if submitted:
res = query_model(index,user_query)
st.write(res)