RaghavenderReddy commited on
Commit
46719fa
Β·
verified Β·
1 Parent(s): dc9d346

Upload 5 files

Browse files
Files changed (5) hide show
  1. .gitignore +31 -0
  2. README.md +80 -20
  3. app.py +573 -0
  4. config.toml +10 -0
  5. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ develop-eggs/
8
+ dist/
9
+ downloads/
10
+ eggs/
11
+ .eggs/
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ wheels/
18
+ *.egg-info/
19
+ .installed.cfg
20
+ *.egg
21
+ MANIFEST
22
+
23
+ .env
24
+ .venv
25
+ env/
26
+ venv/
27
+ ENV/
28
+ env.bak/
29
+ venv.bak/
30
+
31
+ .streamlit/secrets.toml
README.md CHANGED
@@ -1,20 +1,80 @@
1
- ---
2
- title: ' Culture Bot '
3
- emoji: πŸš€
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Streamlit template space
12
- license: mit
13
- ---
14
-
15
- # Welcome to Streamlit!
16
-
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
-
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: CultureBot
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: streamlit
7
+ sdk_version: 1.45.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # CultureBot 🌍
14
+
15
+ CultureBot is an AI-powered Streamlit application that helps users learn about world cultures through interactive conversations and curated cultural facts.
16
+
17
+ ## Features
18
+
19
+ - **AI-Powered Chat**: Ask questions about any culture or country and get intelligent responses
20
+ - **Cultural Facts Database**: Browse curated cultural insights from around the world
21
+ - **Interactive Interface**: Beautiful, responsive design with multiple pages
22
+ - **Global Coverage**: Information about customs, traditions, and practices from various countries
23
+
24
+ ## How to Use
25
+
26
+ 1. **Home Page**: Get an overview of CultureBot's features
27
+ 2. **Chat**: Interact with the AI assistant about cultural topics
28
+ 3. **Cultural Facts**: Browse facts by country or category
29
+ 4. **About**: Learn more about the application and its mission
30
+
31
+ ## Setup for Local Development
32
+
33
+ 1. Clone this repository
34
+ 2. Install dependencies: `pip install -r requirements.txt`
35
+ 3. Set up your OpenAI API key:
36
+ - Create a `.streamlit/secrets.toml` file
37
+ - Add your API key: `openai_api_key = "your-api-key-here"`
38
+ 4. Run the app: `streamlit run app.py`
39
+
40
+ ## Deployment on Hugging Face Spaces
41
+
42
+ This application is optimized for deployment on Hugging Face Spaces. To deploy:
43
+
44
+ 1. Create a new Space on Hugging Face
45
+ 2. Choose Streamlit as the SDK
46
+ 3. Upload the files from this repository
47
+ 4. Add your OpenAI API key in the Space settings under "Repository secrets"
48
+ - Key: `OPENAI_API_KEY`
49
+ - Value: Your OpenAI API key
50
+
51
+ ## Technologies Used
52
+
53
+ - **Streamlit**: Web application framework
54
+ - **OpenAI GPT-3.5**: AI language model for intelligent responses
55
+ - **Python**: Programming language
56
+ - **Hugging Face Spaces**: Deployment platform
57
+
58
+ ## Cultural Coverage
59
+
60
+ The application includes cultural facts and insights from:
61
+ - Japan
62
+ - India
63
+ - Brazil
64
+ - Germany
65
+ - China
66
+ - France
67
+ - South Korea
68
+ - Mexico
69
+ - Egypt
70
+ - Russia
71
+ - Thailand
72
+ - Italy
73
+
74
+ ## Contributing
75
+
76
+ We welcome contributions to expand our cultural database and improve the application. Please feel free to submit issues or pull requests.
77
+
78
+ ## License
79
+
80
+ This project is licensed under the MIT License.
app.py ADDED
@@ -0,0 +1,573 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import json
4
+ import random
5
+ from typing import Dict, List, Any
6
+ from datetime import datetime
7
+
8
+ # Page configuration
9
+ st.set_page_config(
10
+ page_title="CultureBot - Your AI Cultural Guide",
11
+ page_icon="🌍",
12
+ layout="wide",
13
+ initial_sidebar_state="expanded"
14
+ )
15
+
16
+ # Cultural Database Class
17
+ class CulturalDatabase:
18
+ def __init__(self):
19
+ self.cultural_facts = [
20
+ {
21
+ "country": "Japan",
22
+ "fact": "In Japan, it's considered rude to blow your nose in public. People excuse themselves to do it privately.",
23
+ "category": "etiquette",
24
+ "source": "Japanese Cultural Studies"
25
+ },
26
+ {
27
+ "country": "Japan",
28
+ "fact": "Japanese business cards (meishi) are exchanged with both hands and should be received with respect and careful examination.",
29
+ "category": "business",
30
+ "source": "Japanese Business Etiquette Guide"
31
+ },
32
+ {
33
+ "country": "India",
34
+ "fact": "India has 22 official languages and over 1,600 spoken languages, making it one of the most linguistically diverse countries.",
35
+ "category": "language",
36
+ "source": "Indian Linguistic Survey"
37
+ },
38
+ {
39
+ "country": "India",
40
+ "fact": "In Indian culture, touching someone's feet is a sign of respect, especially for elders and teachers.",
41
+ "category": "greeting",
42
+ "source": "Indian Cultural Traditions"
43
+ },
44
+ {
45
+ "country": "Brazil",
46
+ "fact": "Brazilians typically hug and kiss on the cheek when greeting, even in business settings.",
47
+ "category": "greeting",
48
+ "source": "Brazilian Social Customs"
49
+ },
50
+ {
51
+ "country": "Brazil",
52
+ "fact": "In Brazil, the 'OK' hand gesture is considered offensive, similar to giving someone the middle finger.",
53
+ "category": "etiquette",
54
+ "source": "Brazilian Cultural Guide"
55
+ },
56
+ {
57
+ "country": "Germany",
58
+ "fact": "Germans value punctuality so much that being late is considered very disrespectful, even by a few minutes.",
59
+ "category": "business",
60
+ "source": "German Business Culture"
61
+ },
62
+ {
63
+ "country": "Germany",
64
+ "fact": "In Germany, it's customary to maintain eye contact during toasts and say 'Prost' or 'Zum Wohl'.",
65
+ "category": "food",
66
+ "source": "German Dining Etiquette"
67
+ },
68
+ {
69
+ "country": "China",
70
+ "fact": "In Chinese culture, the number 8 is considered extremely lucky because it sounds like the word for 'prosperity'.",
71
+ "category": "beliefs",
72
+ "source": "Chinese Numerology Studies"
73
+ },
74
+ {
75
+ "country": "China",
76
+ "fact": "When receiving a business card in China, accept it with both hands and take a moment to read it carefully.",
77
+ "category": "business",
78
+ "source": "Chinese Business Etiquette"
79
+ },
80
+ {
81
+ "country": "France",
82
+ "fact": "French people typically don't eat meals while walking or standing - dining is seen as a social ritual to be savored.",
83
+ "category": "food",
84
+ "source": "French Culinary Culture"
85
+ },
86
+ {
87
+ "country": "France",
88
+ "fact": "In France, it's polite to greet shopkeepers with 'Bonjour' when entering and 'Au revoir' when leaving.",
89
+ "category": "etiquette",
90
+ "source": "French Social Customs"
91
+ },
92
+ {
93
+ "country": "South Korea",
94
+ "fact": "In Korea, you should use both hands when giving or receiving business cards as a sign of respect.",
95
+ "category": "business",
96
+ "source": "Korean Business Protocol"
97
+ },
98
+ {
99
+ "country": "South Korea",
100
+ "fact": "Korean age calculation includes the time spent in the womb, so Koreans are typically 1-2 years older in 'Korean age'.",
101
+ "category": "general",
102
+ "source": "Korean Cultural Practices"
103
+ },
104
+ {
105
+ "country": "Mexico",
106
+ "fact": "Mexican families often have multiple generations living together, and family loyalty is highly valued.",
107
+ "category": "family",
108
+ "source": "Mexican Family Structures"
109
+ },
110
+ {
111
+ "country": "Mexico",
112
+ "fact": "In Mexico, personal space is smaller than in many Western cultures, and people stand closer during conversations.",
113
+ "category": "etiquette",
114
+ "source": "Mexican Social Norms"
115
+ },
116
+ {
117
+ "country": "Egypt",
118
+ "fact": "In Egypt, showing the sole of your foot to someone is considered offensive, so keep feet flat on the ground when sitting.",
119
+ "category": "etiquette",
120
+ "source": "Egyptian Cultural Guidelines"
121
+ },
122
+ {
123
+ "country": "Egypt",
124
+ "fact": "Egyptian hospitality is legendary - guests are often offered tea or coffee multiple times as a sign of welcome.",
125
+ "category": "food",
126
+ "source": "Egyptian Hospitality Traditions"
127
+ },
128
+ {
129
+ "country": "Russia",
130
+ "fact": "Russians believe that smiling without reason is insincere, so don't be surprised by serious expressions in public.",
131
+ "category": "expression",
132
+ "source": "Russian Social Behavior"
133
+ },
134
+ {
135
+ "country": "Russia",
136
+ "fact": "In Russia, it's traditional to remove shoes when entering someone's home, and slippers are often provided for guests.",
137
+ "category": "etiquette",
138
+ "source": "Russian Home Customs"
139
+ },
140
+ {
141
+ "country": "Thailand",
142
+ "fact": "In Thailand, the head is considered sacred, so never touch someone's head, even children.",
143
+ "category": "etiquette",
144
+ "source": "Thai Cultural Sensitivities"
145
+ },
146
+ {
147
+ "country": "Thailand",
148
+ "fact": "Thai people use the 'wai' greeting - pressing palms together and bowing slightly - as a sign of respect.",
149
+ "category": "greeting",
150
+ "source": "Thai Greeting Customs"
151
+ },
152
+ {
153
+ "country": "Italy",
154
+ "fact": "In Italy, cappuccino is traditionally only drunk in the morning, never after meals.",
155
+ "category": "food",
156
+ "source": "Italian Coffee Culture"
157
+ },
158
+ {
159
+ "country": "Italy",
160
+ "fact": "Italians often speak with their hands, and gestures are an integral part of communication.",
161
+ "category": "language",
162
+ "source": "Italian Communication Styles"
163
+ }
164
+ ]
165
+
166
+ def search_facts(self, query: str) -> List[Dict[str, Any]]:
167
+ """Search for relevant cultural facts based on query"""
168
+ query_lower = query.lower()
169
+ relevant_facts = []
170
+
171
+ # Search by country
172
+ for fact in self.cultural_facts:
173
+ if fact['country'].lower() in query_lower:
174
+ relevant_facts.append(fact)
175
+
176
+ # Search by category
177
+ if not relevant_facts:
178
+ for fact in self.cultural_facts:
179
+ if fact['category'].lower() in query_lower:
180
+ relevant_facts.append(fact)
181
+
182
+ # Search by keywords in fact content
183
+ if not relevant_facts:
184
+ keywords = query_lower.split()
185
+ for fact in self.cultural_facts:
186
+ fact_text = fact['fact'].lower()
187
+ if any(keyword in fact_text for keyword in keywords):
188
+ relevant_facts.append(fact)
189
+
190
+ return relevant_facts[:5]
191
+
192
+ def get_random_fact(self) -> Dict[str, Any]:
193
+ """Get a random cultural fact"""
194
+ return random.choice(self.cultural_facts)
195
+
196
+ def get_facts_by_country(self, country: str) -> List[Dict[str, Any]]:
197
+ """Get all facts for a specific country"""
198
+ return [fact for fact in self.cultural_facts if fact['country'].lower() == country.lower()]
199
+
200
+ def get_facts_by_category(self, category: str) -> List[Dict[str, Any]]:
201
+ """Get all facts for a specific category"""
202
+ return [fact for fact in self.cultural_facts if fact['category'].lower() == category.lower()]
203
+
204
+ def get_all_countries(self) -> List[str]:
205
+ """Get list of all countries in the database"""
206
+ return list(set(fact['country'] for fact in self.cultural_facts))
207
+
208
+ def get_all_categories(self) -> List[str]:
209
+ """Get list of all categories in the database"""
210
+ return list(set(fact['category'] for fact in self.cultural_facts))
211
+
212
+ # Simple AI Response Generator (without OpenAI dependency)
213
+ class CultureAI:
214
+ def __init__(self):
215
+ self.cultural_db = CulturalDatabase()
216
+
217
+ def generate_response(self, user_message: str) -> Dict[str, Any]:
218
+ """Generate response based on cultural database"""
219
+ # Get relevant cultural facts from database
220
+ relevant_facts = self.cultural_db.search_facts(user_message)
221
+
222
+ if relevant_facts:
223
+ # Use the most relevant fact
224
+ fact = relevant_facts[0]
225
+
226
+ # Generate contextual response
227
+ if "greeting" in user_message.lower():
228
+ response = f"Regarding greetings in {fact['country']}: {fact['fact']} This reflects the cultural values of respect and social harmony that are important in {fact['country']}."
229
+ elif "business" in user_message.lower():
230
+ response = f"For business practices in {fact['country']}: {fact['fact']} Understanding these customs is crucial for successful professional relationships."
231
+ elif "food" in user_message.lower() or "dining" in user_message.lower():
232
+ response = f"About dining culture in {fact['country']}: {fact['fact']} Food customs often reflect deeper cultural values and social structures."
233
+ else:
234
+ response = f"Here's an important cultural insight about {fact['country']}: {fact['fact']} This practice is rooted in the cultural values and traditions of the region."
235
+
236
+ # Add additional context if multiple facts are available
237
+ if len(relevant_facts) > 1:
238
+ response += f"\n\nAdditionally, it's worth noting that cultural practices can vary within {fact['country']}, and these customs may differ between regions or generations."
239
+ else:
240
+ # Fallback response
241
+ random_fact = self.cultural_db.get_random_fact()
242
+ response = f"While I don't have specific information about that topic, here's an interesting cultural fact about {random_fact['country']}: {random_fact['fact']} Feel free to ask about specific countries or cultural practices!"
243
+
244
+ return {
245
+ "response": response,
246
+ "confidence": 0.8 if relevant_facts else 0.6,
247
+ "sources": [fact['source'] for fact in relevant_facts[:3]] if relevant_facts else ["Cultural Database"],
248
+ "category": relevant_facts[0]['category'] if relevant_facts else "general"
249
+ }
250
+
251
+ # Initialize components
252
+ @st.cache_resource
253
+ def initialize_components():
254
+ return CultureAI(), CulturalDatabase()
255
+
256
+ culture_ai, cultural_db = initialize_components()
257
+
258
+ # Custom CSS for beautiful styling
259
+ st.markdown("""
260
+ <style>
261
+ .main-header {
262
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
263
+ padding: 2rem;
264
+ border-radius: 10px;
265
+ color: white;
266
+ text-align: center;
267
+ margin-bottom: 2rem;
268
+ }
269
+
270
+ .sidebar-info {
271
+ background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
272
+ padding: 1.5rem;
273
+ border-radius: 10px;
274
+ color: white;
275
+ margin-bottom: 1rem;
276
+ }
277
+
278
+ .chat-message {
279
+ padding: 1rem;
280
+ border-radius: 10px;
281
+ margin: 0.5rem 0;
282
+ }
283
+
284
+ .user-message {
285
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
286
+ color: white;
287
+ margin-left: 2rem;
288
+ }
289
+
290
+ .bot-message {
291
+ background: #f8f9fa;
292
+ color: #333;
293
+ border-left: 4px solid #667eea;
294
+ margin-right: 2rem;
295
+ }
296
+
297
+ .fact-card {
298
+ background: linear-gradient(135deg, #ffd3a5 0%, #fd6585 100%);
299
+ color: black;
300
+ padding: 1.5rem;
301
+ border-radius: 10px;
302
+ margin: 1rem 0;
303
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
304
+ }
305
+
306
+ .metric-card {
307
+ background: white;
308
+ color: black;
309
+ padding: 1rem;
310
+ border-radius: 8px;
311
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
312
+ text-align: center;
313
+ }
314
+ </style>
315
+ """, unsafe_allow_html=True)
316
+
317
+ # Sidebar with app information
318
+ with st.sidebar:
319
+ st.markdown("""
320
+ <div class="sidebar-info">
321
+ <h1 style="font-size: 2.5rem; font-weight: bold; margin-bottom: 1rem;">CultureBot</h1>
322
+ <div style="font-size: 0.9rem; opacity: 0.9;">
323
+ <p><strong>Team:</strong> CultureCoders</p>
324
+ <p><strong>Version:</strong> 2.1.0</p>
325
+ <p><strong>Created:</strong> January 2025</p>
326
+ </div>
327
+ </div>
328
+ """, unsafe_allow_html=True)
329
+
330
+ st.markdown("---")
331
+
332
+ # Navigation
333
+ st.markdown("### 🧭 Navigation")
334
+ page = st.selectbox(
335
+ "Choose a page:",
336
+ ["🏠 Home", "πŸ’¬ Chat with CultureBot", "πŸ“š Cultural Facts", "ℹ️ About"],
337
+ key="navigation"
338
+ )
339
+
340
+ st.markdown("---")
341
+
342
+ # Quick stats
343
+ st.markdown("### πŸ“Š Quick Stats")
344
+ st.success("🟒 System Online")
345
+ st.info(f"πŸ“ˆ {len(cultural_db.cultural_facts)} Cultural Facts")
346
+ st.info(f"🌍 {len(cultural_db.get_all_countries())} Countries")
347
+
348
+ # Random fact
349
+ st.markdown("### 🎲 Random Fact")
350
+ if st.button("Get Random Fact"):
351
+ fact = cultural_db.get_random_fact()
352
+ st.markdown(f"""
353
+ <div class="fact-card">
354
+ <h4>{fact['country']}</h4>
355
+ <p>{fact['fact']}</p>
356
+ <small>Category: {fact['category']}</small>
357
+ </div>
358
+ """, unsafe_allow_html=True)
359
+
360
+ # Main content area
361
+ if page == "🏠 Home":
362
+ # Home page
363
+ st.markdown("""
364
+ <div class="main-header">
365
+ <h1 style="font-size: 3rem; margin-bottom: 1rem;">Welcome to CultureBot</h1>
366
+ <p style="font-size: 1.2rem; opacity: 0.9;">Your AI-powered guide to understanding cultures, traditions, and social customs from around the world</p>
367
+ </div>
368
+ """, unsafe_allow_html=True)
369
+
370
+ # Feature cards
371
+ col1, col2, col3 = st.columns(3)
372
+
373
+ with col1:
374
+ st.markdown("""
375
+ <div class="metric-card">
376
+ <h3>🌍 Global Insights</h3>
377
+ <p>Discover fascinating cultural facts and customs from countries across all continents.</p>
378
+ </div>
379
+ """, unsafe_allow_html=True)
380
+
381
+ with col2:
382
+ st.markdown("""
383
+ <div class="metric-card">
384
+ <h3>πŸ€– AI-Powered Chat</h3>
385
+ <p>Ask questions and get personalized responses about specific countries and cultural practices.</p>
386
+ </div>
387
+ """, unsafe_allow_html=True)
388
+
389
+ with col3:
390
+ st.markdown("""
391
+ <div class="metric-card">
392
+ <h3>πŸ“š Learn & Explore</h3>
393
+ <p>Expand your cultural awareness and become a more informed global citizen.</p>
394
+ </div>
395
+ """, unsafe_allow_html=True)
396
+
397
+ st.markdown("---")
398
+
399
+ # Getting started
400
+ st.markdown("## πŸš€ Getting Started")
401
+ st.markdown("""
402
+ 1. **Chat with CultureBot**: Ask questions about any culture or country
403
+ 2. **Explore Facts**: Browse our curated collection of cultural insights
404
+ 3. **Learn Continuously**: Discover new perspectives and traditions
405
+ """)
406
+
407
+ elif page == "πŸ’¬ Chat with CultureBot":
408
+ # Chat page
409
+ st.markdown("""
410
+ <div class="main-header">
411
+ <h1>Chat with CultureBot</h1>
412
+ <p>Ask me about any culture, country, or tradition!</p>
413
+ </div>
414
+ """, unsafe_allow_html=True)
415
+
416
+ # Initialize chat history
417
+ if "messages" not in st.session_state:
418
+ st.session_state.messages = []
419
+
420
+ # Display chat messages
421
+ for message in st.session_state.messages:
422
+ if message["role"] == "user":
423
+ st.markdown(f"""
424
+ <div class="chat-message user-message">
425
+ <strong>You:</strong> {message["content"]}
426
+ </div>
427
+ """, unsafe_allow_html=True)
428
+ else:
429
+ st.markdown(f"""
430
+ <div class="chat-message bot-message">
431
+ <strong>CultureBot:</strong> {message["content"]}
432
+ </div>
433
+ """, unsafe_allow_html=True)
434
+
435
+ # Chat input
436
+ user_input = st.chat_input("Ask about any culture or country...")
437
+
438
+ if user_input:
439
+ # Add user message to chat history
440
+ st.session_state.messages.append({"role": "user", "content": user_input})
441
+
442
+ # Get bot response
443
+ with st.spinner("CultureBot is thinking..."):
444
+ bot_response = culture_ai.generate_response(user_input)
445
+ st.session_state.messages.append({
446
+ "role": "assistant",
447
+ "content": bot_response["response"]
448
+ })
449
+
450
+ st.rerun()
451
+
452
+ # Suggested questions
453
+ st.markdown("### πŸ’‘ Try asking about:")
454
+ suggestions = [
455
+ "Tell me about Japanese business etiquette",
456
+ "What are some Indian greeting customs?",
457
+ "How do Germans view punctuality?",
458
+ "What should I know about dining in France?",
459
+ "Explain Chinese lucky numbers"
460
+ ]
461
+
462
+ cols = st.columns(len(suggestions))
463
+ for i, suggestion in enumerate(suggestions):
464
+ with cols[i]:
465
+ if st.button(suggestion, key=f"suggestion_{i}", use_container_width=True):
466
+ st.session_state.messages.append({"role": "user", "content": suggestion})
467
+ with st.spinner("CultureBot is thinking..."):
468
+ bot_response = culture_ai.generate_response(suggestion)
469
+ st.session_state.messages.append({
470
+ "role": "assistant",
471
+ "content": bot_response["response"]
472
+ })
473
+ st.rerun()
474
+
475
+ elif page == "πŸ“š Cultural Facts":
476
+ # Cultural facts page
477
+ st.markdown("""
478
+ <div class="main-header">
479
+ <h1>Cultural Facts Explorer</h1>
480
+ <p>Browse our curated collection of cultural insights</p>
481
+ </div>
482
+ """, unsafe_allow_html=True)
483
+
484
+ # Filters
485
+ col1, col2 = st.columns(2)
486
+
487
+ with col1:
488
+ countries = ["All Countries"] + sorted(cultural_db.get_all_countries())
489
+ country_filter = st.selectbox("Filter by Country:", countries)
490
+
491
+ with col2:
492
+ categories = ["All Categories"] + sorted(cultural_db.get_all_categories())
493
+ category_filter = st.selectbox("Filter by Category:", categories)
494
+
495
+ # Display facts
496
+ if country_filter != "All Countries":
497
+ facts = cultural_db.get_facts_by_country(country_filter)
498
+ elif category_filter != "All Categories":
499
+ facts = cultural_db.get_facts_by_category(category_filter)
500
+ else:
501
+ facts = cultural_db.cultural_facts
502
+
503
+ if facts:
504
+ for fact in facts:
505
+ st.markdown(f"""
506
+ <div class="fact-card">
507
+ <h3>{fact['country']}</h3>
508
+ <p>{fact['fact']}</p>
509
+ <div style="display: flex; justify-content: space-between; margin-top: 1rem;">
510
+ <small><strong>Category:</strong> {fact['category']}</small>
511
+ <small><strong>Source:</strong> {fact['source']}</small>
512
+ </div>
513
+ </div>
514
+ """, unsafe_allow_html=True)
515
+ else:
516
+ st.info("No facts found for the selected filters.")
517
+
518
+ else: # About page
519
+ st.markdown("""
520
+ <div class="main-header">
521
+ <h1>About CultureBot</h1>
522
+ <p>Bridging cultures through AI-powered conversations</p>
523
+ </div>
524
+ """, unsafe_allow_html=True)
525
+
526
+ # Mission and features
527
+ col1, col2 = st.columns(2)
528
+
529
+ with col1:
530
+ st.markdown("""
531
+ ### 🎯 Our Mission
532
+ CultureBot was created to help people understand and appreciate the rich diversity of cultures around the world.
533
+ In our increasingly connected world, cultural awareness is more important than ever.
534
+
535
+ ### πŸ”§ Technology Stack
536
+ - **Frontend**: Streamlit (Python)
537
+ - **AI Engine**: Rule-based cultural knowledge system
538
+ - **Database**: In-memory cultural facts database
539
+ - **Deployment**: Hugging Face Spaces
540
+ """)
541
+
542
+ with col2:
543
+ st.markdown("""
544
+ ### ✨ Features
545
+ - **Global Coverage**: Cultural insights from countries across all continents
546
+ - **Smart Chat**: Context-aware responses about cultural practices
547
+ - **Curated Content**: Carefully researched and verified cultural facts
548
+ - **Interactive Interface**: Beautiful, responsive design
549
+ - **Real-time Interaction**: Fast and responsive chat experience
550
+ """)
551
+
552
+ st.markdown("---")
553
+
554
+ # Technical details
555
+ st.markdown("### πŸ—οΈ Architecture")
556
+ st.markdown("""
557
+ CultureBot is built as a single Streamlit application optimized for Hugging Face Spaces:
558
+
559
+ 1. **Streamlit Frontend**: Beautiful, interactive user interface
560
+ 2. **Cultural Knowledge Engine**: Smart response generation based on cultural database
561
+ 3. **Cultural Database**: Curated collection of cultural facts and insights
562
+ 4. **Responsive Design**: Works seamlessly across different devices
563
+ """)
564
+
565
+ # Contact and support
566
+ st.markdown("### πŸ“ž Support")
567
+ st.markdown("""
568
+ For technical support or cultural content suggestions:
569
+ - **Team**: CultureCoders
570
+ - **Version**: 2.1.0
571
+ - **Platform**: Hugging Face Spaces
572
+ - **Last Updated**: January 2025
573
+ """)
config.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ primaryColor = "#667eea"
3
+ backgroundColor = "#ffffff"
4
+ secondaryBackgroundColor = "#f0f2f6"
5
+ textColor = "#262730"
6
+
7
+ [server]
8
+ headless = true
9
+ enableCORS = false
10
+ port = 7860
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit==1.45.1
2
+ openai==1.84.0
3
+ python-dotenv==1.1.0
4
+ requests==2.32.3