File size: 1,636 Bytes
2b8f617
 
74cb18d
2b8f617
74cb18d
 
 
 
 
 
1c29888
74cb18d
 
 
2878a9e
 
 
 
 
 
 
 
1c29888
 
 
 
2878a9e
1c29888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74cb18d
 
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
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 != ""):
    index = None
    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)
        
    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 ','")
              
            submitted = st.form_submit_button("Submit")
            if submitted:
                res = query_model(index,user_query)
                st.write(res)