Upload 7 files
Browse files- .huggingface.yaml +2 -0
- README.md +7 -12
- app.py +29 -0
- country_info.py +11 -0
- gemini_client.py +17 -0
- requirements.txt +2 -0
- utils.py +1 -0
.huggingface.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sdk: gradio
|
| 2 |
+
python_version: 3.10
|
README.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
-
|
| 2 |
-
title: AI Tour
|
| 3 |
-
emoji: 💻
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 5.38.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🌍 AI Tour Guide
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
This Hugging Face Space uses Gemini 2.5 Flash to describe any country in English and translate the result to Bengali. It also displays basic country info using the RESTCountries API.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
- Country description via Gemini
|
| 7 |
+
- Bengali translation via Gemini
|
| 8 |
+
- Country flag, capital, and population
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gemini_client import ask_gemini, translate_to_bangla
|
| 3 |
+
from country_info import get_country_info
|
| 4 |
+
|
| 5 |
+
def ai_tour_guide(country_name):
|
| 6 |
+
english_text = ask_gemini(f"Tell me about {country_name}")
|
| 7 |
+
bangla_text = translate_to_bangla(english_text)
|
| 8 |
+
info = get_country_info(country_name)
|
| 9 |
+
|
| 10 |
+
return (
|
| 11 |
+
english_text,
|
| 12 |
+
bangla_text,
|
| 13 |
+
info['flag'],
|
| 14 |
+
f"Capital: {info['capital']}, Population: {info['population']}"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
with gr.Blocks() as demo:
|
| 18 |
+
gr.Markdown("## 🌍 AI Tour Guide (English ➡️ Bangla)")
|
| 19 |
+
country = gr.Textbox(label="Enter a country name")
|
| 20 |
+
btn = gr.Button("Explore")
|
| 21 |
+
|
| 22 |
+
out_en = gr.Textbox(label="🇬🇧 Description (English)")
|
| 23 |
+
out_bn = gr.Textbox(label="🇧🇩 Description (Bengali)")
|
| 24 |
+
flag = gr.Image(label="🏳️ Flag")
|
| 25 |
+
stats = gr.Textbox(label="🗺️ Quick Facts")
|
| 26 |
+
|
| 27 |
+
btn.click(fn=ai_tour_guide, inputs=country, outputs=[out_en, out_bn, flag, stats])
|
| 28 |
+
|
| 29 |
+
demo.launch()
|
country_info.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
def get_country_info(name):
|
| 4 |
+
url = f"https://restcountries.com/v3.1/name/{name}"
|
| 5 |
+
res = requests.get(url)
|
| 6 |
+
data = res.json()[0]
|
| 7 |
+
return {
|
| 8 |
+
"flag": data['flags']['png'],
|
| 9 |
+
"capital": data['capital'][0],
|
| 10 |
+
"population": data['population']
|
| 11 |
+
}
|
gemini_client.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
from kaggle_secrets import UserSecretsClient
|
| 3 |
+
|
| 4 |
+
user_secrets = UserSecretsClient()
|
| 5 |
+
API_KEY = user_secrets.get_secret("GEMINI_KEY")
|
| 6 |
+
|
| 7 |
+
URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key={API_KEY}"
|
| 8 |
+
HEADERS = {"Content-Type": "application/json"}
|
| 9 |
+
|
| 10 |
+
def ask_gemini(prompt):
|
| 11 |
+
payload = {"contents": [{"parts": [{"text": prompt}]}]}
|
| 12 |
+
res = requests.post(URL, headers=HEADERS, json=payload)
|
| 13 |
+
return res.json()['candidates'][0]['content']['parts'][0]['text']
|
| 14 |
+
|
| 15 |
+
def translate_to_bangla(english_text):
|
| 16 |
+
prompt = f"Translate this to Bengali:\n\n{english_text}"
|
| 17 |
+
return ask_gemini(prompt)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
requests
|
utils.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Currently no helpers needed, placeholder for future features.
|