Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .semversioner/next-release/minor-20250807204918927024.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "minor",
"description": "Add additional context variable to build index signature for custom parameter bag"
}
5 changes: 5 additions & 0 deletions graphrag/api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import logging
from typing import Any

from graphrag.callbacks.noop_workflow_callbacks import NoopWorkflowCallbacks
from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks
Expand All @@ -30,6 +31,7 @@ async def build_index(
is_update_run: bool = False,
memory_profile: bool = False,
callbacks: list[WorkflowCallbacks] | None = None,
additional_context: dict[str, Any] | None = None,
) -> list[PipelineRunResult]:
"""Run the pipeline with the given configuration.

Expand All @@ -43,6 +45,8 @@ async def build_index(
Whether to enable memory profiling.
callbacks : list[WorkflowCallbacks] | None default=None
A list of callbacks to register.
additional_context : dict[str, Any] | None default=None
Additional context to pass to the pipeline run. This can be accessed using PipelineState.

Returns
-------
Expand Down Expand Up @@ -73,6 +77,7 @@ async def build_index(
config,
callbacks=workflow_callbacks,
is_update_run=is_update_run,
additional_context=additional_context,
):
outputs.append(output)
if output.errors and len(output.errors) > 0:
Expand Down
5 changes: 5 additions & 0 deletions graphrag/index/run/run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
from collections.abc import AsyncIterable
from dataclasses import asdict
from typing import Any

from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks
from graphrag.config.models.graph_rag_config import GraphRagConfig
Expand All @@ -28,6 +29,7 @@ async def run_pipeline(
config: GraphRagConfig,
callbacks: WorkflowCallbacks,
is_update_run: bool = False,
additional_context: dict[str, Any] | None = None,
) -> AsyncIterable[PipelineRunResult]:
"""Run all workflows using a simplified pipeline."""
root_dir = config.root_dir
Expand All @@ -40,6 +42,9 @@ async def run_pipeline(
state_json = await output_storage.get("context.json")
state = json.loads(state_json) if state_json else {}

if additional_context:
state.setdefault("additional_context", {}).update(additional_context)

if is_update_run:
logger.info("Running incremental indexing.")

Expand Down
Loading