Spaces:
Sleeping
Sleeping
second commit for chat bot-1
Browse files
app.py
CHANGED
|
@@ -1,21 +1,46 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
# চ্যাটবট ফাংশন
|
| 8 |
def chat(input_text):
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
# Gradio ইন্টারফেস
|
| 13 |
interface = gr.Interface(
|
| 14 |
fn=chat,
|
| 15 |
inputs="text",
|
| 16 |
outputs="text",
|
| 17 |
-
title="
|
| 18 |
-
description="
|
| 19 |
)
|
| 20 |
|
| 21 |
# অ্যাপ রান করুন
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
# JSON ডেটা
|
| 4 |
+
data = {
|
| 5 |
+
"country": "Bangladesh",
|
| 6 |
+
"capital": "Dhaka",
|
| 7 |
+
"location": "South Asia",
|
| 8 |
+
"population": "166 million",
|
| 9 |
+
"official_language": "Bengali",
|
| 10 |
+
"currency": "Taka",
|
| 11 |
+
"landmarks": ["Sundarbans", "Cox's Bazar", "Dhaka's National Museum"],
|
| 12 |
+
"economy": "Textiles, agriculture, remittances"
|
| 13 |
+
}
|
| 14 |
|
| 15 |
+
# চ্যাটবট ফাংশন
|
| 16 |
def chat(input_text):
|
| 17 |
+
input_text = input_text.lower() # প্রশ্নটি ছোট হাতের অক্ষরে রূপান্তর করুন
|
| 18 |
+
if "country" in input_text:
|
| 19 |
+
return f"Country: {data['country']}"
|
| 20 |
+
elif "capital" in input_text:
|
| 21 |
+
return f"Capital: {data['capital']}"
|
| 22 |
+
elif "location" in input_text:
|
| 23 |
+
return f"Location: {data['location']}"
|
| 24 |
+
elif "population" in input_text:
|
| 25 |
+
return f"Population: {data['population']}"
|
| 26 |
+
elif "official language" in input_text:
|
| 27 |
+
return f"Official Language: {data['official_language']}"
|
| 28 |
+
elif "currency" in input_text:
|
| 29 |
+
return f"Currency: {data['currency']}"
|
| 30 |
+
elif "landmarks" in input_text:
|
| 31 |
+
return f"Landmarks: {', '.join(data['landmarks'])}"
|
| 32 |
+
elif "economy" in input_text:
|
| 33 |
+
return f"Economy: {data['economy']}"
|
| 34 |
+
else:
|
| 35 |
+
return "Sorry, I don't have information about that."
|
| 36 |
|
| 37 |
+
# Gradio ইন্টারফেস
|
| 38 |
interface = gr.Interface(
|
| 39 |
fn=chat,
|
| 40 |
inputs="text",
|
| 41 |
outputs="text",
|
| 42 |
+
title="Bangladesh Info Chatbot",
|
| 43 |
+
description="Ask me about Bangladesh!"
|
| 44 |
)
|
| 45 |
|
| 46 |
# অ্যাপ রান করুন
|