Skip to content

Fix market review catalyst snippets - #1241

Merged
ZhuLinsen merged 2 commits into
mainfrom
fix/issue-1216-market-review-catalysts
May 10, 2026
Merged

Fix market review catalyst snippets#1241
ZhuLinsen merged 2 commits into
mainfrom
fix/issue-1216-market-review-catalysts

Conversation

@ZhuLinsen

Copy link
Copy Markdown
Owner

Summary

Fixes #1216.

  • Make the market review 近三日催化线索 table explicitly label search content as 摘要/线索片段.
  • Preserve longer title/snippet context and show source, published date, and URL when available.
  • Expand the prompt-side news context so the LLM receives source metadata instead of hard-truncated title/snippet text only.
  • Add a regression test for the rendered catalyst block and update the changelog.

Root Cause

The rendered market-review news table used a generic 关注点 column and hard-truncated search-result snippets, which could make partial search summaries look like complete event text and hide useful source context.

Validation

  • python -m py_compile src/market_analyzer.py
  • python -m pytest tests/test_market_analyzer_generate_text.py::TestMarketAnalyzerBypassFix::test_news_block_labels_snippets_and_preserves_source_url

Risks

  • This changes the report table wording and may slightly widen rendered market-review markdown tables.

Rollback

Revert this PR to restore the previous compact catalyst table rendering.

Copilot AI review requested due to automatic review settings May 9, 2026 14:29
@github-actions github-actions Bot added ai documentation Improvements or additions to documentation size/M testing labels May 9, 2026
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 3 个
➕ 新增行数 117 行
➖ 删除行数 21 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 docs/CHANGELOG.md (+1/-0)
  • 📝 src/market_analyzer.py (+50/-21)
  • 📝 tests/test_market_analyzer_generate_text.py (+66/-0)

🧠 AI 代码审查意见

结论

Ready to Merge

结构化结果

  • 必要性:通过。PR 描述清晰指出当前大盘复盘报告中“近三日催化线索”表存在关注点列名不明确、搜索摘要硬截断导致内容不完整及来源信息缺失的问题。本次修改旨在解决这些问题,提供更清晰、信息更完整的报告内容,并优化 LLM 输入,具有明确的业务价值。

  • 关联性:通过。PR 描述明确指出 "Fixes 推送的企业微信中的近三日催化线索文字缺失 #1216",与 Issue 关联性强。

  • 类型fix。PR 标题、描述以及 CHANGELOG.md 中的条目都表明这是一个修复现有报告展示问题的改动。

  • 描述完整性:基本完整。

    • 背景:已提供(Root Cause)。
    • 范围:已提供(Summary 列出了多项具体改动)。
    • 验证命令与结果:已提供验证命令,并且 CI 检查状态显示 py_compile 已通过。测试用例 test_news_block_labels_snippets_and_preserves_source_url 等也已添加,充分覆盖了主要改动。
    • 兼容性风险:已提供(Risks)。
    • 回滚方案:已提供(Rollback)。
    • 缺失项:对 Python 后端改动,PR 描述未说明 ./scripts/ci_gate.sh 是否执行或给出跳过原因。此为建议项,不构成阻断。
  • 风险级别:低。

    • 关键风险:描述中提及可能改变报告表格措辞和略微加宽表格,这些是用户可见的 UI 变化,但对于提供更完整的信息而言是可接受的,且影响范围有限。代码逻辑修改引入了新的辅助方法和文本处理逻辑,但有充分的测试覆盖,降低了引入新 Bug 的风险。

必改项

无。

建议项

  1. 对 Python 后端改动,建议在 PR 描述中说明 ./scripts/ci_gate.sh 的执行情况,或给出跳过原因。这有助于确保代码符合更全面的静态分析规范。
  2. tests/test_market_analyzer_generate_text.py 中新添加的测试类命名为 TestMarketAnalyzerBypassFix 可能有歧义,因为它不是用于绕过而是用于测试修复。可以考虑更明确的名称,例如 TestMarketAnalyzerNewsBlockFixTestMarketAnalyzerCatalystSnippetsFix。但这只是风格建议,不影响功能。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec7028e06a

ℹ️ 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".

Comment thread src/market_analyzer.py Outdated
snippet = self._compact_news_text(self._get_news_field(n, "snippet"), limit=220)
source = self._compact_news_text(self._get_news_field(n, "source"), limit=60)
published_date = self._compact_news_text(self._get_news_field(n, "published_date"), limit=30)
url = self._get_news_field(n, "url")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound raw news URLs before prompting

When a search provider returns long tracking URLs or redirect URLs with large query strings, this now copies the raw URL into the LLM prompt for up to six news items. The title and snippet are capped, but the URL is not, so a few long result URLs can dominate or exceed the model context and increase cost or cause generation failures; please cap or omit the prompt URL while still preserving the rendered report metadata.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the market review “近三日催化线索” catalyst news block rendering so that snippets are clearly labeled as excerpts and the report/prompt preserves more source metadata (source, date, URL), addressing #1216.

Changes:

  • Updated the rendered catalyst table headers (ZH/EN) and widened title/snippet limits to reduce misleading truncation.
  • Added source/date/URL formatting in the rendered table and expanded the LLM prompt-side news context to include metadata.
  • Added a regression test for the catalyst table rendering and updated docs/CHANGELOG.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/market_analyzer.py Reworks catalyst table rendering and prompt news context; adds helpers for field extraction, compaction, and source cell formatting.
tests/test_market_analyzer_generate_text.py Adds a regression test ensuring snippet column label and source/date/URL link rendering are correct.
docs/CHANGELOG.md Records the user-visible fix to catalyst snippet/source/URL presentation.

Comment thread src/market_analyzer.py Outdated
Comment on lines +774 to +776
label = " / ".join(label_parts) or "source"
if url:
return f"[{label}]({url})"

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过。该 PR 针对 #1216 中大盘复盘催化线索表格语义不清、摘要被硬截断的问题做定向修复,范围合理。
  • 是否有对应 issue:有,Fixes #1216
  • PR 类型:fix。修复报告渲染与 prompt 新闻上下文中的摘要/来源展示问题,并补充回归测试。
  • description 完整性:完整。已包含 Summary、Root Cause、Validation、Risks、Rollback,符合本仓库对 fix 类 PR 的说明要求。
  • 是否可直接合入:可。当前 CI 成功,docs/CHANGELOG.md 已按 [Unreleased] 扁平格式补充变更记录,未发现需要阻断合入的行为或兼容性问题;mergeable_state=blocked 不单独构成阻断点。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen
ZhuLinsen merged commit 53a617a into main May 10, 2026
10 checks passed
cwjyu pushed a commit to cwjyu/daily_stock_analysis that referenced this pull request May 10, 2026
* fix: preserve market review catalyst details
zbl-96 pushed a commit to zbl-96/daily_stock_analysis that referenced this pull request May 10, 2026
* fix: preserve market review catalyst details
EchoingFootsteps pushed a commit to EchoingFootsteps/daily_stock_analysis that referenced this pull request Jul 4, 2026
* fix: preserve market review catalyst details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai documentation Improvements or additions to documentation size/M testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

推送的企业微信中的近三日催化线索文字缺失

2 participants