Sefat33's picture
Update app.py
eb42d00 verified
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()