Skip to content

Commit 845752c

Browse files
committed
fix(review-feedback-1307): 补齐大盘复盘历史记录的 Web/API 契约闭环与对应文档落点
1 parent 98c6829 commit 845752c

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

apps/dsa-web/src/types/analysis.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
// ============ Request Types ============
77

8+
export type ReportType = 'simple' | 'detailed' | 'full' | 'brief' | 'market_review';
9+
810
export interface AnalysisRequest {
911
stockCode?: string;
1012
stockCodes?: string[];
11-
reportType?: 'simple' | 'detailed' | 'full' | 'brief';
13+
reportType?: ReportType;
1214
forceRefresh?: boolean;
1315
asyncMode?: boolean;
1416
stockName?: string;
@@ -38,7 +40,7 @@ export interface ReportMeta {
3840
queryId: string;
3941
stockCode: string;
4042
stockName: string;
41-
reportType: 'simple' | 'detailed' | 'full' | 'brief';
43+
reportType: ReportType;
4244
reportLanguage?: ReportLanguage;
4345
createdAt: string;
4446
currentPrice?: number;
@@ -206,7 +208,7 @@ export interface HistoryItem {
206208
queryId: string; // Linked analysis query ID
207209
stockCode: string;
208210
stockName?: string;
209-
reportType?: string;
211+
reportType?: ReportType;
210212
sentimentScore?: number;
211213
operationAdvice?: string;
212214
createdAt: string;

docs/full-guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ FastAPI 提供 RESTful API 服务,支持配置管理和触发分析。
11501150
- 🧭 **首次配置提示** - 首页会读取只读配置状态,缺少 LLM 主渠道、自选股等基础项时提示缺口并引导进入系统设置
11511151
- 📊 **实时进度** - 分析任务状态实时更新,支持多任务并行;普通分析链路在进入 LLM 阶段后会优先尝试 LiteLLM 流式生成,并通过任务 SSE 回灌更细粒度的 `message/progress`
11521152
- 🗂️ **大盘复盘任务可见性** - 首页触发大盘复盘后会返回 `task_id` 并轮询 `GET /api/v1/analysis/status/{task_id}`,在进行中/完成/失败场景给出可见反馈,失败时直接透出报错内容
1153+
- 🧾 **市场复盘历史可复用** - 大盘复盘任务会持久化到分析历史,`report_type` 为 `market_review`,可直接通过历史列表/详情打开对应 Markdown 或详情页,不会重新触发分析重算
11531154
- 📈 **回测验证** - 评估历史分析准确率,查询方向胜率与模拟收益
11541155
- 🔗 **API 文档** - 访问 `/docs` 查看 Swagger UI
11551156

@@ -1176,6 +1177,7 @@ FastAPI 提供 RESTful API 服务,支持配置管理和触发分析。
11761177
> 说明:`POST /api/v1/analysis/analyze` 在 `async_mode=false` 时仅支持单只股票;批量 `stock_codes` 需使用 `async_mode=true`。异步 `202` 响应对单股返回 `task_id`,对批量返回 `accepted` / `duplicates` 汇总结构。
11771178
> 说明:`POST /api/v1/analysis/market-review` 采用后端与 CLI/Bot 共用的配置路径(`GeminiAnalyzer(config=...)` 与同样的搜索/提示词构造入口)。Provider 兼容路由会优先识别并使用 `litellm_model`、`llm_model_list`,若未配置则回退 legacy `GEMINI_*`、`OPENAI_*`、`ANTHROPIC_*`、`DEEPSEEK_*` 键;不会新增/调整 provider、Base URL 或 LiteLLM 路由语义。
11781179
> 审计依据:优先级与回退语义以 `src/config.py` 的 `Config._load_from_env()` 为准(`LITELLM_CONFIG` > `LLM_CHANNELS` > legacy)。配套回归见 `tests/test_llm_channel_config.py`(配置源解析)与 `tests/test_market_review_runtime.py`(共享装配路径)。该接口当前仅提供单进程/单机级防重复能力,若为多实例部署需通过外部任务队列或分布式锁补齐全局幂等。
1180+
> 说明:`POST /api/v1/analysis/market-review` 触发后,报告会以 `report_type=market_review` 写入历史库;你可直接查询 `/api/v1/history` 或 `/api/v1/history/{record_id}` 获取历史 Markdown,避免再次触发分析重算。
11791181
> 说明:该端点若返回 `task_id`,WebUI 会轮询 `GET /api/v1/analysis/status/{task_id}` 展示状态。状态为 `completed` 时给出完成提示(报告已生成并按配置推送),状态为 `failed` 时在前端错误区域显示 `error` 原因。
11801182

11811183
> 兼容性审计证据:

docs/full-guide_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ FastAPI provides RESTful API service for configuration management and triggering
10091009
- **First-run Setup Hint** - The Home page reads the read-only setup status and points users to Settings when required items such as the primary LLM channel or watchlist are missing
10101010
- **Real-time Progress** - Analysis task status updates in real-time, supports parallel tasks; the regular stock-analysis path now prefers LiteLLM streaming during the LLM stage and pushes finer-grained `message/progress` updates through task SSE
10111011
- **Market Review visibility** - After clicking Market Review, the API returns a `task_id` and the UI polls `GET /api/v1/analysis/status/{task_id}` to show progress; completed/failure states are rendered explicitly and failure messages are shown directly in the UI error area.
1012+
- **Market review history replay** - Market review results are persisted with `report_type=market_review` and can be reopened from history list/detail or Markdown endpoints directly, without re-triggering a fresh analysis run.
10121013
- **Backtest Validation** - Evaluate historical analysis accuracy, query direction win rate and simulated returns
10131014
- **API Documentation** - Visit `/docs` for Swagger UI
10141015

@@ -1033,6 +1034,7 @@ FastAPI provides RESTful API service for configuration management and triggering
10331034
> Note: `POST /api/v1/analysis/analyze` supports only one stock when `async_mode=false`; batch `stock_codes` requires `async_mode=true`. The async `202` response returns a single `task_id` for one stock, or an `accepted` / `duplicates` summary for batch requests.
10341035
> Note: `POST /api/v1/analysis/market-review` follows the same runtime configuration path as CLI/Bot market review (`GeminiAnalyzer(config=...)`, search setup, and prompt/rendering pipeline). The provider compatibility path prioritizes `litellm_model` and `llm_model_list`, then falls back to existing legacy keys (`GEMINI_*`, `OPENAI_*`, `ANTHROPIC_*`, `DEEPSEEK_*`) when those are not set; provider names, Base URL, and LiteLLM routing semantics are otherwise unchanged.
10351036
> Audit note: priority and fallback are defined by `Config._load_from_env()` in `src/config.py` (`LITELLM_CONFIG` > `LLM_CHANNELS` > legacy). Regression coverage is in `tests/test_llm_channel_config.py` (configuration source parsing) and `tests/test_market_review_runtime.py` (shared runtime assembly). The endpoint lock is process/host-level only; multi-instance deployments still need external distributed idempotency controls.
1037+
> Note: Once `/api/v1/analysis/market-review` completes, the report is persisted with `report_type=market_review`; open `/api/v1/history` and `/api/v1/history/{record_id}` (or Markdown history endpoints) to view it directly without re-running analysis.
10361038
> Note: when `/api/v1/analysis/market-review` returns a `task_id`, the WebUI polls `GET /api/v1/analysis/status/{task_id}`. The UI renders clear `pending/processing` progress, shows completion feedback when status becomes `completed`, and surfaces `error` content on `failed`.
10371039

10381040
> Compatibility audit evidence:

0 commit comments

Comments
 (0)