diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py index 1b8c337..d9bfc95 100644 --- a/backend/app/api/routes.py +++ b/backend/app/api/routes.py @@ -42,9 +42,12 @@ async def search_stock(request: StockSearchRequest, db: AsyncSession = Depends(g @router.post("/analyze", response_model=ReportResponse) async def start_analysis(request: AnalysisRequest, background_tasks: BackgroundTasks, db: AsyncSession = Depends(get_db)): - # Get AI model setting - model_setting = await db.get(Setting, "AI_MODEL") - model = model_setting.value if model_setting else "gemini-2.0-flash" + # Get AI model + if request.model: + model = request.model + else: + model_setting = await db.get(Setting, "AI_MODEL") + model = model_setting.value if model_setting else "gemini-2.0-flash" new_report = Report( market=request.market, @@ -71,7 +74,8 @@ async def start_analysis(request: AnalysisRequest, background_tasks: BackgroundT new_report.id, request.market, request.symbol, - api_key + api_key, + request.data_source ) # Re-fetch with selectinload to avoid lazy loading issues @@ -122,12 +126,18 @@ async def get_report_html(report_id: int, db: AsyncSession = Depends(get_db)): except Exception as e: financial_html = f"
加载财务图表时出错: {str(e)}
" + # If content is not ready, add auto-refresh meta tag + meta_refresh = "" + if "财务图表尚未生成" in financial_html: + meta_refresh = '' + # Only return financial charts, no analysis sections final_html = f""" + {meta_refresh}