Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -131,20 +131,26 @@ def query_financial_data(company_name, query_type):
|
|
| 131 |
company = {}
|
| 132 |
else:
|
| 133 |
company = result
|
| 134 |
-
except (ValueError, KeyError) as e:
|
| 135 |
return f"❌ JSON Parse Error: {str(e)}\n\nResponse: {search_resp.text[:500]}"
|
| 136 |
|
| 137 |
if isinstance(company, dict) and company.get("error"):
|
| 138 |
return f"❌ Error: {company['error']}"
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
# 获取并格式化 CIK 为 10 位标准格式
|
| 145 |
cik = normalize_cik(company.get('cik'))
|
| 146 |
if not cik:
|
| 147 |
-
return result + "❌ Error: Invalid CIK from company search"
|
| 148 |
|
| 149 |
# 根据查询类型获取数据
|
| 150 |
if internal_query_type == "最新财务数据":
|
|
|
|
| 131 |
company = {}
|
| 132 |
else:
|
| 133 |
company = result
|
| 134 |
+
except (ValueError, KeyError, json.JSONDecodeError) as e:
|
| 135 |
return f"❌ JSON Parse Error: {str(e)}\n\nResponse: {search_resp.text[:500]}"
|
| 136 |
|
| 137 |
if isinstance(company, dict) and company.get("error"):
|
| 138 |
return f"❌ Error: {company['error']}"
|
| 139 |
|
| 140 |
+
# advanced_search 返回的字段: cik, name, ticker
|
| 141 |
+
# 注意: 不是 tickers 和 sic_description
|
| 142 |
+
company_name = company.get('name', 'Unknown')
|
| 143 |
+
ticker = company.get('ticker', 'N/A')
|
| 144 |
+
|
| 145 |
+
result = f"# {company_name}\n\n"
|
| 146 |
+
result += f"**Stock Symbol**: {ticker}\n"
|
| 147 |
+
# sic_description 需要后续通过 get_company_info 获取,这里暂时不显示
|
| 148 |
+
result += "\n---\n\n"
|
| 149 |
|
| 150 |
# 获取并格式化 CIK 为 10 位标准格式
|
| 151 |
cik = normalize_cik(company.get('cik'))
|
| 152 |
if not cik:
|
| 153 |
+
return result + f"❌ Error: Invalid CIK from company search\n\nDebug: company data = {json.dumps(company, indent=2)}"
|
| 154 |
|
| 155 |
# 根据查询类型获取数据
|
| 156 |
if internal_query_type == "最新财务数据":
|