HTML knowledge-base files lose every block boundary: get_text() welds the words together
还没有人认领这个 Issue。
评估
调研方向
Start in api/core/rag/extractor/html_extractor.py at HtmlExtractor._load_as_text, then inspect the existing HTML extractor test that currently checks only that characters survive. Run that test and reproduce the provided HTML example; done means block-level boundaries remain separate while inline text keeps its spacing and punctuation.
由索引模型根据 Issue 内容生成。
描述
Self Checks
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report.
- [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- Please do not modify this template :) and fill in all the required fields.
Dify version
main (api/core/rag/extractor/html_extractor.py)
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
Upload an ordinary .html file to a knowledge base — or call the extractor
directly:
from core.rag.extractor.html_extractor import HtmlExtractor
# <h1>Quarterly Report</h1><p>Revenue rose.</p><p>Costs fell.</p>
# <ul><li>Item one</li><li>Item two</li></ul>
print(HtmlExtractor("report.html")._load_as_text())
✔️ Expected Behavior
One block per line, the way the page reads:
Quarterly Report
Revenue rose.
Costs fell.
Item one
Item two
❌ Actual Behavior
Quarterly ReportRevenue rose.Costs fell.Item oneItem two
_load_as_text returns soup.get_text(), which concatenates every text node
with nothing in between. A page's block structure lives in the markup, not in the
text, so every boundary disappears and the words on either side are welded into
one: ReportRevenue, fell.Item, oneItem.
That string is what gets chunked and embedded. ReportRevenue is not a word in
any vocabulary, so the chunk that holds the heading is not retrievable by the
heading, and a chunk boundary can now fall in the middle of what used to be two
separate blocks.
The existing test pins only that the characters survive —
"".join(page_content.split()) == "TitleHello" — which is true either way, so
nothing catches it today.
Note for whoever picks this up: the obvious fix is wrong. get_text(" ") or
get_text("\n") also inserts the separator between inline elements, so
<p>Hello <b>world</b>! See <a href="#">this</a>.</p> turns into
Hello world ! See this . The end of each block-level element has to be marked
instead.
I have a patch ready with tests for both halves and will open the PR against this
issue.
- 主要语言
- TypeScript
- 星标
- 157k
- 派生
- 24.7k
- 平均合并
- 22 小时 32 分钟
- 30 天内合并 PR
- 611
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langgenius/dify 的其他 Issue
-
Annotation Reply: a stored score threshold of 0.0 is silently replaced with 1, disabling the feature 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42639 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 70/100
langgenius/dify#42468 · 1 条评论 · 1 个 reaction ·
-
🐞 bug
难度 2/5 1-3 小时 新手友好度 86/100
langgenius/dify#42446 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42355 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42350 · 1 条评论 · 1 个 reaction ·
相似的 Issue
-
calcite-components needs triage refactor
难度 2/5 1-3 小时 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
难度 2/5 1-3 小时 新手友好度 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/studio#4908 ·
-
难度 2/5 1-3 小时 新手友好度 90/100