import gradio as gr def movie_suggestion(genre): movies = { "action": [ {"title": "Mad Max: Fury Road", "description": "A high-octane post-apocalyptic thriller. ๐Ÿš—๐Ÿ’ฅ"}, {"title": "John Wick", "description": "A retired hitman seeks vengeance. ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ”ซ"}, {"title": "Die Hard", "description": "An NYPD officer tries to save his wife and others taken hostage by terrorists. ๐Ÿš“๐Ÿงจ"} ], "comedy": [ {"title": "The Grand Budapest Hotel", "description": "A quirky comedy set in a famous European hotel. ๐Ÿจ๐Ÿ˜‚"}, {"title": "Superbad", "description": "Two friends try to make the most of their last days of high school. ๐ŸŽ“๐Ÿคฃ"}, {"title": "Step Brothers", "description": "Two middle-aged men become step brothers and cause chaos. ๐Ÿ‘จโ€๐Ÿฆฑ๐Ÿ‘จโ€๐Ÿฆฐ๐Ÿคช"} ], "drama": [ {"title": "The Pursuit of Happyness", "description": "A man's struggle with homelessness while raising his son. ๐Ÿ‘จโ€๐Ÿ‘ฆ๐Ÿ˜ข"}, {"title": "Forrest Gump", "description": "The story of a man's extraordinary life. ๐Ÿƒโ€โ™‚๏ธ๐ŸŽ–๏ธ"}, {"title": "The Shawshank Redemption", "description": "A man imprisoned for a crime he didn't commit forms a friendship with a fellow inmate. ๐Ÿš”๐Ÿค"} ], "sci-fi": [ {"title": "Dune", "description": "A young man faces his destiny on a desert planet. ๐Ÿœ๏ธ๐Ÿ‘จโ€๐Ÿš€"}, {"title": "Blade Runner 2049", "description": "A futuristic detective uncovers secrets about human existence. ๐Ÿค–๐Ÿ”"}, {"title": "Interstellar", "description": "A team of explorers travel through a wormhole in space. ๐ŸŒŒ๐Ÿš€"} ] } if genre.lower() in movies: genre_movies = movies[genre.lower()] suggestions = "Here are some movie suggestions based on your selected genre:\n\n" for movie in genre_movies: suggestions += f"**{movie['title']}**: {movie['description']}\n\n" return suggestions else: return "Sorry, we don't have suggestions for that genre yet!" interface = gr.Interface( fn=movie_suggestion, inputs=gr.Dropdown(["Action", "Comedy", "Drama", "Sci-Fi"], label="Choose a genre"), outputs=gr.Markdown(), title="Movie Suggestions", description="Choose your preferred genre to receive a list of recommended movies." ) interface.launch()