diff --git a/Dockerfile b/Dockerfile
index 7a22b51..00c78cb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,6 +20,10 @@ RUN find /usr/local/lib/python3.11 -type d -name "__pycache__" -exec rm -rf {} +
FROM python:3.11-slim
WORKDIR /app
+# 设置上海时区
+ENV TZ=Asia/Shanghai
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+
# 仅复制已编译好的包,无需 gcc
COPY --from=python-deps /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
diff --git a/backend/services/ai_service.py b/backend/services/ai_service.py
index 26eb81e..a7097c7 100644
--- a/backend/services/ai_service.py
+++ b/backend/services/ai_service.py
@@ -39,6 +39,8 @@ SYSTEM_PROMPT = """你是一位专业的A股市场分析师,擅长从数据中
DAILY_ANALYSIS_PROMPT = """请对 {trade_date} 的A股市场进行收盘分析,生成一份完整的分析报告。
+{prev_report_section}
+
请先调用以下工具获取数据:
1. get_market_dashboard - 获取市场整体数据
2. get_theme_history(date="{trade_date}") - 获取今日题材涨幅
@@ -107,9 +109,13 @@ async def collect_ai_analysis(trade_date: str) -> dict:
Returns:
{"id": int, "tokens_used": int, "tools_used": list}
"""
+ prev_report_section = _get_prev_report_section(trade_date)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
- {"role": "user", "content": DAILY_ANALYSIS_PROMPT.format(trade_date=trade_date)}
+ {"role": "user", "content": DAILY_ANALYSIS_PROMPT.format(
+ trade_date=trade_date,
+ prev_report_section=prev_report_section
+ )}
]
tools_used = []
@@ -185,3 +191,29 @@ def _save_report(trade_date: str, content: str, summary: str, tools_used: list,
return cursor.lastrowid
finally:
conn.close()
+
+
+def _get_prev_report_section(trade_date: str) -> str:
+ """获取前一个交易日的报告摘要,用于上下文参考"""
+ conn = get_connection()
+ try:
+ row = conn.execute(
+ "SELECT trade_date, content FROM ai_reports WHERE trade_date < ? AND report_type = 'daily' ORDER BY trade_date DESC LIMIT 1",
+ (trade_date,)
+ ).fetchone()
+ if not row:
+ return ""
+ prev_date = row["trade_date"]
+ prev_content = row["content"] or ""
+ # 取报告的前1500字符作为参考上下文
+ truncated = prev_content[:1500]
+ if len(prev_content) > 1500:
+ truncated += "\n...(已截断)"
+ return f"""以下是前一个交易日({prev_date})的分析报告,请参考其中的分析逻辑和关注方向,结合今日数据进行对比分析:
+
+{truncated}
+
+---
+"""
+ finally:
+ conn.close()
diff --git a/src/routes/ai-analysis.tsx b/src/routes/ai-analysis.tsx
index 1acd9af..acce930 100644
--- a/src/routes/ai-analysis.tsx
+++ b/src/routes/ai-analysis.tsx
@@ -86,7 +86,6 @@ function AiAnalysisPage() {
{report.created_at}
- {report.model}
{report.tokens_used?.toLocaleString()} tokens
{report.toolsUsed && report.toolsUsed.length > 0 && (