Spaces:
Sleeping
Sleeping
Dua Rajper commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,11 +16,15 @@ if not api_key:
|
|
| 16 |
client = Groq(api_key=api_key)
|
| 17 |
|
| 18 |
# Function to get chatbot response
|
| 19 |
-
def
|
| 20 |
-
#
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
if any(keyword in user_question.lower() for keyword in
|
| 24 |
# Call Groq API to generate a response
|
| 25 |
completion = client.chat.completions.create(
|
| 26 |
model="deepseek-r1-distill-llama-70b",
|
|
@@ -32,16 +36,16 @@ def get_health_response(user_question):
|
|
| 32 |
)
|
| 33 |
return completion.choices[0].message['content']
|
| 34 |
else:
|
| 35 |
-
return "⚠️ This chatbot only answers
|
| 36 |
|
| 37 |
# Streamlit UI
|
| 38 |
st.set_page_config(page_title="Health & Fitness Chatbot", layout="centered")
|
| 39 |
st.title("💪 Health & Fitness Chatbot")
|
| 40 |
-
st.write("Ask me about
|
| 41 |
|
| 42 |
# User Input
|
| 43 |
user_input = st.text_input("Type your question:")
|
| 44 |
|
| 45 |
if user_input:
|
| 46 |
-
response =
|
| 47 |
st.write(response)
|
|
|
|
| 16 |
client = Groq(api_key=api_key)
|
| 17 |
|
| 18 |
# Function to get chatbot response
|
| 19 |
+
def get_fitness_response(user_question):
|
| 20 |
+
# Define keywords related to fitness, weight loss, and health
|
| 21 |
+
fitness_keywords = [
|
| 22 |
+
"health", "fitness", "exercise", "diet", "nutrition", "weight loss", "workout", "calories",
|
| 23 |
+
"meal plan", "cardio", "strength training", "fat loss", "BMI", "hydration", "metabolism",
|
| 24 |
+
"protein intake", "muscle gain", "recovery", "supplements", "healthy habits", "intermittent fasting"
|
| 25 |
+
]
|
| 26 |
|
| 27 |
+
if any(keyword in user_question.lower() for keyword in fitness_keywords):
|
| 28 |
# Call Groq API to generate a response
|
| 29 |
completion = client.chat.completions.create(
|
| 30 |
model="deepseek-r1-distill-llama-70b",
|
|
|
|
| 36 |
)
|
| 37 |
return completion.choices[0].message['content']
|
| 38 |
else:
|
| 39 |
+
return "⚠️ This chatbot only answers fitness, health, and weight loss-related questions."
|
| 40 |
|
| 41 |
# Streamlit UI
|
| 42 |
st.set_page_config(page_title="Health & Fitness Chatbot", layout="centered")
|
| 43 |
st.title("💪 Health & Fitness Chatbot")
|
| 44 |
+
st.write("Ask me anything about fitness, weight loss, workouts, and nutrition!")
|
| 45 |
|
| 46 |
# User Input
|
| 47 |
user_input = st.text_input("Type your question:")
|
| 48 |
|
| 49 |
if user_input:
|
| 50 |
+
response = get_fitness_response(user_input)
|
| 51 |
st.write(response)
|