Skip to content

Commit 9fa06f9

Browse files
committed
Refactor config
- Add new ModelConfig to represent LLM settings - Combines LLMParameters, ParallelizationParameters, encoding_model, and async_mode - Add top level models config that is a list of available LLM ModelConfigs - Remove LLMConfig inheritance and delete LLMConfig - Replace the inheritance with a model_id reference to the ModelConfig listed in the top level models config - Remove all fallbacks and hydration logic from create_graphrag_config - This removes the automatic env variable overrides - Support env variables within config files using Templating - This requires "$" to be escaped with extra "$" so ".*\\.txt$" becomes ".*\\.txt$$" - Update init content to initialize new config file with the ModelConfig structure
1 parent 6eca5ec commit 9fa06f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+697
-1285
lines changed

graphrag/api/prompt_tune.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from graphrag.config.models.graph_rag_config import GraphRagConfig
1818
from graphrag.index.llm.load_llm import load_llm
1919
from graphrag.logger.print_progress import PrintProgressLogger
20-
from graphrag.prompt_tune.defaults import MAX_TOKEN_COUNT
20+
from graphrag.prompt_tune.defaults import MAX_TOKEN_COUNT, PROMPT_TUNING_MODEL_ID
2121
from graphrag.prompt_tune.generator.community_report_rating import (
2222
generate_community_report_rating,
2323
)
@@ -95,9 +95,11 @@ async def generate_indexing_prompts(
9595
)
9696

9797
# Create LLM from config
98+
# TODO: Expose way to specify Prompt Tuning model ID through config
99+
default_llm_settings = config.get_model_config(PROMPT_TUNING_MODEL_ID)
98100
llm = load_llm(
99101
"prompt_tuning",
100-
config.llm,
102+
default_llm_settings,
101103
cache=None,
102104
callbacks=NoopWorkflowCallbacks(),
103105
)
@@ -120,14 +122,17 @@ async def generate_indexing_prompts(
120122
)
121123

122124
entity_types = None
125+
entity_extraction_llm_settings = config.get_model_config(
126+
config.entity_extraction.model_id
127+
)
123128
if discover_entity_types:
124129
logger.info("Generating entity types...")
125130
entity_types = await generate_entity_types(
126131
llm,
127132
domain=domain,
128133
persona=persona,
129134
docs=doc_list,
130-
json_mode=config.llm.model_supports_json or False,
135+
json_mode=entity_extraction_llm_settings.model_supports_json or False,
131136
)
132137

133138
logger.info("Generating entity relationship examples...")
@@ -147,7 +152,7 @@ async def generate_indexing_prompts(
147152
examples=examples,
148153
language=language,
149154
json_mode=False, # config.llm.model_supports_json should be used, but these prompts are used in non-json mode by the index engine
150-
encoding_model=config.encoding_model,
155+
encoding_model=entity_extraction_llm_settings.encoding_model,
151156
max_token_count=max_tokens,
152157
min_examples_required=min_examples_required,
153158
)

graphrag/config/config_file_loader.py

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)