Skip to content

Commit

Permalink
update prompt var usage
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Oct 25, 2024
1 parent 9d607a1 commit 4795495
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions graphrag/index/graph/extractors/claims/claim_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,10 @@ async def _process_document(
)

response = await self._llm(
self._extraction_prompt,
variables={
self._extraction_prompt.format(**{
self._input_text_key: doc,
**prompt_args,
},
})
)
results = response.output.content or ""
claims = results.strip().removesuffix(completion_delimiter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ async def __call__(self, inputs: dict[str, Any]):
output = None
try:
response = await self._llm(
self._extraction_prompt,
self._extraction_prompt.format(**{
self._input_text_key: inputs[self._input_text_key]
}),
json=True,
name="create_community_report",
variables={self._input_text_key: inputs[self._input_text_key]},
json_model=CommunityReportResponse,
model_parameters={"max_tokens": self._max_report_length},
)
Expand Down
5 changes: 2 additions & 3 deletions graphrag/index/graph/extractors/graph/graph_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ async def _process_document(
self, text: str, prompt_variables: dict[str, str]
) -> str:
response = await self._llm(
self._extraction_prompt,
variables={
self._extraction_prompt.format(**{
**prompt_variables,
self._input_text_key: text,
},
}),
)
results = response.output.content or ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,13 @@ async def _summarize_descriptions_with_llm(
):
"""Summarize descriptions using the LLM."""
response = await self._llm(
self._summarization_prompt,
name="summarize",
variables={
self._summarization_prompt.format(**{
self._entity_name_key: json.dumps(items),
self._input_descriptions_key: json.dumps(
sorted(descriptions), ensure_ascii=False
),
},
}),
name="summarize",
model_parameters={"max_tokens": self._max_summary_length},
)
# Calculate result
Expand Down

0 comments on commit 4795495

Please sign in to comment.