diff --git a/graphrag/prompt_tune/loader/input.py b/graphrag/prompt_tune/loader/input.py index fa49ebeeb9..7cdc3006dc 100644 --- a/graphrag/prompt_tune/loader/input.py +++ b/graphrag/prompt_tune/loader/input.py @@ -67,8 +67,8 @@ async def load_docs_in_chunks( # Depending on the select method, build the dataset if limit <= 0 or limit > len(chunks_df): - logger.warning(f"Limit out of range, using default number of chunks: {LIMIT}") # noqa: G004 - limit = LIMIT + limit = min(LIMIT, len(chunks_df)) + logger.warning(f"Limit out of range, using default number of chunks: {limit}") # noqa: G004 if select_method == DocSelectionType.TOP: chunks_df = chunks_df[:limit]