Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove config input models #1570

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all 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/patch-20250102170720512799.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "Remove config input models."
}
18 changes: 6 additions & 12 deletions graphrag/config/create_graphrag_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import os
from enum import Enum
from pathlib import Path
from typing import cast
from typing import Any, cast

from datashaper import AsyncType
from environs import Env
from pydantic import TypeAdapter

import graphrag.config.defaults as defs
from graphrag.config.enums import (
Expand All @@ -28,8 +27,6 @@
AzureApiBaseMissingError,
AzureDeploymentNameMissingError,
)
from graphrag.config.input_models.graphrag_config_input import GraphRagConfigInput
from graphrag.config.input_models.llm_config_input import LLMConfigInput
from graphrag.config.models.basic_search_config import BasicSearchConfig
from graphrag.config.models.cache_config import CacheConfig
from graphrag.config.models.chunking_config import ChunkingConfig, ChunkStrategyType
Expand All @@ -55,27 +52,24 @@
from graphrag.config.models.umap_config import UmapConfig
from graphrag.config.read_dotenv import read_dotenv

InputModelValidator = TypeAdapter(GraphRagConfigInput)


def create_graphrag_config(
values: GraphRagConfigInput | None = None, root_dir: str | None = None
values: dict[str, Any] | None = None, root_dir: str | None = None
) -> GraphRagConfig:
"""Load Configuration Parameters from a dictionary."""
values = values or {}
root_dir = root_dir or str(Path.cwd())
env = _make_env(root_dir)
_token_replace(cast("dict", values))
InputModelValidator.validate_python(values, strict=True)

reader = EnvironmentReader(env)

def hydrate_async_type(input: LLMConfigInput, base: AsyncType) -> AsyncType:
def hydrate_async_type(input: dict[str, Any], base: AsyncType) -> AsyncType:
value = input.get(Fragment.async_mode)
return AsyncType(value) if value else base

def hydrate_llm_params(
config: LLMConfigInput, base: LLMParameters
config: dict[str, Any], base: LLMParameters
) -> LLMParameters:
with reader.use(config.get("llm")):
llm_type = reader.str(Fragment.type)
Expand Down Expand Up @@ -132,7 +126,7 @@ def hydrate_llm_params(
)

def hydrate_embeddings_params(
config: LLMConfigInput, base: LLMParameters
config: dict[str, Any], base: LLMParameters
) -> LLMParameters:
with reader.use(config.get("llm")):
api_type = reader.str(Fragment.type) or defs.EMBEDDING_TYPE
Expand Down Expand Up @@ -198,7 +192,7 @@ def hydrate_embeddings_params(
)

def hydrate_parallelization_params(
config: LLMConfigInput, base: ParallelizationParameters
config: dict[str, Any], base: ParallelizationParameters
) -> ParallelizationParameters:
with reader.use(config.get("parallelization")):
return ParallelizationParameters(
Expand Down
4 changes: 0 additions & 4 deletions graphrag/config/input_models/__init__.py

This file was deleted.

15 changes: 0 additions & 15 deletions graphrag/config/input_models/basic_search_config_input.py

This file was deleted.

19 changes: 0 additions & 19 deletions graphrag/config/input_models/cache_config_input.py

This file was deleted.

15 changes: 0 additions & 15 deletions graphrag/config/input_models/chunking_config_input.py

This file was deleted.

19 changes: 0 additions & 19 deletions graphrag/config/input_models/claim_extraction_config_input.py

This file was deleted.

13 changes: 0 additions & 13 deletions graphrag/config/input_models/cluster_graph_config_input.py

This file was deleted.

17 changes: 0 additions & 17 deletions graphrag/config/input_models/community_reports_config_input.py

This file was deleted.

18 changes: 0 additions & 18 deletions graphrag/config/input_models/embed_graph_config_input.py

This file was deleted.

18 changes: 0 additions & 18 deletions graphrag/config/input_models/entity_extraction_config_input.py

This file was deleted.

16 changes: 0 additions & 16 deletions graphrag/config/input_models/global_search_config_input.py

This file was deleted.

67 changes: 0 additions & 67 deletions graphrag/config/input_models/graphrag_config_input.py

This file was deleted.

27 changes: 0 additions & 27 deletions graphrag/config/input_models/input_config_input.py

This file was deleted.

20 changes: 0 additions & 20 deletions graphrag/config/input_models/llm_config_input.py

This file was deleted.

31 changes: 0 additions & 31 deletions graphrag/config/input_models/llm_parameters_input.py

This file was deleted.

Loading
Loading