Skip to content

Commit 063c018

Browse files
committed
Fix basic search context and id mapping
1 parent 4b202f2 commit 063c018

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

graphrag/prompts/query/basic_search_system_prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Sources (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Sources (1, 3)]"
2929
30-
where 1, 2, 3, 7, 34, 46, and 64 represent the source id taken from the "source_id" column in the provided tables.
30+
where 1, 2, 3, 7, 34, 46, and 64 represent the source id taken from the "id" column in the provided tables.
3131
3232
Do not include information where the supporting evidence for it is not provided.
3333
@@ -60,7 +60,7 @@
6060
6161
"Person X is the owner of Company Y and subject to many allegations of wrongdoing [Data: Sources (2, 7, 64, 46, 34, +more)]. He is also CEO of company X [Data: Sources (1, 3)]"
6262
63-
where 1, 2, 3, 7, 34, 46, and 64 represent the source id taken from the "source_id" column in the provided tables.
63+
where 1, 2, 3, 7, 34, 46, and 64 represent the source id taken from the "id" column in the provided tables.
6464
6565
Do not include information where the supporting evidence for it is not provided.
6666

graphrag/query/structured_search/basic_search/basic_context.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(
3838
self.text_units = text_units
3939
self.text_unit_embeddings = text_unit_embeddings
4040
self.embedding_vectorstore_key = embedding_vectorstore_key
41-
self.text_id_map = self._map_ids()
4241

4342
def build_context(
4443
self,
@@ -48,7 +47,7 @@ def build_context(
4847
max_context_tokens: int = 12_000,
4948
context_name: str = "Sources",
5049
column_delimiter: str = "|",
51-
text_id_col: str = "source_id",
50+
text_id_col: str = "id",
5251
text_col: str = "text",
5352
**kwargs,
5453
) -> ContextBuilderResult:
@@ -63,7 +62,7 @@ def build_context(
6362
text_unit_ids = {t.document.id for t in related_texts}
6463
text_units_filtered = []
6564
text_units_filtered = [
66-
{text_id_col: t.id, text_col: t.text}
65+
{text_id_col: t.short_id, text_col: t.text}
6766
for t in self.text_units or []
6867
if t.id in text_unit_ids
6968
]
@@ -102,13 +101,5 @@ def build_context(
102101

103102
return ContextBuilderResult(
104103
context_chunks=final_text,
105-
context_records={context_name: final_text_df},
104+
context_records={context_name.lower(): final_text_df},
106105
)
107-
108-
def _map_ids(self) -> dict[str, str]:
109-
"""Map id to short id in the text units."""
110-
id_map = {}
111-
text_units = self.text_units or []
112-
for unit in text_units:
113-
id_map[unit.id] = unit.short_id
114-
return id_map

0 commit comments

Comments
 (0)