|
6 | 6 | import os |
7 | 7 | from enum import Enum |
8 | 8 | from pathlib import Path |
9 | | -from typing import cast |
| 9 | +from typing import Any, cast |
10 | 10 |
|
11 | 11 | from datashaper import AsyncType |
12 | 12 | from environs import Env |
13 | | -from pydantic import TypeAdapter |
14 | 13 |
|
15 | 14 | import graphrag.config.defaults as defs |
16 | 15 | from graphrag.config.enums import ( |
|
28 | 27 | AzureApiBaseMissingError, |
29 | 28 | AzureDeploymentNameMissingError, |
30 | 29 | ) |
31 | | -from graphrag.config.input_models.graphrag_config_input import GraphRagConfigInput |
32 | | -from graphrag.config.input_models.llm_config_input import LLMConfigInput |
33 | 30 | from graphrag.config.models.basic_search_config import BasicSearchConfig |
34 | 31 | from graphrag.config.models.cache_config import CacheConfig |
35 | 32 | from graphrag.config.models.chunking_config import ChunkingConfig, ChunkStrategyType |
|
55 | 52 | from graphrag.config.models.umap_config import UmapConfig |
56 | 53 | from graphrag.config.read_dotenv import read_dotenv |
57 | 54 |
|
58 | | -InputModelValidator = TypeAdapter(GraphRagConfigInput) |
59 | | - |
60 | 55 |
|
61 | 56 | def create_graphrag_config( |
62 | | - values: GraphRagConfigInput | None = None, root_dir: str | None = None |
| 57 | + values: dict[str, Any] | None = None, root_dir: str | None = None |
63 | 58 | ) -> GraphRagConfig: |
64 | 59 | """Load Configuration Parameters from a dictionary.""" |
65 | 60 | values = values or {} |
66 | 61 | root_dir = root_dir or str(Path.cwd()) |
67 | 62 | env = _make_env(root_dir) |
68 | 63 | _token_replace(cast("dict", values)) |
69 | | - InputModelValidator.validate_python(values, strict=True) |
70 | 64 |
|
71 | 65 | reader = EnvironmentReader(env) |
72 | 66 |
|
73 | | - def hydrate_async_type(input: LLMConfigInput, base: AsyncType) -> AsyncType: |
| 67 | + def hydrate_async_type(input: dict[str, Any], base: AsyncType) -> AsyncType: |
74 | 68 | value = input.get(Fragment.async_mode) |
75 | 69 | return AsyncType(value) if value else base |
76 | 70 |
|
77 | 71 | def hydrate_llm_params( |
78 | | - config: LLMConfigInput, base: LLMParameters |
| 72 | + config: dict[str, Any], base: LLMParameters |
79 | 73 | ) -> LLMParameters: |
80 | 74 | with reader.use(config.get("llm")): |
81 | 75 | llm_type = reader.str(Fragment.type) |
@@ -132,7 +126,7 @@ def hydrate_llm_params( |
132 | 126 | ) |
133 | 127 |
|
134 | 128 | def hydrate_embeddings_params( |
135 | | - config: LLMConfigInput, base: LLMParameters |
| 129 | + config: dict[str, Any], base: LLMParameters |
136 | 130 | ) -> LLMParameters: |
137 | 131 | with reader.use(config.get("llm")): |
138 | 132 | api_type = reader.str(Fragment.type) or defs.EMBEDDING_TYPE |
@@ -198,7 +192,7 @@ def hydrate_embeddings_params( |
198 | 192 | ) |
199 | 193 |
|
200 | 194 | def hydrate_parallelization_params( |
201 | | - config: LLMConfigInput, base: ParallelizationParameters |
| 195 | + config: dict[str, Any], base: ParallelizationParameters |
202 | 196 | ) -> ParallelizationParameters: |
203 | 197 | with reader.use(config.get("parallelization")): |
204 | 198 | return ParallelizationParameters( |
|
0 commit comments