Awlly/TVShowRecommender
0
1import streamlit as st2import faiss3import pandas as pd4from functions.loader import data, index5from functions.logic import load_image, find_similar_shows6 7 8 9st.title('TV Show Recommender')10 11# User input for the show description12user_description = st.text_area("Describe the TV show you're looking for:")13 14# Slider for the number of recommendations15num_recommendations = st.slider('Number of recommendations:', min_value=1, max_value=10, value=5)16 17# Button to get recommendations18if st.button('Recommend') and user_description:19 try:20 recommended_shows = find_similar_shows(user_description, index, num_recommendations)21 22 for idx in recommended_shows.index:23 with st.container():24 link = data.loc[idx, 'url']25 poster_url = data.loc[idx, 'img']26 title = data.loc[idx, 'title']27 description = data.loc[idx, 'description']28 29 img = load_image(poster_url) # Use the load_image function30 31 col1, col2 = st.columns([1, 2])32 with col1:33 st.image(img, caption=title, use_column_width='always')34 with col2:35 st.write(description)36 st.markdown(f"[More Info]({link})", unsafe_allow_html=True)37 38 except Exception as e:39 st.error(f"An error occurred: {e}")40 