mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-13 00:14:02 +00:00
test(graphrag): pin that identical pages collapse into one
Review asked whether two document rows with the same text and metadata should stay two pages. They should not: the caller gets four pages to hand a model, and a crawl that ingested the same text twice would spend two of them on it. The rows differ only by an id the model never sees. Pinned either way now.
This commit is contained in:
1 parent
692edcdd4e
commit
63d93fc4b9
1 file changed
+28
@@ -724,6 +724,34 @@ class TestEntityPagesLive:
|
||||
store.delete_by_source(source_id)
|
||||
|
||||
|
||||
def test_two_chunks_with_identical_text_collapse_into_one_page(self, store):
|
||||
"""Deliberate: the caller gets at most four pages to hand a model, and a
|
||||
crawl that ingested the same text twice would spend two of them saying
|
||||
the same thing. The rows differ only by an id the model never sees."""
|
||||
source_id = str(uuid.uuid4())
|
||||
conn = store._get_connection()
|
||||
cursor = conn.cursor()
|
||||
chunk_ids = []
|
||||
for _ in range(2):
|
||||
cursor.execute(
|
||||
"INSERT INTO documents (text, metadata, source_id) VALUES (%s, %s, %s) RETURNING id;",
|
||||
("Quill is a write-ahead store.", Jsonb({"title": "quill.md"}), source_id),
|
||||
)
|
||||
chunk_ids.append(str(cursor.fetchone()[0]))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
try:
|
||||
node = store.upsert_node(source_id, "Quill", "quill")
|
||||
for chunk_id in chunk_ids:
|
||||
store.link_node_chunk(source_id, node, chunk_id)
|
||||
|
||||
pages = store.entity_pages(source_id, "Quill", limit=4)
|
||||
|
||||
assert [page["text"] for page in pages] == ["Quill is a write-ahead store."]
|
||||
finally:
|
||||
store.delete_by_source(source_id)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestGraphReadQueries:
|
||||
"""The reads behind fact seeding and the agent's graph tool, without a DB.
|
||||
|
||||
Reference in new issue
Block a user