Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,16 +53,29 @@ if prayer_times:
|
|
| 53 |
st.warning(f"🛑 It is currently **{prayer_name}** time! Auto-reply enabled.")
|
| 54 |
st.write("**Auto-reply:** 'I am in prayer right now. Please call later.'")
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Chatbot for Islamic queries
|
| 57 |
user_query = st.text_input("Ask an Islamic question:")
|
| 58 |
|
| 59 |
if user_query:
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
st.warning(f"🛑 It is currently **{prayer_name}** time! Auto-reply enabled.")
|
| 54 |
st.write("**Auto-reply:** 'I am in prayer right now. Please call later.'")
|
| 55 |
|
| 56 |
+
# Predefined questions and answers related to Islam
|
| 57 |
+
predefined_answers = {
|
| 58 |
+
"What time is Fajr today?": "Fajr time in Khairpur is 5:00 AM.",
|
| 59 |
+
"When is Maghrib time in Pakistan?": "Maghrib time in Khairpur is 6:30 PM.",
|
| 60 |
+
"What are the five pillars of Islam?": "The five pillars of Islam are Shahada (Faith), Salah (Prayer), Zakat (Charity), Sawm (Fasting), and Hajj (Pilgrimage).",
|
| 61 |
+
"What is the importance of Salah in Islam?": "Salah is one of the most important pillars of Islam and is an act of worship performed five times daily.",
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
# Chatbot for Islamic queries
|
| 65 |
user_query = st.text_input("Ask an Islamic question:")
|
| 66 |
|
| 67 |
if user_query:
|
| 68 |
+
# Check if the user query matches any predefined question
|
| 69 |
+
if user_query in predefined_answers:
|
| 70 |
+
st.write(f"**Answer:** {predefined_answers[user_query]}")
|
| 71 |
+
else:
|
| 72 |
+
try:
|
| 73 |
+
# If not a predefined question, use Groq Llama 70B for dynamic answers
|
| 74 |
+
response = client.chat.completions.create(
|
| 75 |
+
messages=[{"role": "user", "content": user_query}],
|
| 76 |
+
model="llama-3.3-70b-versatile",
|
| 77 |
+
)
|
| 78 |
+
answer = response.choices[0].message.content
|
| 79 |
+
st.write("**Islamic Chatbot Answer:**", answer)
|
| 80 |
+
except Exception as e:
|
| 81 |
+
st.error(f"❌ Error fetching response. Please check your API key. Error: {str(e)}")
|