Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
refactor: 移除索引字段验证逻辑,简化 AutoSet、AutoGraph 和 AutoHypergraph 类的初始化过程
yifanfeng97d30e46d11fcd
diff --git a/hyperextract/core/set.py b/hyperextract/core/set.pyindex 92ca987..da80ca2 100644--- a/hyperextract/core/set.py+++ b/hyperextract/core/set.py@@ -126,15 +126,6 @@ class AutoSet(BaseAutoType[AutoSetSchema[Item]], Generic[Item]):self.item_schema = item_schemaself.fields_for_index = fields_for_index- # Validate fields_for_index if provided- if self.fields_for_index:- for field_name in self.fields_for_index:- if field_name not in item_schema.model_fields:- raise ValueError(- f"Field '{field_name}' not found in item schema '{item_schema.__name__}'. "- f"Available fields: {list(item_schema.model_fields.keys())}"- )-# Create AutoSetSchema container dynamically (similar to AutoList's AutoListSchema)container_name = f"{item_schema.__name__}Set"self.item_set_schema = create_model(diff --git a/hyperextract/graphs/base.py b/hyperextract/graphs/base.pyindex 4f93116..8273f6f 100644--- a/hyperextract/graphs/base.py+++ b/hyperextract/graphs/base.py@@ -165,24 +165,6 @@ class AutoGraph(BaseAutoType[AutoGraphSchema[Node, Edge]], Generic[Node, Edge]):self.node_fields_for_index = node_fields_for_indexself.edge_fields_for_index = edge_fields_for_index- # Validate node fields for index- if self.node_fields_for_index:- for field_name in self.node_fields_for_index:- if field_name not in node_schema.model_fields:- raise ValueError(- f"Field '{field_name}' not found in node schema '{node_schema.__name__}'. "- f"Available fields: {list(node_schema.model_fields.keys())}"- )-- # Validate edge fields for index- if self.edge_fields_for_index:- for field_name in self.edge_fields_for_index:- if field_name not in edge_schema.model_fields:- raise ValueError(- f"Field '{field_name}' not found in edge schema '{edge_schema.__name__}'. "- f"Available fields: {list(edge_schema.model_fields.keys())}"- )-# Initialize prompts (use custom if provided, otherwise use defaults)self.node_prompt = prompt_for_node_extraction or self._default_node_prompt()self.edge_prompt = prompt_for_edge_extraction or self._default_edge_prompt()diff --git a/hyperextract/hypergraphs/base.py b/hyperextract/hypergraphs/base.pyindex 3047367..eb74af7 100644--- a/hyperextract/hypergraphs/base.py+++ b/hyperextract/hypergraphs/base.py@@ -171,23 +171,6 @@ class AutoHypergraph(self.node_fields_for_index = node_fields_for_indexself.edge_fields_for_index = edge_fields_for_index- # Validate node fields for index- if self.node_fields_for_index:- for field_name in self.node_fields_for_index:- if field_name not in node_schema.model_fields:- raise ValueError(- f"Field '{field_name}' not found in node schema '{node_schema.__name__}'. "- f"Available fields: {list(node_schema.model_fields.keys())}"- )-- # Validate edge fields for index- if self.edge_fields_for_index:- for field_name in self.edge_fields_for_index:- if field_name not in edge_schema.model_fields:- raise ValueError(- f"Field '{field_name}' not found in edge schema '{edge_schema.__name__}'. "- f"Available fields: {list(edge_schema.model_fields.keys())}"- )self.max_workers = max_workersself.show_progress = show_progress