import streamlit as st
from logic2 import *
import streamlit.components.v1 as components

st.title('PyG - Movie Recommendation')
st.image('Image_graph.png', caption='Bi-Partite Graph')

st.write('Scatter Plot of embeddings')

HtmlFile = open("plot.html", 'r', encoding='utf-8')
source_code = HtmlFile.read() 
components.html(source_code, width=500, height=500)

# load Hgraph
global data
st.write('Loading Data')
data = load_hetero_data()

# Load Model
st.write('Loading Model')
model = load_model(data)

#get user_id
user_id = st.number_input('Give User-Id')
user_id = int(round(user_id))

# get recommendation and graph

make_1_hop_graph(data,user_id)
HtmlFile1 = open('index.html', 'r', encoding='utf-8')
source_code1 = HtmlFile1.read() 
components.html(source_code1, height=1200, width=1000)

ans = get_recommendation(model,data,user_id)
st.write(ans)