import gradio as gr from movie_recommender import MovieRecommender # Initialize the recommender recommender = MovieRecommender() def get_recommendations(vibe_query): """ This function takes a user's query, gets recommendations from the MovieRecommender, and returns them as a formatted string. """ if not vibe_query: return "Please enter a vibe or movie description." recommendations = recommender.recommend(vibe_query) printable_result = "" for i, result in enumerate(recommendations): printable_result += f"TOP {i+1} MOVIE: {result}\n\n" return printable_result # Create the Gradio interface iface = gr.Interface( fn=get_recommendations, inputs="text", outputs="text", title="🎬 Movie Recommender", description="Describe the kind of movie you're in the mood for, and I'll give you some recommendations based on the vibe.", examples=[ ["A heartwarming story about a talking animal who goes on an adventure."], ["A dark and gritty detective noir set in 1940s Los Angeles."], ["A mind-bending psychological thriller with an unreliable narrator."] ] ) if __name__ == "__main__": iface.launch()