fix: 升级 AlphaSift 并兼容热点详情龙头股字段 - #1714
Conversation
🤖 自动审查报告
📁 修改的文件
🧠 AI 代码审查意见结论Ready to Merge 结构化审查结果必要性通过
关联性通过
类型判定建议类型:
描述完整性完整
风险级别低
必改项无 建议项无
|
cb172ad to
788dbb4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 788dbb4914
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| stocks = payload.get("stocks") | ||
| leader_stocks = payload.get("leader_stocks") |
There was a problem hiding this comment.
Backfill from nested summary leader stocks
When a legacy detail cache or AlphaSift detail payload has the only usable leaders under summary_detail.leader_stocks/summary.leader_stocks rather than top-level leader_stocks, this helper reads only the top-level keys, normalizes both lists to empty, and the later backfill cannot populate stocks or leader_stocks. That leaves the degraded-cache path this change is meant to fix still returning no concept stocks despite the leaders being present in the cached summary; pull the nested summary leader list before falling back to [].
Useful? React with 👍 / 👎.
ZhuLinsen
left a comment
There was a problem hiding this comment.
评审结论
- 必要性:通过,修复热点详情在
stocks/leader_stocks单字段可用时仍被判缺字段的兼容问题,和 #1694 场景匹配。 - 是否有对应 issue:有,Fixes #1694。
- PR 类型:fix,主要是修复 AlphaSift 热点详情字段兼容与缓存/API 返回契约。
- description 完整性:完整,已说明背景、AlphaSift 版本核对、改动范围、验证、兼容性风险和 revert 级回滚方案,符合 AGENTS.md 对用户可见/API 变更的说明要求。
- 是否可直接合入:可,CI 已通过;
mergeable_state=blocked在本仓库分支保护语义下不单独构成阻断。
🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。
788dbb4 to
d5727d1
Compare
…ite the leaders being
ZhuLinsen
left a comment
There was a problem hiding this comment.
评审结论
- 必要性:通过,修复热点详情在
stocks/leader_stocks单字段可用时被判缺字段的问题,并补齐 AlphaSift pin 升级后的契约兼容。 - 是否有对应 issue:有,Fixes #1694。
- PR 类型:fix,主要修复热点详情字段兼容,同时同步默认 AlphaSift 依赖 pin 与相关配置/文档/测试。
- description 完整性:完整,已覆盖背景、关联 issue、AlphaSift 外部提交来源、改动范围、验证证据、兼容性/迁移边界和 revert 级回滚方案;符合 AGENTS.md 对配置、API、用户可见行为和 CHANGELOG 同步的要求。
- 是否可直接合入:可,当前 CI 全部通过;
mergeable_state=blocked属于仓库保护策略,不构成本次代码阻断。AlphaSift/LiteLLM 相关兼容风险已在 PR 描述和文档中说明,并有锁定依赖、函数签名 smoke、单测和回滚路径支撑。
🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。
* fix: update AlphaSift pin and hotspot detail fields * fix(review-feedback-1714): fix still returning no concept stocks despite the leaders being
背景
Fixes #1694。
热点题材详情在 EastMoney 瞬断、旧缓存或 AlphaSift 合约降级路径下,可能只携带
stocks/leader_stocks其中一个字段。旧合约或旧缓存仍会检查双字段,导致点击“选股 -> 热点题材 -> 概念股”时报“缺失字段:stocks、leader_stocks”。AlphaSift 最近更新核对
14e74fc0819267f7c04c3117a0dd0fe3f9b19404(AlphaSift PR [Bug] [Feature] analyzer.py导入openai库因为环境使用代理而未安装socksio包,导致创建客户端时抛出 ImportError,且报错提示为未安装openai库 #16,Tencent 日 K、Sina snapshot、source health、candidate quote context 等更新)。main为377049857cc04175dc3cca62121ee41adec6cdb8(PR Update daily_analysis.yml #19,LLM ranking timeout/max tokens 边界),14e74fc...仍是其祖先。14e74fc...HEAD后确认近期新增变更集中在 LLM ranking:LLM_MAX_TOKENS默认 2048、向 ranker/LiteLLM 透传max_tokens、timeout 后不再盲目重试无 JSON mode 请求,并关闭 LiteLLM 内层重试。377049857cc04175dc3cca62121ee41adec6cdb8。HotspotSummary内含leader_stocks,HotspotDetail顶层仍是stocks,hotspot_detail_to_dict()仍只输出summary / stocks / timeline / route。因此 DSA 仍需在 API/cache/provider 边界补齐双字段,兼容旧缓存、降级缓存和 AlphaSift summary 内leader_stocks。参考:
改动
AlphaSiftService热点详情返回前统一补齐stocks与leader_stocks双字段,并按最终stocks刷新stock_count。leaderStocks可选字段。14e74fc...升级到377049857cc04175dc3cca62121ee41adec6cdb8,并同步requirements.txt、src/config.py、.env.example、专题文档和断言测试。.env.example与docs/alphasift-integration.md补充 AlphaSift 侧LLM_MAX_TOKENS、timeout 后不重复 JSON-mode 重试,以及迁移/回退边界。docs/CHANGELOG.md的[Unreleased]条目。验证
git diff --check/tmp/dsa-verify-venv/bin/python -m pip install --no-deps --force-reinstall 'git+https://github.com/ZhuLinsen/alphasift.git@377049857cc04175dc3cca62121ee41adec6cdb8#egg=alphasift'/tmp/dsa-verify-venv/bin/python -m py_compile src/services/alphasift_service.py src/config.py/tmp/dsa-verify-venv/bin/python -m pytest tests/test_alphasift_api.py tests/test_config_env_compat.py tests/test_docker_entrypoint.py tests/test_system_config_service.py -q:267 passed, 12 warnings/tmp/dsa-verify-venv/bin/python - <<'PY' ...smoke:DEFAULT_ALPHASIFT_INSTALL_SPEC指向3770498...、Config.from_env().llm_max_tokens == 2048、rank_candidates_with_metadata签名含max_tokenscd apps/dsa-web && npm run lint(升级 pin 前,同一 PR 的 Web wrapper 变更)cd apps/dsa-web && npm run test -- src/api/__tests__/alphasift.test.ts:10 passed(升级 pin 前,同一 PR 的 Web wrapper 变更)cd apps/dsa-web && npm ci && npm run build(升级 pin 前,同一 PR 的 Web wrapper 变更)d5727d1e):ai-governance、backend-gate、web-gate、docker-build、PR Review 相关检查均通过说明:本机系统 Python 的
anyio包不完整,后端 pytest 使用/tmp/dsa-verify-venv临时 venv 安装项目依赖后执行。未本地执行完整./scripts/ci_gate.sh,已以 GitHub Actionsbackend-gate作为完整后端 gate 证据。兼容性与风险
leader_stocks兼容字段,不改变既有stocks字段语义。stocks或leader_stocks其中一个字段,就会自动补齐另一个。.env里的旧ALPHASIFT_INSTALL_SPEC不会被静默改写;要使用新 pin 需清理旧覆盖值后重建依赖/重启,或按文档完整回退requirements.txt + src/config.py + .env.example。回滚
常规 revert 本 PR 即可。若只回滚 AlphaSift 版本,需要同时恢复
requirements.txt、src/config.py的DEFAULT_ALPHASIFT_INSTALL_SPEC、.env.example示例和相关测试断言到旧 pin,再重建依赖/镜像/桌面后端产物;仅改.env会被当前 install allow-list 拒绝。