Skip to content

Commit 71079d8

Browse files
author
Gabriel Nieves
committed
Ran poe format
1 parent 39ea901 commit 71079d8

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

graphrag/api/prompt_tune.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ async def generate_indexing_prompts(
5454
logger: ProgressLogger,
5555
root: str,
5656
chunk_size: PositiveInt = graphrag_config_defaults.chunks.size,
57-
overlap: Annotated[int, annotated_types.Gt(-1)] = graphrag_config_defaults.chunks.overlap,
57+
overlap: Annotated[
58+
int, annotated_types.Gt(-1)
59+
] = graphrag_config_defaults.chunks.overlap,
5860
limit: PositiveInt = 15,
5961
selection_method: DocSelectionType = DocSelectionType.RANDOM,
6062
domain: str | None = None,
@@ -113,7 +115,9 @@ async def generate_indexing_prompts(
113115
default_llm_settings.max_retries = min(
114116
len(doc_list), language_model_defaults.max_retries
115117
)
116-
logger.warning(f"max_retries not set, using default value: {default_llm_settings.max_retries}") # noqa: G004
118+
logger.warning(
119+
f"max_retries not set, using default value: {default_llm_settings.max_retries}"
120+
) # noqa: G004
117121

118122
logger.info("Creating language model...")
119123
llm = ModelManager().register_chat(

graphrag/cli/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,16 @@ def _prompt_tune_cli(
313313
),
314314
] = 2,
315315
chunk_size: Annotated[
316-
int, typer.Option(help="The size of each example text chunk. Overrides chunks.size in the configuration file.")
316+
int,
317+
typer.Option(
318+
help="The size of each example text chunk. Overrides chunks.size in the configuration file."
319+
),
317320
] = graphrag_config_defaults.chunks.size,
318321
overlap: Annotated[
319-
int, typer.Option(help="The overlap size for chunking documents. Overrides chunks.overlap in the configuration file")
322+
int,
323+
typer.Option(
324+
help="The overlap size for chunking documents. Overrides chunks.overlap in the configuration file"
325+
),
320326
] = graphrag_config_defaults.chunks.overlap,
321327
language: Annotated[
322328
str | None,

graphrag/cli/prompt_tune.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ async def prompt_tune(
6666
# override chunking config in the configuration
6767
if chunk_size != graph_config.chunks.size:
6868
graph_config.chunks.size = chunk_size
69-
69+
7070
if overlap != graph_config.chunks.overlap:
7171
graph_config.chunks.overlap = overlap
7272

7373
progress_logger = LoggerFactory().create_logger(logger)
7474
info, error, success = _logger(progress_logger)
7575

7676
enabled_logging, log_path = enable_logging_with_config(
77-
graph_config,
78-
verbose,
79-
filename="prompt-tune.log"
77+
graph_config, verbose, filename="prompt-tune.log"
8078
)
8179
if enabled_logging:
8280
info(f"Logging enabled at {log_path}", verbose)

graphrag/config/logging.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def enable_logging(log_filepath: str | Path, verbose: bool = False) -> None:
3434

3535

3636
def enable_logging_with_config(
37-
config: GraphRagConfig,
38-
verbose: bool = False,
39-
filename: str = "indexing-engine.log"
37+
config: GraphRagConfig, verbose: bool = False, filename: str = "indexing-engine.log"
4038
) -> tuple[bool, str]:
4139
"""Enable logging to a file based on the config.
4240

graphrag/prompt_tune/loader/input.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ async def _embed_chunks(
2828
) -> tuple[pd.DataFrame, np.ndarray]:
2929
"""Convert text chunks into dense text embeddings."""
3030
sampled_text_chunks = text_chunks.sample(n=min(n_subset_max, len(text_chunks)))
31-
embeddings = await embedding_llm.aembed_batch(
32-
sampled_text_chunks["text"].tolist()
33-
)
31+
embeddings = await embedding_llm.aembed_batch(sampled_text_chunks["text"].tolist())
3432
return text_chunks, np.array(embeddings)
3533

3634

@@ -66,20 +64,20 @@ async def load_docs_in_chunks(
6664
dataset = await create_input(config.input, logger, root)
6765
chunk_config = config.chunks
6866
chunks_df = create_base_text_units(
69-
documents = dataset,
70-
callbacks = NoopWorkflowCallbacks(),
71-
group_by_columns = chunk_config.group_by_columns,
72-
size = chunk_size,
73-
overlap = overlap,
74-
encoding_model = chunk_config.encoding_model,
75-
strategy = chunk_config.strategy,
76-
prepend_metadata = chunk_config.prepend_metadata,
77-
chunk_size_includes_metadata = chunk_config.chunk_size_includes_metadata,
67+
documents=dataset,
68+
callbacks=NoopWorkflowCallbacks(),
69+
group_by_columns=chunk_config.group_by_columns,
70+
size=chunk_size,
71+
overlap=overlap,
72+
encoding_model=chunk_config.encoding_model,
73+
strategy=chunk_config.strategy,
74+
prepend_metadata=chunk_config.prepend_metadata,
75+
chunk_size_includes_metadata=chunk_config.chunk_size_includes_metadata,
7876
)
7977

8078
# Depending on the select method, build the dataset
8179
if limit <= 0 or limit > len(chunks_df):
82-
logger.warning(f"Limit out of range, using default number of chunks: {LIMIT}") # noqa: G004
80+
logger.warning(f"Limit out of range, using default number of chunks: {LIMIT}") # noqa: G004
8381
limit = LIMIT
8482

8583
if select_method == DocSelectionType.TOP:

0 commit comments

Comments
 (0)