Premkumar2025 commited on
Commit
1017415
·
verified ·
1 Parent(s): 6bf44fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -86,7 +86,6 @@ def get_lifestyle_recommendations(age: int, user_input: str) -> str:
86
  return offline_recommendations # Offline dataset
87
  except Exception as e:
88
  return "An error occurred while fetching recommendations."
89
-
90
  @tool
91
  def determine_user_preference(user_input: str) -> bool:
92
  """
@@ -99,15 +98,22 @@ def determine_user_preference(user_input: str) -> bool:
99
  prompt = f"""
100
  The user has provided the following request: "{user_input}".
101
  Determine if the user is explicitly asking for real-time or external data-based insights.
102
- Respond with only 'yes' (for web-based recommendations) or 'no' (for offline recommendations).
103
- If unclear, respond with 'no'.
 
104
  """
 
105
  try:
106
  response = model(prompt)
107
- print(f"Model Response: {response}")
108
- return response.strip().lower() == "yes"
 
 
 
 
 
 
109
  except Exception as e:
110
- print(f"Error in determine_user_preference: {e}")
111
  return False
112
 
113
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
 
86
  return offline_recommendations # Offline dataset
87
  except Exception as e:
88
  return "An error occurred while fetching recommendations."
 
89
  @tool
90
  def determine_user_preference(user_input: str) -> bool:
91
  """
 
98
  prompt = f"""
99
  The user has provided the following request: "{user_input}".
100
  Determine if the user is explicitly asking for real-time or external data-based insights.
101
+ Respond with ONLY 'yes' or 'no'. Do not include any additional text or explanation.
102
+ - 'yes' if the user wants real-time or web-based recommendations.
103
+ - 'no' if the user does not explicitly ask for real-time or web-based recommendations.
104
  """
105
+
106
  try:
107
  response = model(prompt)
108
+
109
+ response = response.strip().lower()
110
+ if response == "yes":
111
+ return True
112
+ elif response == "no":
113
+ return False
114
+ else:
115
+ return False
116
  except Exception as e:
 
117
  return False
118
 
119
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder: