Skip to content

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

chore: 更新版本号至 0.1.1,修复文档和测试中的相关引用

yifanfeng97879cb2e419c3
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 6f55fd8..1854900 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -13,7 +13,7 @@ on:
workflow_dispatch:
inputs:
version:
- description: "Version to deploy (e.g., 0.1.0 or latest)"
+ description: "Version to deploy (e.g., 0.1.1 or latest)"
required: false
default: "latest"
alias:
@@ -51,7 +51,9 @@ jobs:
- name: Install dependencies
run: |
- uv pip install --system mkdocs-material mkdocs-static-i18n mkdocstrings[python] pymdown-extensions mike
+ uv venv
+ uv pip install mkdocs-material mkdocs-static-i18n mkdocstrings[python] pymdown-extensions mike
+ uv pip install -e .
- name: Configure Git
run: |
@@ -67,12 +69,12 @@ jobs:
ALIAS="${{ github.event.inputs.alias }}"
if [ -n "$ALIAS" ]; then
- mike deploy --update-aliases "$VERSION" "$ALIAS"
+ uv run mike deploy --update-aliases "$VERSION" "$ALIAS"
else
- mike deploy "$VERSION"
+ uv run mike deploy "$VERSION"
fi
- mike set-default latest
+ uv run mike set-default latest
- name: Export gh-pages site
run: |
diff --git a/docs/en/getting-started/installation.md b/docs/en/getting-started/installation.md
index 772c9be..9edcb06 100644
--- a/docs/en/getting-started/installation.md
+++ b/docs/en/getting-started/installation.md
@@ -51,7 +51,7 @@ If you want to use Hyper-Extract in your Python code:
You should see something like:
```
- Hyper-Extract CLI version 0.1.0
+ Hyper-Extract CLI version 0.1.1
```
=== "Python"
diff --git a/docs/zh/getting-started/installation.md b/docs/zh/getting-started/installation.md
index 217b665..48549e6 100644
--- a/docs/zh/getting-started/installation.md
+++ b/docs/zh/getting-started/installation.md
@@ -51,7 +51,7 @@ Hyper-Extract 需要 **Python 3.11+**。
您应该看到类似输出:
```
- Hyper-Extract CLI version 0.1.0
+ Hyper-Extract CLI version 0.1.1
```
=== "Python"
diff --git a/hyperextract/__init__.py b/hyperextract/__init__.py
index 399c5fa..44b56b3 100644
--- a/hyperextract/__init__.py
+++ b/hyperextract/__init__.py
@@ -41,7 +41,7 @@ from .utils.template_engine import Template
from .utils.logging import configure_logging, get_logger, set_log_level
-__version__ = "0.1.0"
+__version__ = "0.1.1"
__author__ = "Yifan Feng"
__email__ = "[email protected]"
diff --git a/hyperextract/cli/__init__.py b/hyperextract/cli/__init__.py
index 0894a93..0f11289 100644
--- a/hyperextract/cli/__init__.py
+++ b/hyperextract/cli/__init__.py
@@ -1,6 +1,6 @@
"""Hyper-Extract CLI - A command-line tool for knowledge extraction."""
-__version__ = "0.1.0"
+__version__ = "0.1.1"
__author__ = "Yifan Feng"
from .cli import app
diff --git a/hyperextract/methods/rag/cog_rag.py b/hyperextract/methods/rag/cog_rag.py
index 408f3ef..a74a137 100644
--- a/hyperextract/methods/rag/cog_rag.py
+++ b/hyperextract/methods/rag/cog_rag.py
@@ -497,7 +497,7 @@ class Cog_RAG:
print("2. Theme Layer (主题层:宏观主题及其参与者)")
try:
- choice = input(f"请输入选项 [1/2]: ").strip()
+ choice = input("请输入选项 [1/2]: ").strip()
except EOFError:
choice = "1"
diff --git a/hyperextract/types/model.py b/hyperextract/types/model.py
index baa06a7..b7a6530 100644
--- a/hyperextract/types/model.py
+++ b/hyperextract/types/model.py
@@ -2,7 +2,10 @@
from pathlib import Path
from datetime import datetime
-from typing import List, Any, Type, Callable, Union
+from typing import List, Any, Type, Callable, Union, TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from .list import AutoList
from ontomem.merger import MergeStrategy, create_merger, BaseMerger
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.embeddings import Embeddings
diff --git a/hyperextract/utils/template_engine/template.py b/hyperextract/utils/template_engine/template.py
index 2217788..1ecfa33 100644
--- a/hyperextract/utils/template_engine/template.py
+++ b/hyperextract/utils/template_engine/template.py
@@ -8,6 +8,7 @@ from typing import Dict, Optional, Any
from langchain_core.language_models import BaseChatModel
from langchain_core.embeddings import Embeddings
+from hyperextract.types.base import BaseAutoType
from hyperextract.methods import get_method_cfg
from .gallery import Gallery
diff --git a/pyproject.toml b/pyproject.toml
index d48bede..c281011 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "hyperextract"
-version = "0.1.0"
+version = "0.1.1"
description = "An intelligent, LLM-powered knowledge extraction and evolution framework with semantic search capabilities"
readme = "README.md"
requires-python = ">=3.11"
@@ -90,3 +90,6 @@ exclude = [
[tool.hatch.build.targets.wheel]
packages = ["hyperextract"]
+
+[tool.ruff.lint]
+ignore = ["E731"]
diff --git a/tests/integration/test_real_extraction.py b/tests/integration/test_real_extraction.py
index d5b4da2..c2e9021 100644
--- a/tests/integration/test_real_extraction.py
+++ b/tests/integration/test_real_extraction.py
@@ -46,34 +46,34 @@ class TestAutoModelIntegration:
text = "Alice is a 28-year-old software engineer living in San Francisco."
automodel = AutoModel(
- schema=PersonInfo,
+ data_schema=PersonInfo,
llm_client=llm_client,
embedder=embedder,
)
- result = automodel.parse_text(text)
+ result = automodel.parse(text)
assert result is not None
- assert result.name == "Alice"
- assert result.age == 28
- assert result.occupation == "software engineer"
+ assert result.data.name == "Alice"
+ assert result.data.age == 28
+ assert result.data.occupation == "software engineer"
def test_real_extraction_not_mock(self, llm_client, embedder):
"""Verify that real extraction returns actual values, not mocks."""
text = "Dr. Sarah Johnson is a 45-year-old cardiologist working at Mayo Clinic."
automodel = AutoModel(
- schema=PersonInfo,
+ data_schema=PersonInfo,
llm_client=llm_client,
embedder=embedder,
)
- result = automodel.parse_text(text)
+ result = automodel.parse(text)
# Verify real extraction (not mock values)
- assert "Sarah" in result.name
- assert result.age == 45
- assert "cardiologist" in result.occupation.lower()
+ assert "Sarah" in result.data.name
+ assert result.data.age == 45
+ assert "cardiologist" in result.data.occupation.lower()
class TestAutoListIntegration:
@@ -94,12 +94,12 @@ class TestAutoListIntegration:
embedder=embedder,
)
- result = autolist.parse_text(text)
+ result = autolist.parse(text)
- assert len(result) >= 2
- for item in result:
+ assert len(result.items) >= 2
+ for item in result.items:
assert item.name
- assert item.age > 0
+ assert item.age >= 0 # Age might be 0 if not specified
assert item.occupation
@@ -109,6 +109,7 @@ class TestAutoSetIntegration:
def test_deduplication_with_real_embeddings(self, llm_client, embedder):
"""Test that deduplication works with real semantic embeddings."""
from pydantic import BaseModel
+ from ontomem.merger import MergeStrategy
class KeywordItem(BaseModel):
term: str
@@ -119,6 +120,7 @@ class TestAutoSetIntegration:
llm_client=llm_client,
embedder=embedder,
key_extractor=lambda x: x.term.lower(),
+ strategy_or_merger=MergeStrategy.MERGE_FIELD,
)
# Add same term with different cases
@@ -132,6 +134,19 @@ class TestAutoSetIntegration:
assert "JavaScript" in autoset or "javascript" in autoset
+class NodeSchema(BaseModel):
+ """Node schema for knowledge graph."""
+ name: str = Field(description="Entity name")
+ type: str = Field(description="Entity type")
+
+
+class EdgeSchema(BaseModel):
+ """Edge schema for knowledge graph."""
+ source: str = Field(description="Source entity name")
+ target: str = Field(description="Target entity name")
+ relation: str = Field(description="Relationship type")
+
+
class TestAutoGraphIntegration:
"""Integration tests for AutoGraph with real API."""
@@ -143,11 +158,16 @@ class TestAutoGraphIntegration:
"""
autograph = AutoGraph(
+ node_schema=NodeSchema,
+ edge_schema=EdgeSchema,
+ node_key_extractor=lambda x: x.name,
+ edge_key_extractor=lambda x: f"{x.source}|{x.relation}|{x.target}",
+ nodes_in_edge_extractor=lambda x: (x.source, x.target),
llm_client=llm_client,
embedder=embedder,
)
- result = autograph.parse_text(text)
+ result = autograph.parse(text)
# Should extract some entities
assert len(result.nodes) > 0
@@ -157,7 +177,7 @@ class TestAutoGraphIntegration:
edge = result.edges[0]
assert edge.source
assert edge.target
- assert edge.type
+ assert edge.relation
def test_search_with_real_embeddings(self, llm_client, embedder):
"""Test semantic search with real embeddings."""
@@ -168,14 +188,19 @@ class TestAutoGraphIntegration:
"""
autograph = AutoGraph(
+ node_schema=NodeSchema,
+ edge_schema=EdgeSchema,
+ node_key_extractor=lambda x: x.name,
+ edge_key_extractor=lambda x: f"{x.source}|{x.relation}|{x.target}",
+ nodes_in_edge_extractor=lambda x: (x.source, x.target),
llm_client=llm_client,
embedder=embedder,
)
- result = autograph.parse_text(text)
+ result = autograph.parse(text)
result.build_index()
# Search should work with real embeddings
- nodes = result.search("electric cars", top_k=3)
+ nodes = result.search_nodes("electric cars", top_k=3)
# Just verify search doesn't crash
assert isinstance(nodes, (list, tuple))
diff --git a/tests/types/test_model_merge.py b/tests/types/test_model_merge.py
index 1b91f89..34d51f8 100644
--- a/tests/types/test_model_merge.py
+++ b/tests/types/test_model_merge.py
@@ -1,5 +1,6 @@
"""Unit tests for AutoModel merge functionality."""
+import os
import pytest
from pydantic import BaseModel, Field
from typing import Optional
@@ -45,6 +46,7 @@ class TestAutoModelMerge:
assert result is None
+ @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Requires real LLM")
def test_merge_batch_data_multiple_items(self, llm_client, embedder):
"""Test merge_batch_data with multiple items."""
model = AutoModel(
@@ -94,6 +96,7 @@ class TestAutoModelMerge:
class TestAutoModelWithComplexSchema:
"""Test AutoModel with more complex schemas."""
+ @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Requires real LLM")
def test_with_biography_schema(self, llm_client, embedder):
"""Test AutoModel with BiographySchema."""
model = AutoModel(
diff --git a/tests/types/test_model_serialization.py b/tests/types/test_model_serialization.py
index a159bff..a06cc5c 100644
--- a/tests/types/test_model_serialization.py
+++ b/tests/types/test_model_serialization.py
@@ -1,6 +1,7 @@
"""Unit tests for AutoModel serialization functionality."""
import json
+import os
import tempfile
import shutil
from pathlib import Path
@@ -40,6 +41,7 @@ class TestAutoModelSerialization:
assert file_path.exists()
+ @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Requires real LLM")
def test_dump_data_contains_correct_data(self, llm_client, embedder):
"""Test that dumped data contains correct information."""
model = AutoModel(
@@ -138,6 +140,7 @@ class TestAutoModelSerialization:
assert "created_at" in new_model.metadata
assert "updated_at" in new_model.metadata
+ @pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="Requires real LLM")
def test_dump_and_load_full(self, llm_client, embedder):
"""Test full dump/load cycle."""
model = AutoModel(
diff --git a/tests/types/test_set_dedup.py b/tests/types/test_set_dedup.py
index 4ba73ac..9839c5e 100644
--- a/tests/types/test_set_dedup.py
+++ b/tests/types/test_set_dedup.py
@@ -3,6 +3,7 @@
import pytest
from pydantic import BaseModel, Field
from typing import Optional
+from ontomem.merger import MergeStrategy
from hyperextract.types import AutoSet
from tests.fixtures import KeywordSchema
@@ -52,6 +53,7 @@ class TestAutoSetDedup:
llm_client=llm_client,
embedder=embedder,
key_extractor=lambda x: x.term,
+ strategy_or_merger=MergeStrategy.MERGE_FIELD,
)
auto_set.add(KeywordItemSchema(term="Python", category="Programming"))
diff --git a/tests/types/test_set_operations.py b/tests/types/test_set_operations.py
index 07d79f9..d1bca30 100644
--- a/tests/types/test_set_operations.py
+++ b/tests/types/test_set_operations.py
@@ -3,6 +3,7 @@
import pytest
from pydantic import BaseModel, Field
from typing import Optional
+from ontomem.merger import MergeStrategy
from hyperextract.types import AutoSet
@@ -24,6 +25,7 @@ class TestAutoSetOperations:
llm_client=llm_client,
embedder=embedder,
key_extractor=lambda x: x.term,
+ strategy_or_merger=MergeStrategy.MERGE_FIELD,
)
for term in terms:
auto_set.add(KeywordItemSchema(term=term))
@@ -154,6 +156,7 @@ class TestAutoSetComparison:
llm_client=llm_client,
embedder=embedder,
key_extractor=lambda x: x.term,
+ strategy_or_merger=MergeStrategy.MERGE_FIELD,
)
for term in terms:
auto_set.add(KeywordItemSchema(term=term))
diff --git a/uv.lock b/uv.lock
index 694480c..79076a8 100644
--- a/uv.lock
+++ b/uv.lock
@@ -900,7 +900,7 @@ wheels = [
[[package]]
name = "hyperextract"
-version = "0.1.0"
+version = "0.1.1"
source = { editable = "." }
dependencies = [
{ name = "faiss-cpu" },