Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +15 -2
- mcp_server.py +8 -1
app.py
CHANGED
|
@@ -253,13 +253,20 @@ def get_company_news(symbol: str, from_date: Optional[str] = None, to_date: Opti
|
|
| 253 |
}
|
| 254 |
|
| 255 |
if not result or len(result) == 0:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
return {
|
| 257 |
"symbol": symbol.upper(),
|
| 258 |
"from_date": from_date,
|
| 259 |
"to_date": to_date,
|
| 260 |
"total_articles": 0,
|
| 261 |
"articles": [],
|
| 262 |
-
"message": f"No news articles found for {symbol.upper()}
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
# Format the news articles
|
|
@@ -360,7 +367,13 @@ def test_company_news_tool(symbol: str, from_date: str, to_date: str) -> str:
|
|
| 360 |
return f"❌ Error: {result['error']}"
|
| 361 |
|
| 362 |
if result.get('total_articles', 0) == 0:
|
| 363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
|
| 365 |
# Format for display
|
| 366 |
output = f"📰 Company News for {result['symbol']}\n"
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
if not result or len(result) == 0:
|
| 256 |
+
# Provide helpful suggestions based on the symbol
|
| 257 |
+
suggestion = "Try expanding the date range or check if the symbol is correct."
|
| 258 |
+
if symbol.upper() in ["BABA", "BIDU", "JD", "PDD", "NIO"]:
|
| 259 |
+
suggestion = "Note: Chinese ADRs may have limited news coverage. Try US companies like AAPL, MSFT, TSLA, or GOOGL for better results."
|
| 260 |
+
|
| 261 |
return {
|
| 262 |
"symbol": symbol.upper(),
|
| 263 |
"from_date": from_date,
|
| 264 |
"to_date": to_date,
|
| 265 |
"total_articles": 0,
|
| 266 |
"articles": [],
|
| 267 |
+
"message": f"No news articles found for {symbol.upper()} between {from_date} and {to_date}.",
|
| 268 |
+
"suggestion": suggestion,
|
| 269 |
+
"note": "Company news is only available for North American companies. Some companies may have limited news coverage during certain periods."
|
| 270 |
}
|
| 271 |
|
| 272 |
# Format the news articles
|
|
|
|
| 367 |
return f"❌ Error: {result['error']}"
|
| 368 |
|
| 369 |
if result.get('total_articles', 0) == 0:
|
| 370 |
+
# Show detailed message with suggestions
|
| 371 |
+
output = f"⚠️ {result.get('message', 'No news articles found')}\n\n"
|
| 372 |
+
if 'suggestion' in result:
|
| 373 |
+
output += f"💡 {result['suggestion']}\n\n"
|
| 374 |
+
if 'note' in result:
|
| 375 |
+
output += f"📝 {result['note']}"
|
| 376 |
+
return output
|
| 377 |
|
| 378 |
# Format for display
|
| 379 |
output = f"📰 Company News for {result['symbol']}\n"
|
mcp_server.py
CHANGED
|
@@ -259,13 +259,20 @@ def get_company_news(symbol: str, from_date: Optional[str] = None, to_date: Opti
|
|
| 259 |
}
|
| 260 |
|
| 261 |
if not result or len(result) == 0:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
return {
|
| 263 |
"symbol": symbol.upper(),
|
| 264 |
"from_date": from_date,
|
| 265 |
"to_date": to_date,
|
| 266 |
"total_articles": 0,
|
| 267 |
"articles": [],
|
| 268 |
-
"message": f"No news found for {symbol.upper()}
|
|
|
|
|
|
|
| 269 |
}
|
| 270 |
|
| 271 |
# Format the news articles
|
|
|
|
| 259 |
}
|
| 260 |
|
| 261 |
if not result or len(result) == 0:
|
| 262 |
+
# Provide helpful suggestions based on the symbol
|
| 263 |
+
suggestion = "Try expanding the date range or check if the symbol is correct."
|
| 264 |
+
if symbol.upper() in ["BABA", "BIDU", "JD", "PDD", "NIO"]:
|
| 265 |
+
suggestion = "Note: Chinese ADRs may have limited news coverage. Try US companies like AAPL, MSFT, TSLA, or GOOGL for better results."
|
| 266 |
+
|
| 267 |
return {
|
| 268 |
"symbol": symbol.upper(),
|
| 269 |
"from_date": from_date,
|
| 270 |
"to_date": to_date,
|
| 271 |
"total_articles": 0,
|
| 272 |
"articles": [],
|
| 273 |
+
"message": f"No news found for {symbol.upper()} between {from_date} and {to_date}.",
|
| 274 |
+
"suggestion": suggestion,
|
| 275 |
+
"note": "Company news is only available for North American companies. Some companies may have limited news coverage during certain periods."
|
| 276 |
}
|
| 277 |
|
| 278 |
# Format the news articles
|