Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

refactor: 更新示例文件和显示解析器配置

yifanfeng976f7e0f90bac0
diff --git a/examples/template_demo.py b/examples/template_demo.py
index 0a7a6db..4cf7d46 100644
--- a/examples/template_demo.py
+++ b/examples/template_demo.py
@@ -21,16 +21,22 @@ from hyperextract import Template
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
+# INPUT_FILE = (
+# Path(__file__).parent.parent
+# / "tests"
+# / "test_data"
+# / "templates"
+# / "biography_scientist.md"
+# )
+
INPUT_FILE = (
Path(__file__).parent.parent
/ "tests"
- / "test_data"
- / "templates"
- / "biography_scientist.md"
+ / "kg.md"
)
-name = "general/life_event_timeline"
-# name = "general/knowledge_graph"
+# name = "general/life_event_timeline"
+name = "general/knowledge_graph"
def main():
diff --git a/hyperextract/utils/template_engine/parsers/display.py b/hyperextract/utils/template_engine/parsers/display.py
index b0984eb..aa76feb 100644
--- a/hyperextract/utils/template_engine/parsers/display.py
+++ b/hyperextract/utils/template_engine/parsers/display.py
@@ -11,9 +11,9 @@ from .identifiers import _extractor
def parse_display(
- display: NaiveDisplaySchema | GraphDisplaySchema | None,
+ display: NaiveDisplaySchema | GraphDisplaySchema,
autotype: VALID_AUTOTYPES,
-) -> Callable[[Any], str] | tuple[Callable[[Any], str], Callable[[Any], str]] | None:
+) -> Callable[[Any], str] | tuple[Callable[[Any], str], Callable[[Any], str]]:
"""Parse display config and return label extractors.
Args:
@@ -24,9 +24,6 @@ def parse_display(
- For model/list/set: label_extractor
- For graph types: (entity_label_extractor, relation_label_extractor)
"""
- if not display:
- return None
-
if autotype in ("model", "list", "set"):
return _extractor(display.label)