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/prompts/index/extract_claims.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A file containing prompts definition.""" EXTRACT_CLAIMS_PROMPT = """ -Target activity- You are an intelligent assistant that helps a human analyst to analyze claims against certain entities presented in a text document. -Goal- Given a te...
62
5,077
graphrag
packages/graphrag/graphrag/config/init_content.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Content for the init CLI command to generate a default configuration.""" import graphrag.config.defaults as defs from graphrag.config.defaults import ( graphrag_config_defaults, vector_store_defaults, ) INIT_YAML = f"""\ ### This...
145
5,576
graphrag
packages/graphrag/graphrag/config/errors.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Errors for the default configuration.""" class ApiKeyMissingError(ValueError): """LLM Key missing error.""" def __init__(self, llm_type: str, azure_auth_type: str | None = None) -> None: """Init method definition.""" ...
42
1,390
graphrag
packages/graphrag/graphrag/config/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The config package root."""
5
109
graphrag
packages/graphrag/graphrag/config/embeddings.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing embeddings values.""" entity_description_embedding = "entity_description" community_full_content_embedding = "community_full_content" text_unit_text_embedding = "text_unit_text" all_embeddings: set[str] = { entity...
20
552
graphrag
packages/graphrag/graphrag/config/load_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Default method for loading config.""" from pathlib import Path from typing import Any from graphrag_common.config import load_config as lc from graphrag.config.models.graph_rag_config import GraphRagConfig def load_config( root_di...
48
1,257
graphrag
packages/graphrag/graphrag/config/enums.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing config enums.""" from __future__ import annotations from enum import Enum class ReportingType(str, Enum): """The reporting configuration type for the pipeline.""" file = "file" """The file reporting con...
78
2,096
graphrag
packages/graphrag/graphrag/config/defaults.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Common default configuration values.""" from dataclasses import dataclass, field from pathlib import Path from typing import ClassVar from graphrag_cache import CacheType from graphrag_chunking.chunk_strategy_type import ChunkerType from...
386
11,727
graphrag
packages/graphrag/graphrag/config/models/extract_graph_nlp_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.config.enums import AsyncType, NounPhraseExtractorType class ...
75
3,320
graphrag
packages/graphrag/graphrag/config/models/local_search_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class LocalSearchConfig(BaseModel): """The default configuration sectio...
50
1,866
graphrag
packages/graphrag/graphrag/config/models/reporting_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.config.enums import ReportingType class ReportingConfig(BaseM...
35
1,225
graphrag
packages/graphrag/graphrag/config/models/extract_claims_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from dataclasses import dataclass from pathlib import Path from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.pro...
57
1,970
graphrag
packages/graphrag/graphrag/config/models/global_search_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class GlobalSearchConfig(BaseModel): """The default configuration secti...
68
2,903
graphrag
packages/graphrag/graphrag/config/models/cluster_graph_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class ClusterGraphConfig(BaseModel): """Configuration section for clust...
26
825
graphrag
packages/graphrag/graphrag/config/models/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Interfaces for Default Config parameterization."""
5
132
graphrag
packages/graphrag/graphrag/config/models/extract_graph_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from dataclasses import dataclass from pathlib import Path from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.pro...
53
1,822
graphrag
packages/graphrag/graphrag/config/models/community_reports_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from dataclasses import dataclass from pathlib import Path from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.pro...
64
2,435
graphrag
packages/graphrag/graphrag/config/models/summarize_descriptions_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from dataclasses import dataclass from pathlib import Path from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults from graphrag.pro...
53
1,941
graphrag
packages/graphrag/graphrag/config/models/drift_search_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class DRIFTSearchConfig(BaseModel): """The default configuration sectio...
124
4,900
graphrag
packages/graphrag/graphrag/config/models/basic_search_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class BasicSearchConfig(BaseModel): """The default configuration sectio...
34
1,174
graphrag
packages/graphrag/graphrag/config/models/graph_rag_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from dataclasses import asdict from pathlib import Path from devtools import pformat from graphrag_cache import CacheConfig from graphrag_chunking.chunking_config import Chunkin...
334
13,658
graphrag
packages/graphrag/graphrag/config/models/snapshots_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class SnapshotsConfig(BaseModel): """Configuration section for snapshot...
26
916
graphrag
packages/graphrag/graphrag/config/models/embed_text_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class EmbedTextConfig(BaseModel): """Configuration section for text emb...
34
1,204
graphrag
packages/graphrag/graphrag/config/models/prune_graph_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Parameterization settings for the default configuration.""" from pydantic import BaseModel, Field from graphrag.config.defaults import graphrag_config_defaults class PruneGraphConfig(BaseModel): """Configuration section for pruning...
42
1,600
graphrag
packages/graphrag/graphrag/data_model/types.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Common types for the GraphRAG knowledge model.""" from collections.abc import Callable TextEmbedder = Callable[[str], list[float]]
9
214
graphrag
packages/graphrag/graphrag/data_model/row_transformers.py
.py
# Copyright (C) 2026 Microsoft """Row-level type coercion for streaming Table reads. Each transformer converts a raw ``dict[str, Any]`` row (as produced by ``csv.DictReader``, where every value is a string) into a dict with properly typed fields. They serve the same purpose as the DataFrame- based ``*_typed`` helper...
253
7,859
graphrag
packages/graphrag/graphrag/data_model/identified.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Identified' protocol.""" from dataclasses import dataclass @dataclass class Identified: """A protocol for an item with an ID.""" id: str """The ID of the item.""" short_id: str | None """H...
18
449
graphrag
packages/graphrag/graphrag/data_model/data_reader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A DataReader that loads typed dataframes from a TableProvider.""" import pandas as pd from graphrag_storage.tables import TableProvider from graphrag.data_model.dfs import ( communities_typed, community_reports_typed, covaria...
72
2,701
graphrag
packages/graphrag/graphrag/data_model/dfs.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing dataframe processing utilities.""" from typing import Any import pandas as pd from graphrag.data_model.schemas import ( COMMUNITY_CHILDREN, COMMUNITY_ID, COMMUNITY_LEVEL, COVARIATE_IDS, EDGE_DEGR...
153
5,345
graphrag
packages/graphrag/graphrag/data_model/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Knowledge model package.""" from graphrag.data_model.data_reader import DataReader __all__ = ["DataReader"]
9
191
graphrag
packages/graphrag/graphrag/data_model/covariate.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Covariate' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.identified import Identified @dataclass class Covariate(Identified): """ A protocol for a covariat...
55
1,579
graphrag
packages/graphrag/graphrag/data_model/relationship.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Relationship' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.identified import Identified @dataclass class Relationship(Identified): """A relationship between t...
66
2,226
graphrag
packages/graphrag/graphrag/data_model/community_report.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'CommunityReport' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.named import Named @dataclass class CommunityReport(Named): """Defines an LLM-generated summary ...
68
2,083
graphrag
packages/graphrag/graphrag/data_model/text_unit.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'TextUnit' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.identified import Identified @dataclass class TextUnit(Identified): """A protocol for a TextUnit item i...
63
2,046
graphrag
packages/graphrag/graphrag/data_model/community.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Community' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.named import Named @dataclass class Community(Named): """A protocol for a community in the system.""" ...
80
2,566
graphrag
packages/graphrag/graphrag/data_model/schemas.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Common field name definitions for data frames.""" ID = "id" SHORT_ID = "human_readable_id" TITLE = "title" DESCRIPTION = "description" TYPE = "type" # POST-PREP NODE TABLE SCHEMA NODE_DEGREE = "degree" NODE_FREQUENCY = "frequency" NODE_D...
160
2,963
graphrag
packages/graphrag/graphrag/data_model/document.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Document' model.""" from dataclasses import dataclass, field from typing import Any from graphrag.data_model.named import Named @dataclass class Document(Named): """A protocol for a document in the system....
50
1,403
graphrag
packages/graphrag/graphrag/data_model/named.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Named' protocol.""" from dataclasses import dataclass from graphrag.data_model.identified import Identified @dataclass class Named(Identified): """A protocol for an item with a name/title.""" title: s...
17
361
graphrag
packages/graphrag/graphrag/data_model/entity.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing the 'Entity' model.""" from dataclasses import dataclass from typing import Any from graphrag.data_model.named import Named @dataclass class Entity(Named): """A protocol for an entity in the system.""" typ...
70
2,455
graphrag
packages/graphrag/graphrag/api/prompt_tune.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """ Auto Templating API. This API provides access to the auto templating feature of graphrag, allowing external applications to hook into graphrag and generate prompts from private data. WARNING: This API is under development and may underg...
187
6,940
graphrag
packages/graphrag/graphrag/api/index.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """ Indexing API for GraphRAG. WARNING: This API is under development and may undergo changes in future releases. Backwards compatibility is not guaranteed at this time. """ import logging from typing import Any import pandas as pd from g...
99
3,615
graphrag
packages/graphrag/graphrag/api/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """API for GraphRAG. WARNING: This API is under development and may undergo changes in future releases. Backwards compatibility is not guaranteed at this time. """ from graphrag.api.index import build_index from graphrag.api.prompt_tune imp...
40
992
graphrag
packages/graphrag/graphrag/api/query.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """ Query Engine API. This API provides access to the query engine of graphrag, allowing external applications to hook into graphrag and run queries over a knowledge graph generated by graphrag. Contains the following functions: - global_s...
547
20,270
graphrag
packages/graphrag/graphrag/utils/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Util functions for the GraphRAG package."""
5
125
graphrag
packages/graphrag/graphrag/utils/api.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """API functions for the GraphRAG module.""" from pathlib import Path from graphrag_vectors import ( VectorStore, VectorStoreConfig, create_vector_store, ) def get_embedding_store( config: VectorStoreConfig, embedding_...
76
2,166
graphrag
packages/graphrag/graphrag/utils/cli.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI functions for the GraphRAG module.""" import argparse import json from pathlib import Path def file_exist(path): """Check for file existence.""" if not Path(path).is_file(): msg = f"File not found: {path}" ra...
55
1,493
graphrag
packages/graphrag/graphrag/callbacks/workflow_callbacks_manager.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A module containing 'WorkflowCallbacksManager' model.""" from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks from graphrag.index.typing.pipeline_run_result import PipelineRunResult from graphrag.logger.progress import Prog...
59
2,332
graphrag
packages/graphrag/graphrag/callbacks/noop_workflow_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A no-op implementation of WorkflowCallbacks.""" from graphrag.callbacks.workflow_callbacks import WorkflowCallbacks from graphrag.index.typing.pipeline_run_result import PipelineRunResult from graphrag.logger.progress import Progress cl...
31
1,229
graphrag
packages/graphrag/graphrag/callbacks/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A package containing callback implementations."""
5
131
graphrag
packages/graphrag/graphrag/callbacks/workflow_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Collection of callbacks that can be used to monitor the workflow execution.""" from typing import Protocol from graphrag.index.typing.pipeline_run_result import PipelineRunResult from graphrag.logger.progress import Progress class Work...
42
1,390
graphrag
packages/graphrag/graphrag/callbacks/query_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Query Callbacks.""" from typing import Any from graphrag.callbacks.llm_callbacks import BaseLLMCallback from graphrag.query.structured_search.base import SearchResult class QueryCallbacks(BaseLLMCallback): """Callbacks used during ...
34
1,094
graphrag
packages/graphrag/graphrag/callbacks/noop_query_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """No-op Query Callbacks.""" from typing import Any from graphrag.callbacks.query_callbacks import QueryCallbacks from graphrag.query.structured_search.base import SearchResult class NoopQueryCallbacks(QueryCallbacks): """A no-op impl...
34
1,099
graphrag
packages/graphrag/graphrag/callbacks/console_workflow_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """A logger that emits updates from the indexing engine to the console.""" from graphrag.callbacks.noop_workflow_callbacks import NoopWorkflowCallbacks from graphrag.index.typing.pipeline_run_result import PipelineRunResult from graphrag.log...
51
1,936
graphrag
packages/graphrag/graphrag/callbacks/llm_callbacks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """LLM Callbacks.""" from typing import Protocol class BaseLLMCallback(Protocol): """Base class for LLM callbacks.""" def on_llm_new_token(self, token: str): """Handle when a new token is generated.""" ...
15
312
graphrag
packages/graphrag/graphrag/cli/prompt_tune.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI implementation of the prompt-tune subcommand.""" import logging from pathlib import Path import graphrag.api as api from graphrag.config.load_config import load_config from graphrag.prompt_tune.generator.community_report_summarizatio...
115
4,019
graphrag
packages/graphrag/graphrag/cli/main.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI entrypoint.""" import os import re from collections.abc import Callable from pathlib import Path import typer from graphrag.config.defaults import ( DEFAULT_COMPLETION_MODEL, DEFAULT_EMBEDDING_MODEL, graphrag_config_defa...
482
13,839
graphrag
packages/graphrag/graphrag/cli/index.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI implementation of the index subcommand.""" import asyncio import logging import sys import warnings from pathlib import Path from graphrag_cache.cache_type import CacheType import graphrag.api as api from graphrag.callbacks.console_...
136
3,280
graphrag
packages/graphrag/graphrag/cli/initialize.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI implementation of the initialization subcommand.""" import logging from pathlib import Path from graphrag.config.defaults import graphrag_config_defaults from graphrag.config.init_content import INIT_DOTENV, INIT_YAML from graphrag.p...
102
3,972
graphrag
packages/graphrag/graphrag/cli/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI for GraphRAG."""
5
102
graphrag
packages/graphrag/graphrag/cli/query.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CLI implementation of the query subcommand.""" import asyncio import sys from pathlib import Path from typing import TYPE_CHECKING, Any from graphrag_storage import create_storage from graphrag_storage.tables.table_provider_factory impor...
398
11,910
graphrag
packages/graphrag/graphrag/prompt_tune/types.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Types for prompt tuning.""" from enum import Enum class DocSelectionType(str, Enum): """The type of document selection to use.""" ALL = "all" RANDOM = "random" TOP = "top" AUTO = "auto" def __str__(self): ...
20
407
graphrag
packages/graphrag/graphrag/prompt_tune/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """The prompt-tuning package root."""
5
116
graphrag
packages/graphrag/graphrag/prompt_tune/defaults.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Default values for the prompt-tuning module. Note: These values get accessed from the CLI to set default behavior. To maintain fast responsiveness from the CLI, do not add long-running code in this file and be mindful of imports. """ DEF...
21
604
graphrag
packages/graphrag/graphrag/prompt_tune/generator/community_report_summarization.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Module for generating prompts for community report summarization.""" from pathlib import Path from graphrag.prompt_tune.template.community_report_summarization import ( COMMUNITY_REPORT_SUMMARIZATION_PROMPT, ) COMMUNITY_SUMMARIZATIO...
51
1,655
graphrag
packages/graphrag/graphrag/prompt_tune/generator/persona.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Persona generating module for fine-tuning GraphRAG prompts.""" from typing import TYPE_CHECKING from graphrag.prompt_tune.defaults import DEFAULT_TASK from graphrag.prompt_tune.prompt.persona import GENERATE_PERSONA_PROMPT if TYPE_CHECK...
35
1,115
graphrag
packages/graphrag/graphrag/prompt_tune/generator/language.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Language detection for GraphRAG prompts.""" from typing import TYPE_CHECKING from graphrag.prompt_tune.prompt.language import DETECT_LANGUAGE_PROMPT if TYPE_CHECKING: from graphrag_llm.completion import LLMCompletion from graphr...
35
1,015
graphrag
packages/graphrag/graphrag/prompt_tune/generator/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Prompt generation module."""
5
110
graphrag
packages/graphrag/graphrag/prompt_tune/generator/entity_summarization_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Entity summarization prompt generation module.""" from pathlib import Path from graphrag.prompt_tune.template.entity_summarization import ( ENTITY_SUMMARIZATION_PROMPT, ) ENTITY_SUMMARIZATION_FILENAME = "summarize_descriptions.txt" ...
40
1,176
graphrag
packages/graphrag/graphrag/prompt_tune/generator/domain.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Domain generation for GraphRAG prompts.""" from typing import TYPE_CHECKING from graphrag.prompt_tune.prompt.domain import GENERATE_DOMAIN_PROMPT if TYPE_CHECKING: from graphrag_llm.completion import LLMCompletion from graphrag_...
35
1,029
graphrag
packages/graphrag/graphrag/prompt_tune/generator/community_reporter_role.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Generate a community reporter role for community summarization.""" from typing import TYPE_CHECKING from graphrag.prompt_tune.prompt.community_reporter_role import ( GENERATE_COMMUNITY_REPORTER_ROLE_PROMPT, ) if TYPE_CHECKING: f...
43
1,322
graphrag
packages/graphrag/graphrag/prompt_tune/generator/entity_types.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Entity type generation module for fine-tuning.""" from typing import TYPE_CHECKING from graphrag_llm.utils import ( CompletionMessagesBuilder, ) from pydantic import BaseModel from graphrag.prompt_tune.defaults import DEFAULT_TASK f...
75
2,100
graphrag
packages/graphrag/graphrag/prompt_tune/generator/entity_relationship.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Entity relationship example generation module.""" import asyncio from typing import TYPE_CHECKING from graphrag_llm.utils import ( CompletionMessagesBuilder, ) from graphrag.prompt_tune.prompt.entity_relationship import ( ENTITY...
79
2,316
graphrag
packages/graphrag/graphrag/prompt_tune/generator/extract_graph_prompt.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Entity Extraction prompt generator module.""" from pathlib import Path from graphrag_llm.tokenizer import Tokenizer from graphrag.prompt_tune.template.extract_graph import ( EXAMPLE_EXTRACTION_TEMPLATE, GRAPH_EXTRACTION_JSON_PRO...
111
3,547
graphrag
packages/graphrag/graphrag/prompt_tune/generator/community_report_rating.py
.py
"""Generate a rating description for community report rating.""" # Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from typing import TYPE_CHECKING from graphrag.prompt_tune.prompt.community_report_rating import ( GENERATE_REPORT_RATING_PROMPT, ) if TYPE_CHECKING: from graphrag_llm...
42
1,319
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/persona.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for persona generation.""" GENERATE_PERSONA_PROMPT = """ You are an intelligent assistant that helps a human to analyze the information in a text document. Given a specific type of task and sample text, help the user b...
14
618
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/language.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for language detection.""" DETECT_LANGUAGE_PROMPT = """ You are an intelligent assistant that helps a human to analyze the information in a text document. Given a sample text, help the user by determining what's the pr...
13
501
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Persona, entity type, relationships and domain generation prompts module."""
5
158
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/domain.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for domain generation.""" GENERATE_DOMAIN_PROMPT = """ You are an intelligent assistant that helps a human to analyze the information in a text document. Given a sample text, help the user by assigning a descriptive do...
13
492
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/community_reporter_role.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for community reporter role generation.""" GENERATE_COMMUNITY_REPORTER_ROLE_PROMPT = """ {persona} Given a sample text, help the user by creating a role definition that will be tasked with community analysis. Take a lo...
21
1,001
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/entity_types.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for entity types generation.""" ENTITY_TYPE_GENERATION_PROMPT = """ The goal is to study the connections and relations between the entity types and their features in order to understand all available information from t...
90
5,378
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/entity_relationship.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for entity relationship generation.""" ENTITY_RELATIONSHIPS_GENERATION_PROMPT = """ -Goal- Given a text document that is potentially relevant to this activity and a list of entity types, identify all entities of those ...
356
20,938
graphrag
packages/graphrag/graphrag/prompt_tune/prompt/community_report_rating.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine tuning prompts for Community Reports Rating.""" GENERATE_REPORT_RATING_PROMPT = """ You are a helpful agent tasked with rating the importance of a given text in the context of the provided domain and persona. Your goal is to provide...
133
6,473
graphrag
packages/graphrag/graphrag/prompt_tune/loader/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning config and data loader module."""
5
127
graphrag
packages/graphrag/graphrag/prompt_tune/loader/input.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Input loading module.""" import dataclasses import logging from typing import Any import numpy as np import pandas as pd from graphrag_chunking.chunker_factory import create_chunker from graphrag_input import create_input_reader from gra...
108
3,758
graphrag
packages/graphrag/graphrag/prompt_tune/template/community_report_summarization.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for community report summarization.""" COMMUNITY_REPORT_SUMMARIZATION_PROMPT = """ {persona} # Goal Write a comprehensive assessment report of a community taking on the role of a {role}. The content of this report inc...
106
6,230
graphrag
packages/graphrag/graphrag/prompt_tune/template/extract_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for entity extraction.""" 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 ...
142
6,082
graphrag
packages/graphrag/graphrag/prompt_tune/template/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for entity extraction, entity summarization, and community report summarization."""
5
185
graphrag
packages/graphrag/graphrag/prompt_tune/template/entity_summarization.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Fine-tuning prompts for entity summarization.""" ENTITY_SUMMARIZATION_PROMPT = """ {persona} Using your expertise, you're asked to generate a comprehensive summary of the data provided below. Given one or two entities, and a list of descr...
23
1,070
graphrag
packages/graphrag/graphrag/cache/cache_key_creator.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """Cache key creation for Graphrag.""" from typing import Any from graphrag_llm.cache import create_cache_key _CACHE_VERSION = 4 """ If there's a breaking change in what we cache, we should increment this version number to invalidate exist...
45
1,345
graphrag
packages/graphrag/graphrag/cache/__init__.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """Cache module."""
5
98
graphrag
tests/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Tests for the GraphRAG LLM module."""
6
120
graphrag
tests/conftest.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License def pytest_addoption(parser): parser.addoption( "--run_slow", action="store_true", default=False, help="run slow tests" )
9
217
graphrag
tests/integration/storage/test_factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """StorageFactory Tests. These tests will test the StorageFactory class and the creation of each storage type that is natively supported. """ import sys import pytest from graphrag_storage import ( Storage, StorageConfig, Storag...
151
4,939
graphrag
tests/integration/storage/test_blob_storage.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Blob Storage Tests.""" import re from datetime import datetime from graphrag_storage.azure_blob_storage import AzureBlobStorage # cspell:disable-next-line well-known-key WELL_KNOWN_BLOB_STORAGE_KEY = "DefaultEndpointsProtocol=http;Accoun...
90
3,321
graphrag
tests/integration/storage/test_file_storage.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Blob Storage Tests.""" import os import re from datetime import datetime from pathlib import Path from graphrag_storage.file_storage import ( FileStorage, ) __dirname__ = os.path.dirname(__file__) async def test_find(): storage...
60
1,750
graphrag
tests/integration/storage/test_cosmosdb_storage.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CosmosDB Storage Tests.""" import json import re import sys from datetime import datetime import pytest from graphrag_storage.azure_cosmos_storage import AzureCosmosStorage # cspell:disable-next-line well-known-key WELL_KNOWN_COSMOS_CONN...
130
4,305
graphrag
tests/integration/language_model/test_factory.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """LLMFactory Tests. These tests will test the LLMFactory class and the creation of custom and provided LLMs. """ from typing import TYPE_CHECKING, Any, Unpack from graphrag_llm.completion import ( LLMCompletion, create_completion,...
102
2,760
graphrag
tests/integration/language_model/utils.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """LiteLLM Test Utilities.""" def bin_time_intervals( time_values: list[float], time_interval: int ) -> list[list[float]]: """Bin values.""" bins: list[list[float]] = [] bin_number = 0 for time_value in time_values: ...
38
1,076
graphrag
tests/integration/language_model/test_rate_limiter.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test LiteLLM Rate Limiter.""" import threading import time from math import ceil from queue import Queue from graphrag_llm.config import RateLimitConfig, RateLimitType from graphrag_llm.rate_limit import RateLimiter, create_rate_limiter ...
350
10,968
graphrag
tests/integration/language_model/test_retries.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test LiteLLM Retries.""" import time from typing import Any import httpx import litellm.exceptions as exceptions import pytest from graphrag_llm.config import RetryConfig, RetryType from graphrag_llm.retry import create_retry @pytest.m...
244
6,351