Skip to content

Commit

Permalink
Update SimpleKGPipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
stellasia committed Dec 4, 2024
1 parent 9dc8bec commit d551fb4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 436 deletions.
199 changes: 0 additions & 199 deletions src/neo4j_graphrag/experimental/pipeline/config/parser.py

This file was deleted.

53 changes: 2 additions & 51 deletions src/neo4j_graphrag/experimental/pipeline/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,13 @@
# limitations under the License.

import enum
from typing import Any, Literal, Optional, Sequence, Union
from typing import Any, Literal, Union

from pydantic import BaseModel, ConfigDict

from neo4j_graphrag.experimental.components.entity_relation_extractor import OnError
from neo4j_graphrag.experimental.components.types import LexicalGraphConfig
from neo4j_graphrag.experimental.pipeline.types import (
EntityInputType,
RelationInputType,
)
from neo4j_graphrag.generation.prompts import ERExtractionTemplate
from pydantic import BaseModel


class ParamResolverEnum(str, enum.Enum):
ENV = "ENV"
CONFIG_ARRAY = "CONFIG_ARRAY"
CONFIG_KEY = "CONFIG_KEY"


Expand All @@ -54,43 +45,3 @@ class ParamFromKeyConfig(ParamToResolveConfig):
ParamFromKeyConfig,
dict[str, Any],
]


class BasePipelineV1Config(BaseModel):
version_: Literal["1"] = "1"


class DriverConfig(BaseModel):
uri: ParamConfig
user: ParamConfig
password: ParamConfig


class ClassConfig(BaseModel):
class_: str
params_: dict[str, ParamConfig]


class SimpleKGPipelineExposedParamConfig(BaseModel):
from_pdf: bool = False
potential_schema: Optional[list[tuple[str, str, str]]] = None
on_error: OnError = OnError.IGNORE
prompt_template: Union[ERExtractionTemplate, str] = ERExtractionTemplate()
perform_entity_resolution: bool = True
lexical_graph_config: Optional[LexicalGraphConfig] = None
neo4j_database: Optional[str] = None

model_config = ConfigDict(
arbitrary_types_allowed=True,
)


class SimpleKGPipelineConfig(BasePipelineV1Config, SimpleKGPipelineExposedParamConfig):
neo4j_config: DriverConfig
llm_config: ClassConfig
embedder_config: ClassConfig
pdf_loader: ClassConfig | None = None
text_splitter: ClassConfig | None = None
kg_writer: ClassConfig | None = None
entities: Optional[Sequence[EntityInputType]] = None
relations: Optional[Sequence[RelationInputType]] = None
Loading

0 comments on commit d551fb4

Please sign in to comment.