Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from utils import get_country_info, generate_description, translate_to_bangla | |
| def ai_tour_guide(country_name): | |
| if not country_name.strip(): | |
| return "β οΈ Please enter a country name.", "", "" | |
| # 1. Get English description from GPT-2 | |
| english_desc = generate_description(country_name) | |
| # 2. Translate to Bangla | |
| bangla_desc = translate_to_bangla(english_desc) | |
| # 3. Get country info | |
| info = get_country_info(country_name) | |
| if "error" in info: | |
| info_text = info["error"] | |
| else: | |
| info_text = "\n".join([f"**{k}:** {v}" for k, v in info.items()]) | |
| return english_desc, bangla_desc, info_text | |
| # Gradio UI | |
| demo = gr.Interface( | |
| fn=ai_tour_guide, | |
| inputs=gr.Textbox(label="π Enter a country name", placeholder="e.g., Japan"), | |
| outputs=[ | |
| gr.Textbox(label="π English Description"), | |
| gr.Textbox(label="π Bangla Translation"), | |
| gr.Markdown(label="π Country Facts") | |
| ], | |
| title="π§ AI Tour Guide", | |
| description="Enter any country to get an AI-generated description, Bangla translation, and facts.", | |
| flagging_mode="never" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |