HTML knowledge-base files lose every block boundary: get_text() welds the words together
まだ誰も着手していません。
評価
調査の方向性
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分
- マージ済み PR(30日)
- 611
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
langgenius/dify#42468 · コメント 1 件 · リアクション 1 件 ·
-
🐞 bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
langgenius/dify#42446 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
langgenius/dify#42355 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
langgenius/dify#42350 · コメント 1 件 · リアクション 1 件 ·
langgenius/dify の issue をすべて見る
似ている 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