Dua Rajper commited on
Commit
bf90edc
·
verified ·
1 Parent(s): 7b207fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
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 get_health_response(user_question):
20
- # Check if the question is related to health, fitness, or diet
21
- health_keywords = ["health", "fitness", "exercise", "diet", "nutrition", "weight loss", "workout", "calories", "meal plan"]
 
 
 
 
22
 
23
- if any(keyword in user_question.lower() for keyword in health_keywords):
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 health, fitness, and diet-related questions."
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 health, fitness, weight loss, and diet plans!")
41
 
42
  # User Input
43
  user_input = st.text_input("Type your question:")
44
 
45
  if user_input:
46
- response = get_health_response(user_input)
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)