import streamlit as st import faiss import pandas as pd from functions.loader import data, index from functions.logic import load_image, find_similar_shows st.title('TV Show Recommender') # User input for the show description user_description = st.text_area("Describe the TV show you're looking for:") # Slider for the number of recommendations num_recommendations = st.slider('Number of recommendations:', min_value=1, max_value=10, value=5) # Button to get recommendations if st.button('Recommend') and user_description: try: recommended_shows = find_similar_shows(user_description, index, num_recommendations) for idx in recommended_shows.index: with st.container(): link = data.loc[idx, 'url'] poster_url = data.loc[idx, 'img'] title = data.loc[idx, 'title'] description = data.loc[idx, 'description'] img = load_image(poster_url) # Use the load_image function col1, col2 = st.columns([1, 2]) with col1: st.image(img, caption=title, use_column_width='always') with col2: st.write(description) st.markdown(f"[More Info]({link})", unsafe_allow_html=True) except Exception as e: st.error(f"An error occurred: {e}")