repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
graphrag
packages/graphrag/graphrag/index/operations/summarize_communities/text_unit_context/context_builder.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Context builders for text units.""" import logging from typing import cast import pandas as pd from graphrag_llm.tokenizer import Tokenizer import graphrag.data_model.schemas as schemas from graphrag.index.operations.summarize_communiti...
238
8,604
graphrag
packages/graphrag/graphrag/index/operations/summarize_communities/graph_context/sort_context.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Sort context by degree in descending order.""" import pandas as pd from graphrag_llm.tokenizer import Tokenizer import graphrag.data_model.schemas as schemas def sort_context( local_context: list[dict], tokenizer: Tokenizer, ...
165
5,823
graphrag
packages/graphrag/graphrag/index/operations/summarize_communities/graph_context/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Package of context builders for graph-based reports."""
5
137
graphrag
packages/graphrag/graphrag/index/operations/summarize_communities/graph_context/context_builder.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Context builders for graphs.""" import logging from typing import cast import pandas as pd from graphrag_llm.tokenizer import Tokenizer import graphrag.data_model.schemas as schemas from graphrag.callbacks.workflow_callbacks import Work...
369
12,088
graphrag
packages/graphrag/graphrag/index/operations/embed_text/run_embed_text.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'TextEmbeddingResult' model and run_embed_text method definition.""" import asyncio import logging from dataclasses import dataclass from typing import TYPE_CHECKING import numpy as np from graphrag_chunking.token_chu...
171
5,163
graphrag
packages/graphrag/graphrag/index/operations/embed_text/embed_text.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Streaming text embedding operation.""" import logging from typing import TYPE_CHECKING, Any import numpy as np from graphrag_llm.tokenizer import Tokenizer from graphrag_storage.tables.table import Table from graphrag_vectors import VectorStore, Vect...
154
4,151
graphrag
packages/graphrag/graphrag/index/operations/embed_text/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The Indexing Engine text embed package root."""
5
129
graphrag
packages/graphrag/graphrag/index/operations/extract_graph/extract_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing extract_graph method.""" import logging from typing import TYPE_CHECKING import pandas as pd from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks from graphrag.config.enums import AsyncType from graphr...
130
3,617
graphrag
packages/graphrag/graphrag/index/operations/extract_graph/utils.py
.py
# Copyright (C) 2026 Microsoft Corporation. # Licensed under the MIT License """Utility functions for graph extraction operations.""" import logging import pandas as pd logger = logging.getLogger(__name__) def filter_orphan_relationships( relationships: pd.DataFrame, entities: pd.DataFrame, ) -> pd.DataFr...
54
1,621
graphrag
packages/graphrag/graphrag/index/operations/extract_graph/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The Indexing Engine entities extraction package root."""
5
138
graphrag
packages/graphrag/graphrag/index/operations/extract_graph/graph_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Graph extraction helpers that return tabular data.""" import logging import re import traceback from typing import TYPE_CHECKING, Any import pandas as pd from graphrag_llm.utils import ( CompletionMessagesBuilder, ) from graphrag.in...
189
6,609
graphrag
packages/graphrag/graphrag/index/operations/summarize_descriptions/summarize_descriptions.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing the summarize_descriptions verb.""" import asyncio import logging from typing import TYPE_CHECKING import pandas as pd from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks from graphrag.index.operation...
141
4,268
graphrag
packages/graphrag/graphrag/index/operations/summarize_descriptions/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Root package for description summarization."""
5
128
graphrag
packages/graphrag/graphrag/index/operations/summarize_descriptions/description_summary_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'SummarizationResult' and 'SummarizeExtractor' models.""" import json from dataclasses import dataclass from typing import TYPE_CHECKING from graphrag.index.typing.error_handler import ErrorHandlerFn if TYPE_CHECKING...
135
4,551
graphrag
packages/graphrag/graphrag/index/operations/summarize_descriptions/typing.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'SummarizedDescriptionResult' model.""" from dataclasses import dataclass from typing import Any, NamedTuple @dataclass class SummarizedDescriptionResult: """Entity summarization result class definition.""" ...
22
480
graphrag
packages/graphrag/graphrag/index/operations/extract_covariates/extract_covariates.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing the extract_covariates verb definition.""" import logging from collections.abc import Iterable from dataclasses import asdict from typing import TYPE_CHECKING, Any import pandas as pd from graphrag.callbacks.workflow...
122
3,667
graphrag
packages/graphrag/graphrag/index/operations/extract_covariates/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The Indexing Engine text extract claims package root."""
5
138
graphrag
packages/graphrag/graphrag/index/operations/extract_covariates/claim_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'ClaimExtractorResult' and 'ClaimExtractor' models.""" import logging import traceback from dataclasses import dataclass from typing import TYPE_CHECKING, Any from graphrag_llm.utils import ( CompletionMessagesBui...
194
6,872
graphrag
packages/graphrag/graphrag/index/operations/extract_covariates/typing.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'Covariate' and 'CovariateExtractionResult' models.""" from collections.abc import Awaitable, Callable, Iterable from dataclasses import dataclass from typing import Any from graphrag_cache import Cache from graphrag...
51
1,205
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The Indexing Engine noun graph package root."""
5
129
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/build_noun_graph.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Graph extraction using NLP.""" import logging from collections import defaultdict from itertools import combinations import pandas as pd from graphrag_cache import Cache from graphrag_storage.tables.table import Table from graphrag.graphs.edge_weigh...
144
4,165
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/regex_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Functions to analyze text data using SpaCy.""" import re from typing import Any import nltk from textblob import TextBlob from graphrag.index.operations.build_noun_graph.np_extractors.base import ( BaseNounPhraseExtractor, ) from gr...
125
4,540
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/syntactic_parsing_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Noun phrase extractor based on dependency parsing and NER using SpaCy.""" from typing import Any from spacy.tokens.span import Span from spacy.util import filter_spans from graphrag.index.operations.build_noun_graph.np_extractors.base i...
163
6,245
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/resource_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Util functions needed for nltk-based noun-phrase extractors (i.e. TextBlob).""" import nltk def download_if_not_exists(resource_name) -> bool: """Download nltk resources if they haven't been already.""" # look under all possible...
39
969
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """NLP-based graph extractors."""
5
112
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/stop_words.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Custom list of stop words to be excluded by noun phrase extractors.""" EN_STOP_WORDS = [ "stuff", "thing", "things", "bunch", "bit", "bits", "people", "person", "okay", "hey", "hi", "hello",...
22
349
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/cfg_extractor.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CFG-based noun phrase extractor.""" from typing import Any from spacy.tokens.doc import Doc from graphrag.index.operations.build_noun_graph.np_extractors.base import ( BaseNounPhraseExtractor, ) from graphrag.index.operations.build_...
183
7,253
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Create a noun phrase extractor from a configuration.""" from typing import ClassVar from graphrag.config.enums import NounPhraseExtractorType from graphrag.config.models.extract_graph_nlp_config import TextAnalyzerConfig from graphrag.in...
83
3,488
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/base.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Base class for noun phrase extractors.""" import logging from abc import ABCMeta, abstractmethod import spacy logger = logging.getLogger(__name__) class BaseNounPhraseExtractor(metaclass=ABCMeta): """Abstract base class for noun p...
62
1,730
graphrag
packages/graphrag/graphrag/index/operations/build_noun_graph/np_extractors/np_validator.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Util functions to tag noun phrases for filtering.""" def is_compound(tokens: list[str]) -> bool: """List of tokens forms a compound noun phrase.""" return any( "-" in token and len(token.strip()) > 1 and len(token.strip()...
26
853
graphrag
packages/graphrag/graphrag/index/update/relationships.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Relationship related operations and utils for Incremental Indexing.""" import itertools import numpy as np import pandas as pd from graphrag.data_model.schemas import RELATIONSHIPS_FINAL_COLUMNS def _update_and_merge_relationships( ...
87
2,706
graphrag
packages/graphrag/graphrag/index/update/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Incremental Indexing main module definition."""
5
129
graphrag
packages/graphrag/graphrag/index/update/entities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Entity related operations and utils for Incremental Indexing.""" import itertools import numpy as np import pandas as pd from graphrag.data_model.schemas import ENTITIES_FINAL_COLUMNS def _group_and_resolve_entities( old_entities_...
75
2,321
graphrag
packages/graphrag/graphrag/index/update/incremental_index.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Dataframe operations and utils for Incremental Indexing.""" from dataclasses import dataclass import numpy as np import pandas as pd from graphrag_storage.tables.table_provider import TableProvider @dataclass class InputDelta: """D...
79
2,323
graphrag
packages/graphrag/graphrag/index/update/communities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Dataframe operations and utils for Incremental Indexing.""" import pandas as pd from graphrag.data_model.schemas import ( COMMUNITIES_FINAL_COLUMNS, COMMUNITY_REPORTS_FINAL_COLUMNS, ) def _update_and_merge_communities( old_...
152
4,852
graphrag
packages/graphrag/graphrag/index/utils/derive_from_rows.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing derive_from_rows, derive_from_rows_asyncio_threads, and derive_from_rows_asyncio methods.""" import asyncio import inspect import logging import traceback from collections.abc import Awaitable, Callable, Coroutine, Has...
168
5,280
graphrag
packages/graphrag/graphrag/index/utils/uuid.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """UUID utilities.""" import uuid from random import Random, getrandbits def gen_uuid(rd: Random | None = None): """Generate a random UUID v4.""" return uuid.UUID( int=rd.getrandbits(128) if rd is not None else getrandbits(...
15
346
graphrag
packages/graphrag/graphrag/index/utils/is_null.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Defines the is_null utility.""" import math from typing import Any def is_null(value: Any) -> bool: """Check if value is null or is nan.""" def is_none() -> bool: return value is None def is_nan() -> bool: ...
20
408
graphrag
packages/graphrag/graphrag/index/utils/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Utils methods definition."""
5
110
graphrag
packages/graphrag/graphrag/index/utils/dicts.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A utility module containing methods for inspecting and verifying dictionary types.""" def dict_has_keys_with_types( data: dict, expected_fields: list[tuple[str, type]], inplace: bool = False ) -> bool: """Return True if the given...
23
708
graphrag
packages/graphrag/graphrag/index/utils/dataframes.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing DataFrame utilities.""" from collections.abc import Callable from typing import Any, cast import pandas as pd from pandas._typing import MergeHow def drop_columns(df: pd.DataFrame, *column: str) -> pd.DataFrame: ...
54
1,661
graphrag
packages/graphrag/graphrag/index/utils/string.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """String utilities.""" import html import re from typing import Any def clean_str(input: Any) -> str: """Clean an input string by removing HTML escapes, control characters, and other unwanted characters.""" # If we get non-string ...
20
601
graphrag
packages/graphrag/graphrag/index/utils/hashing.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Hashing utilities.""" from collections.abc import Iterable from hashlib import sha512 from typing import Any def gen_sha512_hash(item: dict[str, Any], hashcode: Iterable[str]): """Generate a SHA512 hash.""" hashed = "".join([str...
15
442
graphrag
packages/graphrag/graphrag/index/text_splitting/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The Indexing Engine Text Splitting package root."""
5
133
graphrag
packages/graphrag/graphrag/index/text_splitting/text_splitting.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'TokenTextSplitter' class and 'split_single_text_on_tokens' function.""" import logging from abc import ABC from collections.abc import Callable from typing import cast import pandas as pd from graphrag_llm.tokenizer ...
103
3,269
graphrag
packages/graphrag/graphrag/index/workflows/extract_graph_nlp.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """NLP-based graph extraction workflow.""" import logging from typing import Any import pandas as pd from graphrag_cache import Cache from graphrag_storage.tables.table import Table from graphrag.config.models.graph_rag_config import GraphRagConfig fro...
143
4,368
graphrag
packages/graphrag/graphrag/index/workflows/load_input_documents.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from dataclasses import asdict import pandas as pd from graphrag_input import InputReader, create_input_reader from graphrag_storage.tables.table import Table from gr...
61
1,892
graphrag
packages/graphrag/graphrag/index/workflows/update_final_documents.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.index.run.utils import get_update_table_providers from graphrag.index.typing.context i...
38
1,271
graphrag
packages/graphrag/graphrag/index/workflows/update_community_reports.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging import pandas as pd from graphrag_storage.tables.table_provider import TableProvider from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag....
68
2,336
graphrag
packages/graphrag/graphrag/index/workflows/extract_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from typing import TYPE_CHECKING import pandas as pd from graphrag_llm.completion import create_completion from graphrag.cache.cache_key_creator import cache_key_crea...
186
6,846
graphrag
packages/graphrag/graphrag/index/workflows/create_final_documents.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Workflow to create final documents with text unit mappings.""" import logging from typing import Any from graphrag_storage.tables.table import Table from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.data_model.row_tran...
74
2,259
graphrag
packages/graphrag/graphrag/index/workflows/create_base_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from typing import Any from graphrag_chunking.chunker import Chunker from graphrag_chunking.chunker_factory import create_chunker from graphrag_chunking.transformers i...
161
5,223
graphrag
packages/graphrag/graphrag/index/workflows/create_community_reports_text.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from typing import TYPE_CHECKING import pandas as pd from graphrag_llm.completion import create_completion from graphrag_llm.tokenizer import Tokenizer from graphrag....
120
3,828
graphrag
packages/graphrag/graphrag/index/workflows/update_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging import numpy as np import pandas as pd from graphrag_storage.tables.table_provider import TableProvider from graphrag.config.models.graph_rag_config import GraphRagCo...
96
3,153
graphrag
packages/graphrag/graphrag/index/workflows/extract_covariates.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from typing import TYPE_CHECKING from uuid import uuid4 import pandas as pd from graphrag_llm.completion import create_completion from graphrag.cache.cache_key_creato...
109
3,792
graphrag
packages/graphrag/graphrag/index/workflows/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing all built-in workflow definitions.""" from graphrag.index.workflows.factory import PipelineFactory from .create_base_text_units import ( run_workflow as run_create_base_text_units, ) from .create_communities imp...
101
3,352
graphrag
packages/graphrag/graphrag/index/workflows/create_final_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from contextlib import nullcontext from typing import Any from graphrag_storage.tables.table import Table from graphrag.config.models.graph_rag_config import GraphRag...
136
4,697
graphrag
packages/graphrag/graphrag/index/workflows/generate_text_embeddings.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from contextlib import AsyncExitStack from dataclasses import dataclass from typing import TYPE_CHECKING from graphrag_llm.embedding import create_embedding from graph...
163
5,307
graphrag
packages/graphrag/graphrag/index/workflows/update_entities_relationships.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging import pandas as pd from graphrag_cache import Cache from graphrag_llm.completion import create_completion from graphrag_storage.tables.table_provider import TableProv...
120
4,492
graphrag
packages/graphrag/graphrag/index/workflows/load_update_documents.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from dataclasses import asdict import pandas as pd from graphrag_input.input_reader import InputReader from graphrag_input.input_reader_factory import create_input_rea...
63
2,355
graphrag
packages/graphrag/graphrag/index/workflows/create_communities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from datetime import datetime, timezone from typing import Any, cast from uuid import uuid4 import numpy as np import pandas as pd from graphrag_storage.tables.table i...
208
7,242
graphrag
packages/graphrag/graphrag/index/workflows/update_communities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from graphrag_storage.tables.table_provider import TableProvider from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.data_model.data_read...
55
1,982
graphrag
packages/graphrag/graphrag/index/workflows/update_covariates.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging import numpy as np import pandas as pd from graphrag_storage.tables.table_provider import TableProvider from graphrag.config.models.graph_rag_config import GraphRagCo...
81
2,688
graphrag
packages/graphrag/graphrag/index/workflows/factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Encapsulates pipeline construction and selection.""" import logging from typing import ClassVar from graphrag.config.enums import IndexingMethod from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.index.typin...
98
3,014
graphrag
packages/graphrag/graphrag/index/workflows/prune_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging import pandas as pd from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.config.models.prune_graph_config import PruneGraphConfig from gra...
79
2,659
graphrag
packages/graphrag/graphrag/index/workflows/update_text_embeddings.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from graphrag_llm.embedding import create_embedding from graphrag.cache.cache_key_creator import cache_key_creator from graphrag.config.models.graph_rag_config import GraphRagConf...
53
1,630
graphrag
packages/graphrag/graphrag/index/workflows/create_community_reports.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from typing import TYPE_CHECKING import pandas as pd from graphrag_llm.completion import create_completion from graphrag_llm.tokenizer import Tokenizer import graphra...
200
5,990
graphrag
packages/graphrag/graphrag/index/workflows/finalize_graph.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from collections import Counter from typing import Any from graphrag_storage.tables.table import Table from graphrag.config.models.graph_rag_config import GraphRagConfig from grap...
126
3,849
graphrag
packages/graphrag/graphrag/index/workflows/update_clean_state.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing run_workflow method definition.""" import logging from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.index.typing.context import PipelineRunContext from graphrag.index.typing.workflow imp...
32
935
graphrag
packages/graphrag/graphrag/index/run/utils.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Utility functions for the GraphRAG run module.""" from graphrag_cache import Cache from graphrag_cache.memory_cache import MemoryCache from graphrag_storage import Storage, create_storage from graphrag_storage.memory_storage import Memory...
76
3,306
graphrag
packages/graphrag/graphrag/index/run/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Run module for GraphRAG."""
5
109
graphrag
packages/graphrag/graphrag/index/run/profiling.py
.py
# Copyright (C) 2025 Microsoft # Licensed under the MIT License """Workflow profiling utilities.""" import time import tracemalloc from types import TracebackType from typing import Self from graphrag.index.typing.stats import WorkflowMetrics class WorkflowProfiler: """Context manager for profiling workflow ex...
61
1,912
graphrag
packages/graphrag/graphrag/index/run/run_pipeline.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Different methods to run the pipeline.""" import json import logging import time from collections.abc import AsyncIterable from dataclasses import asdict from typing import Any import pandas as pd from graphrag_cache import create_cache ...
190
7,108
graphrag
packages/graphrag/graphrag/index/typing/pipeline.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing the Pipeline class.""" from collections.abc import Generator from graphrag.index.typing.workflow import Workflow class Pipeline: """Encapsulates running workflows.""" def __init__(self, workflows: list[Work...
28
824
graphrag
packages/graphrag/graphrag/index/typing/workflow.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Pipeline workflow types.""" from collections.abc import Awaitable, Callable from dataclasses import dataclass from typing import Any from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.index.typing.context im...
29
990
graphrag
packages/graphrag/graphrag/index/typing/state.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Pipeline state types.""" from typing import Any PipelineState = dict[Any, Any]
9
162
graphrag
packages/graphrag/graphrag/index/typing/stats.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Pipeline stats types.""" from dataclasses import dataclass, field @dataclass class WorkflowMetrics: """Metrics collected for a single workflow execution.""" overall: float """Wall-clock time in seconds.""" peak_memory_...
43
1,143
graphrag
packages/graphrag/graphrag/index/typing/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Root typings for GraphRAG."""
5
111
graphrag
packages/graphrag/graphrag/index/typing/context.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License # isort: skip_file """A module containing the 'PipelineRunContext' models.""" from dataclasses import dataclass from graphrag_cache import Cache from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks from graphrag.index.typing....
35
1,314
graphrag
packages/graphrag/graphrag/index/typing/error_handler.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Shared error handler types.""" from collections.abc import Callable ErrorHandlerFn = Callable[[BaseException | None, str | None, dict | None], None]
9
232
graphrag
packages/graphrag/graphrag/index/typing/pipeline_run_result.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing the PipelineRunResult class.""" from dataclasses import dataclass from typing import Any from graphrag.index.typing.state import PipelineState @dataclass class PipelineRunResult: """Pipeline run result class def...
23
728
graphrag
packages/graphrag/graphrag/logger/progress.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Progress Logging Utilities.""" import logging from collections.abc import Callable, Iterable from dataclasses import dataclass from typing import TypeVar T = TypeVar("T") logger = logging.getLogger(__name__) @dataclass class Progress: ...
96
2,712
graphrag
packages/graphrag/graphrag/logger/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Logger utilities and implementations."""
5
122
graphrag
packages/graphrag/graphrag/logger/factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Factory functions for creating a logger.""" from __future__ import annotations import logging from pathlib import Path from graphrag_common.factory import Factory from graphrag.config.enums import ReportingType LOG_FORMAT = "%(asctime...
65
2,063
graphrag
packages/graphrag/graphrag/logger/standard_logging.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Standard logging configuration for the graphrag package. This module provides a standardized way to configure Python's built-in logging system for use within the graphrag package. Usage: # Configuration should be done once at the sta...
92
2,968
graphrag
packages/graphrag/graphrag/logger/blob_workflow_logger.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A logger that emits updates from the indexing engine to a blob in Azure Storage.""" import json import logging from datetime import datetime, timezone from typing import Any from azure.identity import DefaultAzureCredential from azure.st...
122
4,470
graphrag
packages/graphrag/graphrag/prompts/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """All prompts for the GraphRAG system."""
5
121
graphrag
packages/graphrag/graphrag/prompts/query/basic_search_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Basic Search prompts.""" BASIC_SEARCH_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant responding to questions about data in the tables provided. ---Goal--- Generate a response of the target length and format that responds t...
74
2,893
graphrag
packages/graphrag/graphrag/prompts/query/global_search_knowledge_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Global Search system prompts.""" GENERAL_KNOWLEDGE_INSTRUCTION = """ The response may also include relevant real-world knowledge outside the dataset, but it must be explicitly annotated with a verification tag [LLM: verify]. For example: ...
10
403
graphrag
packages/graphrag/graphrag/prompts/query/global_search_map_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """System prompts for global search.""" MAP_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant responding to questions about data in the tables provided. ---Goal--- Generate a response consisting of a list of key points that resp...
86
4,116
graphrag
packages/graphrag/graphrag/prompts/query/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """All prompts for the query engine."""
5
118
graphrag
packages/graphrag/graphrag/prompts/query/question_gen_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Question Generation system prompts.""" QUESTION_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant generating a bulleted list of {question_count} questions about data in the tables provided. ---Data tables--- {context_data} ...
29
939
graphrag
packages/graphrag/graphrag/prompts/query/local_search_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Local search system prompts.""" LOCAL_SEARCH_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant responding to questions about data in the tables provided. ---Goal--- Generate a response of the target length and format that res...
70
2,701
graphrag
packages/graphrag/graphrag/prompts/query/global_search_reduce_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Global Search system prompts.""" REDUCE_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant responding to questions about a dataset by synthesizing perspectives from multiple analysts. ---Goal--- Generate a response of the targ...
86
3,956
graphrag
packages/graphrag/graphrag/prompts/query/drift_search_system_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """DRIFT Search prompts.""" DRIFT_LOCAL_SYSTEM_PROMPT = """ ---Role--- You are a helpful assistant responding to questions about data in the tables provided. ---Goal--- Generate a response of the target length and format that responds to...
168
8,170
graphrag
packages/graphrag/graphrag/prompts/index/extract_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A file containing prompts definition.""" GRAPH_EXTRACTION_PROMPT = """ -Goal- Given a text document that is potentially relevant to this activity and a list of entity types, identify all entities of those types from the text and all relat...
130
7,082
graphrag
packages/graphrag/graphrag/prompts/index/summarize_descriptions.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A file containing prompts definition.""" SUMMARIZE_PROMPT = """ You are a helpful assistant responsible for generating a comprehensive summary of the data provided below. Given one or more entities, and a list of descriptions, all related...
21
882
graphrag
packages/graphrag/graphrag/prompts/index/community_report_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A file containing prompts definition.""" COMMUNITY_REPORT_TEXT_PROMPT = """ You are an AI assistant that helps a human analyst to perform general information discovery. Information discovery is the process of identifying and assessing rel...
96
7,971
graphrag
packages/graphrag/graphrag/prompts/index/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """All prompts for the indexing engine."""
5
121
graphrag
packages/graphrag/graphrag/prompts/index/community_report.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A file containing prompts definition.""" COMMUNITY_REPORT_PROMPT = """ You are an AI assistant that helps a human analyst to perform general information discovery. Information discovery is the process of identifying and assessing relevant ...
154
9,011