Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 103 |
-
|
|
|
|
| 104 |
"""
|
|
|
|
| 105 |
try:
|
| 106 |
response = model(prompt)
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|