Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,55 +154,37 @@ def healthcare_software_trend_analyzer(product_keyword: str, timeframe: str = 't
|
|
| 154 |
"Medical Billing Software", "Practice Management Software",
|
| 155 |
"Remote Patient Monitoring", "Healthcare CRM", "Medical Imaging Software","Sig", "Patient Instructions"
|
| 156 |
]
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
pytrends = TrendReq(hl='en-US', tz=360)
|
| 174 |
-
pytrends.build_payload([product_keyword], timeframe=timeframe, geo=geo)
|
| 175 |
-
interest_over_time = pytrends.interest_over_time()
|
| 176 |
-
|
| 177 |
-
# Calculate trend metrics
|
| 178 |
-
current_interest = interest_over_time[product_keyword].iloc[-1]
|
| 179 |
-
avg_interest = interest_over_time[product_keyword].mean()
|
| 180 |
-
trend_direction = "Increasing" if current_interest > avg_interest else "Decreasing"
|
| 181 |
-
|
| 182 |
-
# Compile report
|
| 183 |
-
report = f"Healthcare Software Market Trend Analysis for '{product_keyword}':\n"
|
| 184 |
-
report += f"Timeframe: {timeframe}\n"
|
| 185 |
-
report += f"Region: {geo if geo else 'Worldwide'}\n\n"
|
| 186 |
-
report += f"Google Trends Analysis:\n"
|
| 187 |
-
report += f"- Current Interest: {current_interest:.2f}\n"
|
| 188 |
-
report += f"- Average Interest: {avg_interest:.2f}\n"
|
| 189 |
-
report += f"- Trend Direction: {trend_direction}\n"
|
| 190 |
-
report += suggestion
|
| 191 |
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
time.sleep(delay)
|
| 200 |
-
else:
|
| 201 |
-
return f"❌ Rate limit exceeded. Please try again later."
|
| 202 |
-
else:
|
| 203 |
-
return f"❌ Error analyzing healthcare software market trends: {str(e)}"
|
| 204 |
-
|
| 205 |
-
return "❌ Failed to retrieve data after multiple attempts."
|
| 206 |
|
| 207 |
@tool
|
| 208 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 154 |
"Medical Billing Software", "Practice Management Software",
|
| 155 |
"Remote Patient Monitoring", "Healthcare CRM", "Medical Imaging Software","Sig", "Patient Instructions"
|
| 156 |
]
|
| 157 |
+
try:
|
| 158 |
+
# Suggest category if not in list
|
| 159 |
+
if product_keyword not in HEALTHCARE_SOFTWARE_CATEGORIES:
|
| 160 |
+
suggestion = f"\nNote: '{product_keyword}' is not in our list of common healthcare software categories. Consider using one of these: {', '.join(HEALTHCARE_SOFTWARE_CATEGORIES)}\n"
|
| 161 |
+
else:
|
| 162 |
+
suggestion = ""
|
| 163 |
+
|
| 164 |
+
# Google Trends analysis
|
| 165 |
+
pytrends = TrendReq(hl='en-US', tz=360)
|
| 166 |
+
pytrends.build_payload([product_keyword], timeframe=timeframe, geo=geo)
|
| 167 |
+
interest_over_time = pytrends.interest_over_time()
|
| 168 |
+
|
| 169 |
+
# Calculate trend metrics
|
| 170 |
+
current_interest = interest_over_time[product_keyword].iloc[-1]
|
| 171 |
+
avg_interest = interest_over_time[product_keyword].mean()
|
| 172 |
+
trend_direction = "Increasing" if current_interest > avg_interest else "Decreasing"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
+
# Compile report
|
| 175 |
+
report = f"Healthcare Software Market Trend Analysis for '{product_keyword}':\n"
|
| 176 |
+
report += f"Timeframe: {timeframe}\n"
|
| 177 |
+
report += f"Region: {geo if geo else 'Worldwide'}\n\n"
|
| 178 |
+
report += f"Google Trends Analysis:\n"
|
| 179 |
+
report += f"- Current Interest: {current_interest:.2f}\n"
|
| 180 |
+
report += f"- Average Interest: {avg_interest:.2f}\n"
|
| 181 |
+
report += f"- Trend Direction: {trend_direction}\n"
|
| 182 |
+
report += suggestion
|
| 183 |
|
| 184 |
+
return report
|
| 185 |
+
|
| 186 |
+
except Exception as e:
|
| 187 |
+
return f"❌ Error analyzing healthcare software market trends: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
@tool
|
| 190 |
def get_current_time_in_timezone(timezone: str) -> str:
|