From a52c8502d72cb8b1db7776078f5516991e8fbf98 Mon Sep 17 00:00:00 2001 From: zhulinsen <42829555+ZhuLinsen@users.noreply.github.com> Date: Fri, 3 Jul 2026 21:00:12 +0800 Subject: [PATCH] fix: harden AlphaSift timeout handling (#1898) --- .env.example | 11 ++++++++++- apps/dsa-web/src/pages/StockScreeningPage.tsx | 13 ++++++++++++- .../src/pages/__tests__/StockScreeningPage.test.tsx | 3 ++- docs/CHANGELOG.md | 1 + docs/alphasift-integration.md | 13 +++++++------ requirements.txt | 2 +- src/config.py | 2 +- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 9d0f39831..d8c5ddd0b 100644 --- a/.env.example +++ b/.env.example @@ -34,7 +34,7 @@ ALPHASIFT_ENABLED=false # - ALPHASIFT_ENABLED 只影响 AlphaSift 选股流程,不会改写/迁移/清理现有 LITELLM_*/LLM_* 配置。 # - 关闭/回退只需将 ALPHASIFT_ENABLED 置 false;现有 provider/base_url/custom headers 与 fallback 语义保持原状。 # - 兼容依据(运维核验):LiteLLM providers 与 OpenAI-compatible 语义说明见下方注释;运行时默认使用 requirements.txt 中固定 litellm 版本。 -ALPHASIFT_INSTALL_SPEC=git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e81718f851890535241bc105d4ddc64 +ALPHASIFT_INSTALL_SPEC=git+https://github.com/ZhuLinsen/alphasift.git@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf # 兼容说明: # - ALPHASIFT_INSTALL_SPEC 仅用于显式调用 /api/v1/alphasift/install;不会自动覆盖历史 .env 配置。 # - 升级后想使用新 pin,请清理旧 `.env` 中该变量后重建依赖/重启服务;或直接改为上方默认值并重建后端。 @@ -44,6 +44,15 @@ ALPHASIFT_INSTALL_SPEC=git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e # - 无 TUSHARE_TOKEN:sina,efinance,akshare_em,em_datacenter # SNAPSHOT_SOURCE_PRIORITY=tushare,sina,efinance,akshare_em,em_datacenter # (若希望保持与运行时自动注入一致,建议仅留空,不在该文件中固定值) +# AlphaSift 第三方 wrapper 数据源调用超时护栏;避免 efinance/AkShare/Baostock/Tushare/yfinance 卡住时拖慢整次选股。 +# - ALPHASIFT_SOURCE_CALL_TIMEOUT_SEC 为全局兜底;设为 0/off/disabled 可关闭 caller-side timeout。 +# - SNAPSHOT/Daily 专项值优先于全局值;默认分别为 60s / 20s。 +# ALPHASIFT_SOURCE_CALL_TIMEOUT_SEC= +# ALPHASIFT_SNAPSHOT_CALL_TIMEOUT_SEC=60 +# ALPHASIFT_DAILY_CALL_TIMEOUT_SEC=20 +# AlphaSift 东财直连请求限速与随机抖动;降低连续 fallback/热点刷新时的连接抖动。 +# ALPHASIFT_EASTMONEY_MIN_INTERVAL_SEC=1.0 +# ALPHASIFT_EASTMONEY_JITTER_SEC=0.3 # AlphaSift 最新版支持 last-good 快照、日线历史和行业/概念 provider 缓存;DSA 运行时默认使用 data/alphasift 下的隔离缓存目录。 # 如需自定义,可覆盖以下路径;留空不会改写既有 DSA 配置。 # ALPHASIFT_DATA_DIR=data/alphasift diff --git a/apps/dsa-web/src/pages/StockScreeningPage.tsx b/apps/dsa-web/src/pages/StockScreeningPage.tsx index f51a51861..8980a6de1 100644 --- a/apps/dsa-web/src/pages/StockScreeningPage.tsx +++ b/apps/dsa-web/src/pages/StockScreeningPage.tsx @@ -95,6 +95,16 @@ const clearPersistedScreenTask = () => { const isUnrecoverableScreenTaskError = (error: ParsedApiError) => error.title === '选股任务不可恢复'; +const formatRecoverableScreenTaskPollingError = (error: ParsedApiError) => { + if (error.category === 'upstream_timeout') { + return '选股任务仍在后台运行,状态轮询暂时超时,将自动重试。'; + } + if (error.category === 'upstream_network' || error.category === 'local_connection_failed') { + return '选股任务仍在后台运行,暂时无法连接本地服务获取状态,将自动重试。'; + } + return formatParsedApiError(error) || '暂时无法获取选股任务状态,稍后将自动重试。'; +}; + const formatScore = (score: AlphaSiftCandidate['score']) => { if (score == null || Number.isNaN(Number(score))) { return '-'; @@ -734,13 +744,14 @@ const StockScreeningPage: React.FC = () => { return; } const parsedError = getParsedApiError(err); - setError(formatParsedApiError(parsedError) || '暂时无法获取选股任务状态,稍后将自动重试。'); if (isUnrecoverableScreenTaskError(parsedError)) { + setError(formatParsedApiError(parsedError) || '选股任务不可恢复,请重新提交。'); setCandidates([]); setScreenMeta(null); finishTask(); return; } + setError(formatRecoverableScreenTaskPollingError(parsedError)); setLoading(true); timer = window.setTimeout(pollTask, SCREEN_TASK_POLL_INTERVAL_MS); } diff --git a/apps/dsa-web/src/pages/__tests__/StockScreeningPage.test.tsx b/apps/dsa-web/src/pages/__tests__/StockScreeningPage.test.tsx index fe33c310e..e4bb41256 100644 --- a/apps/dsa-web/src/pages/__tests__/StockScreeningPage.test.tsx +++ b/apps/dsa-web/src/pages/__tests__/StockScreeningPage.test.tsx @@ -906,7 +906,8 @@ describe('StockScreeningPage', () => { expect(await screen.findByText('选股任务运行中')).toBeInTheDocument(); await waitFor(() => expect(getScreenTask).toHaveBeenCalledTimes(1)); expect(screen.getByText('选股运行中')).toBeInTheDocument(); - expect(screen.getByText(/连接上游服务超时/)).toBeInTheDocument(); + expect(screen.getByText('选股任务仍在后台运行,状态轮询暂时超时,将自动重试。')).toBeInTheDocument(); + expect(screen.queryByText(/连接上游服务超时/)).not.toBeInTheDocument(); expect(window.sessionStorage.getItem('dsa.alphasift.activeScreenTask.v1')).toContain('screen-task-1'); }); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8a840d868..5b113d8d4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - [修复] 修复桌面端启动时 `.env` 中 `WEBUI_PORT` 与 Electron 自动选择端口不一致会导致窗口继续等待旧端口并连接超时的问题。 - [修复] A 股个股分析遇到空 `belong_boards` 占位时会继续补查所属板块,关联板块模块在已有板块时稳定展示;对应涨跌幅缺失时只显示板块,不再输出占位涨跌幅。 - [修复] 大盘复盘在 LLM 标题漂移或正文缺少板块段时,会从结构化 `sectors` 兜底渲染板块表,避免 Web 与推送报告偶发缺少板块主线。 +- [改进] AlphaSift 默认依赖 pin 更新到 `9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf`,接入 wrapper 数据源 caller-side timeout、东财直连限速/抖动、策略目录元数据与新增防守策略;选股任务状态轮询遇到可恢复超时时改为提示后台任务仍会自动重试,`.env.example` 补充相关超时调优项,降低外部数据源卡住时触发 Web 30 秒等待超时的概率。 diff --git a/docs/alphasift-integration.md b/docs/alphasift-integration.md index 25d55de1e..a02e65e65 100644 --- a/docs/alphasift-integration.md +++ b/docs/alphasift-integration.md @@ -8,7 +8,7 @@ AlphaSift 作为独立仓库维护的选股引擎接入 DSA。DSA 默认不启 - 默认关闭:`ALPHASIFT_ENABLED=false`。 - 启用入口:设置页或选股页点击开启,或在 `.env` 中配置 `ALPHASIFT_ENABLED=true`。 -- 依赖来源:`requirements.txt` 固定到已验证的 AlphaSift 适配层 commit:`git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e81718f851890535241bc105d4ddc64#egg=alphasift`(对应提交 `https://github.com/ZhuLinsen/alphasift/commit/0a7b9cd59e81718f851890535241bc105d4ddc64`,覆盖 PR `https://github.com/ZhuLinsen/alphasift/pull/16`、`https://github.com/ZhuLinsen/alphasift/pull/19`、`https://github.com/ZhuLinsen/alphasift/pull/22`、`https://github.com/ZhuLinsen/alphasift/pull/23`、`https://github.com/ZhuLinsen/alphasift/pull/24`、`https://github.com/ZhuLinsen/alphasift/pull/25`、`https://github.com/ZhuLinsen/alphasift/pull/26`、`https://github.com/ZhuLinsen/alphasift/pull/28`、`https://github.com/ZhuLinsen/alphasift/pull/29`、`https://github.com/ZhuLinsen/alphasift/pull/30`、`https://github.com/ZhuLinsen/alphasift/pull/31`、`https://github.com/ZhuLinsen/alphasift/pull/32`、`https://github.com/ZhuLinsen/alphasift/pull/33` 与 `https://github.com/ZhuLinsen/alphasift/pull/35`)。该来源覆盖 `alphasift.dsa_adapter` 契约、`screen/list_strategies/get_status` 调用、Tencent 日 K、Sina snapshot、source health、stale daily fallback、候选级 quote context、日线数据源健康度/降级诊断、硬过滤瀑布诊断、策略评估摘要、题材匹配得分,以及 LLM ranking 的 `LLM_MAX_TOKENS` 输出上限、timeout 后不重复 JSON-mode 重试和更稳健的 JSON 解析边界。 +- 依赖来源:`requirements.txt` 固定到已验证的 AlphaSift 适配层 commit:`git+https://github.com/ZhuLinsen/alphasift.git@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf#egg=alphasift`(对应提交 `https://github.com/ZhuLinsen/alphasift/commit/9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf`,覆盖 PR `https://github.com/ZhuLinsen/alphasift/pull/16`、`https://github.com/ZhuLinsen/alphasift/pull/19`、`https://github.com/ZhuLinsen/alphasift/pull/22`、`https://github.com/ZhuLinsen/alphasift/pull/23`、`https://github.com/ZhuLinsen/alphasift/pull/24`、`https://github.com/ZhuLinsen/alphasift/pull/25`、`https://github.com/ZhuLinsen/alphasift/pull/26`、`https://github.com/ZhuLinsen/alphasift/pull/28`、`https://github.com/ZhuLinsen/alphasift/pull/29`、`https://github.com/ZhuLinsen/alphasift/pull/30`、`https://github.com/ZhuLinsen/alphasift/pull/31`、`https://github.com/ZhuLinsen/alphasift/pull/32`、`https://github.com/ZhuLinsen/alphasift/pull/33`、`https://github.com/ZhuLinsen/alphasift/pull/35`、`https://github.com/ZhuLinsen/alphasift/pull/36` 与 `https://github.com/ZhuLinsen/alphasift/pull/37`)。该来源覆盖 `alphasift.dsa_adapter` 契约、`screen/list_strategies/get_status` 调用、Tencent 日 K、Sina snapshot、source health、stale daily fallback、候选级 quote context、wrapper 数据源 caller-side timeout、东财直连限速与抖动、日线数据源健康度/降级诊断、硬过滤瀑布诊断、策略评估摘要、题材匹配得分、策略目录元数据、`blue_chip_income` / `low_volatility_quality` 策略,以及 LLM ranking 的 `LLM_MAX_TOKENS` 输出上限、timeout 后不重复 JSON-mode 重试和更稳健的 JSON 解析边界。 - 修复安装来源:`ALPHASIFT_INSTALL_SPEC` 仍保留,默认等于同一个受信任 commit。它不再是策略列表或选股接口的运行时安装主路径,只用于显式调用 `/api/v1/alphasift/install` 时做修复安装和来源校验;未显式配置时才按代码常量 `DEFAULT_ALPHASIFT_INSTALL_SPEC` 回退。 - 迁移边界(显式 `.env` 优先): - 若 `.env` 中显式保留旧 pin(如 `...de54ea0da367be85770d9589a5bf7ded4f62d386`),DSA 会把该值当作用户覆盖,不会在运行期自动替换为新 pin; @@ -23,7 +23,7 @@ AlphaSift 作为独立仓库维护的选股引擎接入 DSA。DSA 默认不启 ## 外部契约来源与迁移边界 -- 外部契约依据:本次 AlphaSift 运行契约(含 `schema_version=2` 的热点缓存与题材详情字段)对应 GitHub 提交 `https://github.com/ZhuLinsen/alphasift/commit/0a7b9cd59e81718f851890535241bc105d4ddc64`。 +- 外部契约依据:本次 AlphaSift 运行契约(含 `schema_version=2` 的热点缓存与题材详情字段)对应 GitHub 提交 `https://github.com/ZhuLinsen/alphasift/commit/9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf`。 该 commit 在 DSA 中通过以下链路生效:`requirements.txt` 安装 pin、`src/config.py` 默认 `DEFAULT_ALPHASIFT_INSTALL_SPEC`、`.env.example` 默认示例值。 - 升级路径: - 部署侧只需按部署方式 `git pull` + `pip install -r requirements.txt` + 重启服务; @@ -39,7 +39,8 @@ AlphaSift 作为独立仓库维护的选股引擎接入 DSA。DSA 默认不启 - 日 K 线补特征:DSA 调用 AlphaSift 时会优先复用 DSA 历史行情加载链路(数据库缓存、Tushare、Efinance、Akshare、Pytdx、Baostock、Yfinance 等 fallback),仅在 DSA 链路无可用数据时回退到 AlphaSift 原始日线数据源,减少单一上游超时拖垮选股。 - LLM 环境:DSA 调用 AlphaSift 时会桥接 DSA 已解析的 `LITELLM_MODEL`、`LITELLM_FALLBACK_MODELS`、`LLM_CHANNELS`、`LLM__*`、`LITELLM_CONFIG`、渠道额外请求头和各模型密钥;AlphaSift 独立运行时仍使用自己的 `.env`/环境变量。`LLM_TIMEOUT_SEC` 与 `LLM_MAX_TOKENS` 可被 AlphaSift 选股 LLM 重排读取,分别限制单次请求耗时和输出 token 上限。 - 快照源:DSA 调用 AlphaSift 时,未显式配置 `SNAPSHOT_SOURCE_PRIORITY` 会按 token-aware 顺序注入:有 `TUSHARE_TOKEN` 时为 `tushare,sina,efinance,akshare_em,em_datacenter`,无 token 时为 `sina,efinance,akshare_em,em_datacenter`;同时注入 `DAILY_SOURCE=auto`、`DAILY_FETCH_RETRIES=3`、`DAILY_FETCH_MAX_WORKERS=1` 和默认候选上下文 `news,fund_flow,announcement,quote`。显式配置的源顺序、日线源和候选上下文 provider 会原样保留。 -- 最新 AlphaSift 能力:锁定 commit `0a7b9cd59e81718f851890535241bc105d4ddc64` 包含选股 pipeline 性能优化、Tencent 日 K、Sina snapshot、source health、stale daily fallback、candidate quote context、LLM ranking timeout/max tokens 边界、last-good snapshot fallback、日线历史缓存、行业/概念 provider cache、热点/行业热度因子、hotspot 热点题材榜单、本地 scorecard/post-analysis 元信息、日线数据源健康度排序与告警、硬过滤瀑布诊断、策略评估摘要、多窗口价格路径评估和题材匹配得分。DSA 调用时会注入隔离缓存默认路径 `data/alphasift`、`data/alphasift/snapshot.last_good.json`、`data/alphasift/daily_history`、`data/alphasift/industry_provider_cache`;Web 选股页提供“热点题材”手动刷新入口,请求 `/api/v1/alphasift/hotspots` 时会显式使用 `akshare` provider 优先拉取具体概念/题材异动(例如钼、铅锌、铜、诊断服务等实时板块异动),行业板块仅作为兜底;默认打开页面时优先读取上一次成功且不少于 3 条的热点题材缓存,点击刷新才实时拉取并覆盖缓存,实时拉取失败时会尽量回退旧缓存;如果 AlphaSift 合约层只返回少量或缺少涨跌幅等关键字段的热点,DSA 会用东方财富板块异动直连榜单替代。点击题材会请求 `/api/v1/alphasift/hotspots/{topic}` 展示发酵路线与概念股;题材详情另有 DSA 侧 30 分钟磁盘缓存,路径为 `data/alphasift/hotspot_details` 或自定义 `ALPHASIFT_DATA_DIR/hotspot_details`,重复点开同一题材会优先返回缓存,实时详情失败时可回退过期缓存;手动刷新热点榜单并保留当前题材时会对详情请求传入 `refresh=true` 绕过详情缓存;不会默认触发 AlphaSift 的 DSA deep-analysis 回调,避免无提示扩大递归调用面。 +- 外部数据源超时护栏:AlphaSift 对 efinance、AkShare、Baostock、Tushare、yfinance 等第三方 wrapper 源增加 caller-side timeout;`ALPHASIFT_SNAPSHOT_CALL_TIMEOUT_SEC` 默认 60 秒,`ALPHASIFT_DAILY_CALL_TIMEOUT_SEC` 默认 20 秒,`ALPHASIFT_SOURCE_CALL_TIMEOUT_SEC` 可作为全局兜底,设为 `0`/`off`/`disabled` 可关闭。超时后会记录 source health 与 `last_error`,并继续尝试后续数据源或 last-good / daily history fallback,减少一次 wrapper 卡死拖垮整次选股。 +- 最新 AlphaSift 能力:锁定 commit `9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf` 包含选股 pipeline 性能优化、Tencent 日 K、Sina snapshot、source health、stale daily fallback、candidate quote context、wrapper 数据源 caller-side timeout、东财直连共享重试会话/限速/随机抖动、LLM ranking timeout/max tokens 边界、last-good snapshot fallback、日线历史缓存、行业/概念 provider cache、热点/行业热度因子、hotspot 热点题材榜单、本地 scorecard/post-analysis 元信息、日线数据源健康度排序与告警、硬过滤瀑布诊断、策略评估摘要、多窗口价格路径评估、题材匹配得分、策略目录元数据、`blue_chip_income` 与 `low_volatility_quality` 策略。DSA 调用时会注入隔离缓存默认路径 `data/alphasift`、`data/alphasift/snapshot.last_good.json`、`data/alphasift/daily_history`、`data/alphasift/industry_provider_cache`;Web 选股页提供“热点题材”手动刷新入口,请求 `/api/v1/alphasift/hotspots` 时会显式使用 `akshare` provider 优先拉取具体概念/题材异动(例如钼、铅锌、铜、诊断服务等实时板块异动),行业板块仅作为兜底;默认打开页面时优先读取上一次成功且不少于 3 条的热点题材缓存,点击刷新才实时拉取并覆盖缓存,实时拉取失败时会尽量回退旧缓存;如果 AlphaSift 合约层只返回少量或缺少涨跌幅等关键字段的热点,DSA 会用东方财富板块异动直连榜单替代。点击题材会请求 `/api/v1/alphasift/hotspots/{topic}` 展示发酵路线与概念股;题材详情另有 DSA 侧 30 分钟磁盘缓存,路径为 `data/alphasift/hotspot_details` 或自定义 `ALPHASIFT_DATA_DIR/hotspot_details`,重复点开同一题材会优先返回缓存,实时详情失败时可回退过期缓存;手动刷新热点榜单并保留当前题材时会对详情请求传入 `refresh=true` 绕过详情缓存;不会默认触发 AlphaSift 的 DSA deep-analysis 回调,避免无提示扩大递归调用面。 - 热点刷新容错:`/api/v1/alphasift/hotspots` 未显式传入 provider 且未配置 `INDUSTRY_PROVIDER` 时,默认使用 DSA EastMoney 兜底 provider(响应中 provider 为 `akshare`),避免落到 AlphaSift 的空 provider 路径;东方财富热点直连源遇到连接中断、超时或 `Connection aborted` 会做短 backoff 重试;手动刷新失败且没有可用热点缓存时返回稳定空态 payload、`source_errors=["eastmoney_hotspot_unavailable"]` 和用户可读 `message`,原始异常仅保留在服务端日志或诊断链路中。桌面端更新会保留 `data/alphasift/hotspots.json`、`data/alphasift/hotspot.history.jsonl`、`data/alphasift/hotspot_details` 与 `data/alphasift/snapshot.last_good.json`,避免更新后丢失 last-good 缓存。 - 热点数据源补充:DSA provider 使用直连 HTTP 思路,东财板块兜底源使用 `push2.eastmoney.com/api/qt/clist/get` 并保留涨跌幅、领涨股、上涨/下跌家数等字段;题材详情会在一次 provider 生命周期内缓存并合并东方财富成分股、同花顺页面解析和板块异动龙头兜底,优先返回多只概念股,发酵路线按日期聚合展示,避免把同一盘中观察拆成多条同时间节点;事件催化不再使用 DSA 内置静态文案,只展示 AlphaSift 合约时间线、同花顺摘要、已配置新闻搜索源或东财板块异动结构拿到的真实信息;新闻搜索命中的消息会优先通过已配置 LLM 压缩成一句题材催化摘要,LLM 不可用时回退本地短摘要,避免在时间线中展示完整报道。 - 风险提示:前端设置页和选股页展示第三方来源与投资风险说明;不会弹窗打断用户。 @@ -123,7 +124,7 @@ context = { AlphaSift 会在 L1 初筛后、LLM 重排前调用 `context["dsa"]` 中的 provider,为有限 Top 候选补充 DSA 行情和基本面轻量上下文,并把 `dsa_context` 随候选返回。新闻搜索、完整摘要和缺失字段补全由 DSA API 在最终 Top 候选阶段执行;若候选已经携带完整新闻上下文,DSA API 返回阶段会复用这些字段,避免重复请求。 -AlphaSift 侧已在 `ZhuLinsen/alphasift@0a7b9cd59e81718f851890535241bc105d4ddc64` 提供 DSA provider context 支持、DSA adapter contract,并支持复用 DSA 的 `LLM_TIMEOUT_SEC`;同一 pin 还会读取 `LLM_MAX_TOKENS` 限制 LLM 重排输出,且 timeout 后不再盲目重试无 JSON mode 请求。 +AlphaSift 侧已在 `ZhuLinsen/alphasift@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf` 提供 DSA provider context 支持、DSA adapter contract,并支持复用 DSA 的 `LLM_TIMEOUT_SEC`;同一 pin 还会读取 `LLM_MAX_TOKENS` 限制 LLM 重排输出,且 timeout 后不再盲目重试无 JSON mode 请求。`dsa_adapter` 稳定契约仍只返回 DSA 已消费的策略基础字段和选股结果字段;上游新增的 strategy facets、overview、本地只读 API 和策略卡片能力暂不进入 DSA API 契约。 ## DSA 后端行为 @@ -137,7 +138,7 @@ AlphaSift 侧已在 `ZhuLinsen/alphasift@0a7b9cd59e81718f851890535241bc105d4ddc6 ## 配置兼容边界(LLM / LiteLLM / Base URL) - 兼容语义与版本证据(可追溯): - - 运行依赖约束:`requirements.txt` 中将 LiteLLM 固定到 `litellm>=1.80.10,!=1.82.7,!=1.82.8,<2.0.0`,并通过 `git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e81718f851890535241bc105d4ddc64` 安装 AlphaSift 适配层。 + - 运行依赖约束:`requirements.txt` 中将 LiteLLM 固定到 `litellm>=1.80.10,!=1.82.7,!=1.82.8,<2.0.0`,并通过 `git+https://github.com/ZhuLinsen/alphasift.git@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf` 安装 AlphaSift 适配层。 - 文档依据: - LiteLLM Providers: https://docs.litellm.ai/docs/providers - LiteLLM OpenAI-compatible: https://docs.litellm.ai/docs/providers/openai_compatible @@ -170,7 +171,7 @@ AlphaSift 侧已在 `ZhuLinsen/alphasift@0a7b9cd59e81718f851890535241bc105d4ddc6 - 依赖与源码约束核验:`requirements.txt` 中的 `litellm` 约束与 `src/config.py`/`requirements.txt` 一致。 - Hotspot 契约兼容核验:`docs/alphasift-integration.md` 与 `api/v1/endpoints/alphasift.py`、`src/services/alphasift_service.py` 保持 `hotspots`/`hotspots/{topic}` 字段与 `tests/test_alphasift_api.py` 一致,调用前后默认使用 `snapshot.last_good` 缓存兜底。 -- 外部版本来源:本次集成依赖来源为 `https://github.com/ZhuLinsen/alphasift/commit/0a7b9cd59e81718f851890535241bc105d4ddc64`,需在复验时按该 commit pin 回放导入与接口契约。 +- 外部版本来源:本次集成依赖来源为 `https://github.com/ZhuLinsen/alphasift/commit/9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf`,需在复验时按该 commit pin 回放导入与接口契约。 - 行为核验:`src/services/alphasift_service.py` 的 `_build_alphasift_runtime_env` 与 `_build_alphasift_context` 仅在调用期写入进程环境;`/api/v1/alphasift/screen`、`strategies`、`status` 在运行期不回写 `.env`。 - 回退核验:关闭 `ALPHASIFT_ENABLED` 并重启配置链路后,系统恢复原始 `LITELLM_MODEL/FALLBACK_MODELS`、`LLM_CHANNELS` 与 `LLM_*` 运行语义,不执行迁移清理脚本。 - 语义来源核验:LiteLLM 文档(https://docs.litellm.ai/docs/providers)、OpenAI-compatible 文档(https://docs.litellm.ai/docs/providers/openai_compatible)与 LiteLLM 配置文档(https://docs.litellm.ai/docs/proxy/configs)用于核对 provider/model/base_url/extra_headers 映射链路。 diff --git a/requirements.txt b/requirements.txt index 9a89b4d9c..31276d261 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ longbridge==0.2.74; platform_system == "Linux" and python_version < "3.12" longbridge>=4.0.5,<5; platform_system != "Linux" or python_version >= "3.12" tickflow>=0.1.24 # TickFlow official SDK; 0.1.24 verified for klines/get batch quotes/universes # Built-in optional AlphaSift screening engine -git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e81718f851890535241bc105d4ddc64#egg=alphasift +git+https://github.com/ZhuLinsen/alphasift.git@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf#egg=alphasift # Feishu lark-oapi>=1.0.0 # Feishu API diff --git a/src/config.py b/src/config.py index b94ba4835..ffaa77a9d 100644 --- a/src/config.py +++ b/src/config.py @@ -74,7 +74,7 @@ from src.scheduler import normalize_schedule_times logger = logging.getLogger(__name__) DEFAULT_ALPHASIFT_INSTALL_SPEC = ( - "git+https://github.com/ZhuLinsen/alphasift.git@0a7b9cd59e81718f851890535241bc105d4ddc64" + "git+https://github.com/ZhuLinsen/alphasift.git@9f522747caafd3c0b1ddb7e14d5cf44c8580b6cf" )