Skip to content

Commit fea56d2

Browse files
committed
Use dict of ModelConfig instead of list
1 parent 9fa06f9 commit fea56d2

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

graphrag/config/init_content.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
## There are a number of settings to tune the threading and token limits for LLM calls - check the docs.
1414
1515
models:
16-
- id: {defs.DEFAULT_CHAT_MODEL_ID}
16+
{defs.DEFAULT_CHAT_MODEL_ID}:
1717
api_key: ${{GRAPHRAG_API_KEY}} # set this in the generated .env file
1818
type: {defs.LLM_TYPE.value} # or azure_openai_chat
1919
model: {defs.LLM_MODEL}
@@ -26,7 +26,7 @@
2626
# api_version: 2024-02-15-preview
2727
# organization: <organization_id>
2828
# deployment_name: <azure_model_deployment_name>
29-
- id: {defs.DEFAULT_EMBEDDING_MODEL_ID}
29+
{defs.DEFAULT_EMBEDDING_MODEL_ID}:
3030
api_key: ${{GRAPHRAG_API_KEY}}
3131
type: {defs.EMBEDDING_TYPE.value} # or azure_openai_embedding
3232
model: {defs.EMBEDDING_MODEL}

graphrag/config/models/graph_rag_config.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def __str__(self):
4545
description="The root directory for the configuration.", default="."
4646
)
4747

48-
models: list[ModelConfig] = Field(
49-
description="Available language model configurations.", default=[]
48+
models: dict[str, ModelConfig] = Field(
49+
description="Available language model configurations.", default={}
5050
)
5151

5252
reporting: ReportingConfig = Field(
@@ -179,8 +179,7 @@ def get_model_config(self, model_id: str) -> ModelConfig:
179179
ValueError
180180
If the model ID is not found in the configuration.
181181
"""
182-
for model in self.models:
183-
if model.id == model_id:
184-
return model
185-
err_msg = f"Model ID {model_id} not found in configuration."
186-
raise ValueError(err_msg)
182+
if model_id not in self.models:
183+
err_msg = f"Model ID {model_id} not found in configuration."
184+
raise ValueError(err_msg)
185+
return self.models[model_id]

graphrag/config/models/model_config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
class ModelConfig(BaseModel):
1414
"""Language model configuration."""
1515

16-
id: str = Field(
17-
description="A user friendly ID of the model used elsewhere in GraphRAGConfig for selecting models."
18-
)
1916
api_key: str | None = Field(
2017
description="The API key to use for the LLM service.",
2118
default=None,

0 commit comments

Comments
 (0)