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(templates): 统一提取指南字段名从extraction_guide改为guide

yifanfeng97d2260a472805
diff --git a/examples/config_template_demo.py b/examples/config_template_demo.py
index ac004f4..e3bffdb 100644
--- a/examples/config_template_demo.py
+++ b/examples/config_template_demo.py
@@ -20,7 +20,7 @@ from hyperextract.utils.template_engine import Gallery, TemplateFactory
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "general"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "general"
INPUT_FILE = TEST_SAMPLES_ROOT / "biography_scientist.md"
diff --git a/examples/template_finance_demo.py b/examples/template_finance_demo.py
index 7f0ef83..e088689 100644
--- a/examples/template_finance_demo.py
+++ b/examples/template_finance_demo.py
@@ -60,7 +60,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "finance"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "finance"
# 模板到输入文件的映射关系
TEMPLATE_TO_INPUT = {
diff --git a/examples/template_general_demo.py b/examples/template_general_demo.py
index 4fa01b5..b1e461a 100644
--- a/examples/template_general_demo.py
+++ b/examples/template_general_demo.py
@@ -50,7 +50,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "general"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "general"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/examples/template_industry_demo.py b/examples/template_industry_demo.py
index 9caa3b3..8dc1fa2 100644
--- a/examples/template_industry_demo.py
+++ b/examples/template_industry_demo.py
@@ -54,7 +54,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
TEST_SAMPLES_ROOT = (
Path(__file__).parent.parent
/ "tests"
- / "fixtures"
+ / "test_data"
/ "test_samples"
/ "zh"
/ "industry"
diff --git a/examples/template_legal_demo.py b/examples/template_legal_demo.py
index 9d34e38..c75a0e6 100644
--- a/examples/template_legal_demo.py
+++ b/examples/template_legal_demo.py
@@ -45,7 +45,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "legal"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "legal"
# 模板到输入文件的映射关系
TEMPLATE_TO_INPUT = {
diff --git a/examples/template_medicine_demo.py b/examples/template_medicine_demo.py
index 2e84c45..cfae9aa 100644
--- a/examples/template_medicine_demo.py
+++ b/examples/template_medicine_demo.py
@@ -52,7 +52,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "medicine"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "medicine"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/examples/template_tcm_demo.py b/examples/template_tcm_demo.py
index 3ec5ca5..bbc3634 100644
--- a/examples/template_tcm_demo.py
+++ b/examples/template_tcm_demo.py
@@ -45,7 +45,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "tcm"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "tcm"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/__init__.py b/hyperextract/__init__.py
index 550c14e..33f4ead 100644
--- a/hyperextract/__init__.py
+++ b/hyperextract/__init__.py
@@ -7,6 +7,16 @@ Architecture:
- types: Core data structure primitives (AutoModel, AutoList, AutoSet, AutoGraph, etc.)
- methods: Algorithms and strategies (rag, typical graph construction methods)
- templates: Domain-specific extraction templates
+
+Usage:
+ from hyperextract import Template
+
+ # Search templates
+ Template.list()
+ Template.search("知识图谱")
+
+ # Create template (auto reads config from ~/.he/config.toml)
+ template = Template.create("knowledge_graph")
"""
# Core AutoType primitives
@@ -22,6 +32,10 @@ from .types import (
AutoSpatioTemporalGraph,
)
+# Template engine API
+from .utils.template_engine import Template
+
+
__version__ = "0.1.0"
__author__ = "Yifan Feng"
__email__ = "[email protected]"
@@ -39,4 +53,6 @@ __all__ = [
"AutoTemporalGraph",
"AutoSpatialGraph",
"AutoSpatioTemporalGraph",
+ # Template engine
+ "Template",
]
diff --git a/hyperextract/cli/config.py b/hyperextract/cli/config.py
index 97e19db..81355fd 100644
--- a/hyperextract/cli/config.py
+++ b/hyperextract/cli/config.py
@@ -2,6 +2,8 @@
import os
import json
+import tomllib
+import tomli_w
from pathlib import Path
from typing import Optional, Dict, Any
from dataclasses import dataclass
@@ -79,11 +81,6 @@ class ConfigManager:
if not self.config_path.exists():
return
- try:
- import tomli as tomllib
- except ImportError:
- import tomllib
-
with open(self.config_path, "rb") as f:
data = tomllib.load(f)
@@ -96,9 +93,6 @@ class ConfigManager:
"""Save configuration to file."""
DEFAULT_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
- import tomli as tomllib
- import tomli_w
-
data = {
"llm": self.llm.to_dict(),
"embedder": self.embedder.to_dict(),
diff --git a/hyperextract/cli/templates.py b/hyperextract/cli/templates.py
index 0f89bac..1951336 100644
--- a/hyperextract/cli/templates.py
+++ b/hyperextract/cli/templates.py
@@ -2,114 +2,36 @@
from typing import Optional, Any, Type
-from hyperextract.utils.template_engine import Gallery, TemplateFactory, TemplateConfig
+from hyperextract.utils.template_engine import Gallery, TemplateConfig
def resolve_template(template_str: str, lang: str = "zh") -> Type:
- """
- Resolve a template string to a template instance.
-
+ """Resolve a template string to a template instance.
+
Args:
- template_str: Template name (e.g., "KnowledgeGraph", "zh/finance/risk_assessment")
+ template_str: Template name (e.g., "knowledge_graph", "zh/finance/risk_assessment")
lang: Language (zh/en)
-
+
Returns:
TemplateWrapper instance
-
+
Raises:
ValueError: If template not found
"""
- original_str = template_str
-
- config = Gallery.get(template_str)
- if config is not None:
- return _create_template_from_config(config)
-
- parts = template_str.split("/")
- if len(parts) == 1:
- template_name = parts[0]
- search_name = f"{lang}/{template_name}"
- config = Gallery.get(search_name)
- if config is not None:
- return _create_template_from_config(config)
- else:
- template_lang = parts[0]
- if template_lang not in ["zh", "en"]:
- template_lang = lang
- template_name = parts[-1]
-
- full_name = f"{template_lang}/{template_name}"
- config = Gallery.get(full_name)
- if config is not None:
- return _create_template_from_config(config)
-
- available = Gallery.list_all()
- raise ValueError(f"Template '{original_str}' not found. Available templates: {available[:10]}...")
+ return Gallery.create(template_str, lang)
def resolve_template_config(template_str: str, lang: str = "zh") -> Optional[TemplateConfig]:
- """
- Resolve a template string to a TemplateConfig.
-
+ """Resolve a template string to a TemplateConfig.
+
Args:
template_str: Template name
lang: Language (zh/en)
-
+
Returns:
TemplateConfig if found, None otherwise
"""
- original_str = template_str
-
- config = Gallery.get(template_str)
- if config is not None:
- return config
-
- parts = template_str.split("/")
- if len(parts) == 1:
- template_name = parts[0]
- search_name = f"{lang}/{template_name}"
- config = Gallery.get(search_name)
- if config is not None:
- return config
- else:
- template_lang = parts[0]
- if template_lang not in ["zh", "en"]:
- template_lang = lang
- template_name = parts[-1]
- full_name = f"{template_lang}/{template_name}"
- return Gallery.get(full_name)
-
-
-def _create_template_from_config(config: TemplateConfig):
- """Create a template instance from config using TemplateFactory."""
- from .config import ConfigManager
-
- config_manager = ConfigManager()
- llm_config = config_manager.get_llm_config()
- embedder_config = config_manager.get_embedder_config()
-
- if llm_config.provider == "openai":
- from langchain_openai import ChatOpenAI
- llm_client = ChatOpenAI(
- model=llm_config.model,
- api_key=llm_config.api_key,
- base_url=llm_config.base_url or None,
- temperature=0,
- )
- else:
- raise ValueError(f"Unsupported LLM provider: {llm_config.provider}")
-
- if embedder_config.provider == "openai":
- from langchain_openai import OpenAIEmbeddings
- embedder = OpenAIEmbeddings(
- model=embedder_config.model,
- api_key=embedder_config.api_key,
- base_url=embedder_config.base_url or None,
- )
- else:
- raise ValueError(f"Unsupported Embedder provider: {embedder_config.provider}")
-
- return TemplateFactory.create(config, llm_client, embedder)
+ return Gallery._resolve_config(template_str, lang)
def get_auto_type_from_template(template_or_config: Any) -> str:
diff --git a/hyperextract/templates/legacy/examples/template_agriculture_demo.py b/hyperextract/templates/legacy/examples/template_agriculture_demo.py
index 77081bd..57670d3 100644
--- a/hyperextract/templates/legacy/examples/template_agriculture_demo.py
+++ b/hyperextract/templates/legacy/examples/template_agriculture_demo.py
@@ -39,7 +39,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "agriculture"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "agriculture"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/examples/template_biology_demo.py b/hyperextract/templates/legacy/examples/template_biology_demo.py
index 76754fe..5d8629b 100644
--- a/hyperextract/templates/legacy/examples/template_biology_demo.py
+++ b/hyperextract/templates/legacy/examples/template_biology_demo.py
@@ -43,7 +43,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "biology"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "biology"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/examples/template_food_demo.py b/hyperextract/templates/legacy/examples/template_food_demo.py
index 10a12ca..be31021 100644
--- a/hyperextract/templates/legacy/examples/template_food_demo.py
+++ b/hyperextract/templates/legacy/examples/template_food_demo.py
@@ -38,7 +38,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "food"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "food"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/examples/template_history_demo.py b/hyperextract/templates/legacy/examples/template_history_demo.py
index 525815d..df08710 100644
--- a/hyperextract/templates/legacy/examples/template_history_demo.py
+++ b/hyperextract/templates/legacy/examples/template_history_demo.py
@@ -44,7 +44,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "history"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "history"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/examples/template_literature_demo.py b/hyperextract/templates/legacy/examples/template_literature_demo.py
index 8e3e348..ddd18e2 100644
--- a/hyperextract/templates/legacy/examples/template_literature_demo.py
+++ b/hyperextract/templates/legacy/examples/template_literature_demo.py
@@ -42,7 +42,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "literature"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "literature"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/examples/template_news_demo.py b/hyperextract/templates/legacy/examples/template_news_demo.py
index bee275f..7b1fb46 100644
--- a/hyperextract/templates/legacy/examples/template_news_demo.py
+++ b/hyperextract/templates/legacy/examples/template_news_demo.py
@@ -42,7 +42,7 @@ from langchain_openai import ChatOpenAI, OpenAIEmbeddings
# ==========================================
# 测试文件根目录
-TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "news"
+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "test_data" / "test_samples" / "zh" / "news"
# 模板到输入文件的映射关系(根据 README 中的典型应用场景)
TEMPLATE_TO_INPUT = {
diff --git a/hyperextract/templates/legacy/presets/agriculture/amendment_plan.yaml b/hyperextract/templates/legacy/presets/agriculture/amendment_plan.yaml
index e2a96a0..6bc4185 100644
--- a/hyperextract/templates/legacy/presets/agriculture/amendment_plan.yaml
+++ b/hyperextract/templates/legacy/presets/agriculture/amendment_plan.yaml
@@ -41,7 +41,7 @@ edge_schema:
description:
zh: "详细描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的土壤肥料专家,请从土壤改良方案报告中提取改良方案图。
diff --git a/hyperextract/templates/legacy/presets/agriculture/crop_growth_cycle.yaml b/hyperextract/templates/legacy/presets/agriculture/crop_growth_cycle.yaml
index 38cf5bf..cbe6578 100644
--- a/hyperextract/templates/legacy/presets/agriculture/crop_growth_cycle.yaml
+++ b/hyperextract/templates/legacy/presets/agriculture/crop_growth_cycle.yaml
@@ -41,7 +41,7 @@ edge_schema:
description:
zh: "关系描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的农业技术专家,请从农业技术手册中提取作物生长周期图。
diff --git a/hyperextract/templates/legacy/presets/agriculture/field_observation_list.yaml b/hyperextract/templates/legacy/presets/agriculture/field_observation_list.yaml
index 111454e..8230f30 100644
--- a/hyperextract/templates/legacy/presets/agriculture/field_observation_list.yaml
+++ b/hyperextract/templates/legacy/presets/agriculture/field_observation_list.yaml
@@ -38,7 +38,7 @@ item_schema:
description:
zh: "建议措施列表"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的农技人员,请从巡田报告中提取结构化的田间观测记录。
diff --git a/hyperextract/templates/legacy/presets/agriculture/pest_control_hypergraph.yaml b/hyperextract/templates/legacy/presets/agriculture/pest_control_hypergraph.yaml
index 198ed24..bba7f4d 100644
--- a/hyperextract/templates/legacy/presets/agriculture/pest_control_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/agriculture/pest_control_hypergraph.yaml
@@ -49,7 +49,7 @@ edge_schema:
description:
zh: "安全间隔期"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的植物保护专家,请从农业技术手册中提取病虫害防治超图。
diff --git a/hyperextract/templates/legacy/presets/agriculture/soil_nutrient_model.yaml b/hyperextract/templates/legacy/presets/agriculture/soil_nutrient_model.yaml
index df97a3a..966c41f 100644
--- a/hyperextract/templates/legacy/presets/agriculture/soil_nutrient_model.yaml
+++ b/hyperextract/templates/legacy/presets/agriculture/soil_nutrient_model.yaml
@@ -109,7 +109,7 @@ schema:
zh: "有效硼含量,单位mg/kg"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的土壤肥料专家,请从土壤检测报告中提取土壤养分指标。
diff --git a/hyperextract/templates/legacy/presets/biology/binding_site_model.yaml b/hyperextract/templates/legacy/presets/biology/binding_site_model.yaml
index c764c9c..0d8903c 100644
--- a/hyperextract/templates/legacy/presets/biology/binding_site_model.yaml
+++ b/hyperextract/templates/legacy/presets/biology/binding_site_model.yaml
@@ -39,7 +39,7 @@ schema:
zh: "配体信息,如结合的配体分子或药物"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的结构生物学专家,请从文本中提取蛋白质的关键位点信息。
diff --git a/hyperextract/templates/legacy/presets/biology/biochemical_reaction_hypergraph.yaml b/hyperextract/templates/legacy/presets/biology/biochemical_reaction_hypergraph.yaml
index ad7c3cb..2c01e7c 100644
--- a/hyperextract/templates/legacy/presets/biology/biochemical_reaction_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/biology/biochemical_reaction_hypergraph.yaml
@@ -56,7 +56,7 @@ edge_schema:
zh: "反应详细描述,包括反应条件或生物学意义"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的生物化学专家,请从代谢通路文献中提取生化分子及其反应关系。
diff --git a/hyperextract/templates/legacy/presets/biology/biodiversity_registry.yaml b/hyperextract/templates/legacy/presets/biology/biodiversity_registry.yaml
index e635e98..33709bb 100644
--- a/hyperextract/templates/legacy/presets/biology/biodiversity_registry.yaml
+++ b/hyperextract/templates/legacy/presets/biology/biodiversity_registry.yaml
@@ -42,7 +42,7 @@ item_schema:
zh: "观测详情,包括观测时间、地点和数量记录"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的生态学专家,请从调查报告中提取所有物种观测记录,构建物种名录。
diff --git a/hyperextract/templates/legacy/presets/biology/phylogenetic_relation_graph.yaml b/hyperextract/templates/legacy/presets/biology/phylogenetic_relation_graph.yaml
index c5f54d0..9607cd9 100644
--- a/hyperextract/templates/legacy/presets/biology/phylogenetic_relation_graph.yaml
+++ b/hyperextract/templates/legacy/presets/biology/phylogenetic_relation_graph.yaml
@@ -53,7 +53,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的进化生物学专家,请从生物学文献中提取物种或分类单元及其系统发育关系。
diff --git a/hyperextract/templates/legacy/presets/biology/protein_complex_map.yaml b/hyperextract/templates/legacy/presets/biology/protein_complex_map.yaml
index e20a98b..5f19a84 100644
--- a/hyperextract/templates/legacy/presets/biology/protein_complex_map.yaml
+++ b/hyperextract/templates/legacy/presets/biology/protein_complex_map.yaml
@@ -48,7 +48,7 @@ edge_schema:
zh: "组装细节,如哪些亚基相互作用"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的结构生物学专家,请从蛋白质结构文献中提取蛋白质及其复合物组成关系。
diff --git a/hyperextract/templates/legacy/presets/biology/regulatory_network.yaml b/hyperextract/templates/legacy/presets/biology/regulatory_network.yaml
index 7d77eb7..36455e7 100644
--- a/hyperextract/templates/legacy/presets/biology/regulatory_network.yaml
+++ b/hyperextract/templates/legacy/presets/biology/regulatory_network.yaml
@@ -53,7 +53,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的分子生物学专家,请从文本中提取基因、转录因子及其之间的调控关系。
diff --git a/hyperextract/templates/legacy/presets/biology/species_interaction_web.yaml b/hyperextract/templates/legacy/presets/biology/species_interaction_web.yaml
index 01f4c87..115b951 100644
--- a/hyperextract/templates/legacy/presets/biology/species_interaction_web.yaml
+++ b/hyperextract/templates/legacy/presets/biology/species_interaction_web.yaml
@@ -47,7 +47,7 @@ edge_schema:
zh: "关系详细描述,包括具体行为或机制"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的生态学专家,请从文本中提取物种及其之间的相互作用关系。
diff --git a/hyperextract/templates/legacy/presets/biology/taxonomic_tree.yaml b/hyperextract/templates/legacy/presets/biology/taxonomic_tree.yaml
index 7c30c04..11dc4dc 100644
--- a/hyperextract/templates/legacy/presets/biology/taxonomic_tree.yaml
+++ b/hyperextract/templates/legacy/presets/biology/taxonomic_tree.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "详细描述,包含具体的分类路径信息"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的生物分类学专家,请从生物学文献中提取分类单元及其层级包含关系。
diff --git a/hyperextract/templates/legacy/presets/food/dish_review_summary.yaml b/hyperextract/templates/legacy/presets/food/dish_review_summary.yaml
index 6e7f31a..bed2373 100644
--- a/hyperextract/templates/legacy/presets/food/dish_review_summary.yaml
+++ b/hyperextract/templates/legacy/presets/food/dish_review_summary.yaml
@@ -46,7 +46,7 @@ item_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的美食评论家,请从文本中提取每道菜品的核心评价信息,形成食评摘要清单。
diff --git a/hyperextract/templates/legacy/presets/food/ingredient_composition_hypergraph.yaml b/hyperextract/templates/legacy/presets/food/ingredient_composition_hypergraph.yaml
index a5d4697..211c96f 100644
--- a/hyperextract/templates/legacy/presets/food/ingredient_composition_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/food/ingredient_composition_hypergraph.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的烹饪大师,请从文本中提取菜品与食材的配伍关系,建模为超边结构。
diff --git a/hyperextract/templates/legacy/presets/food/recipe_collection.yaml b/hyperextract/templates/legacy/presets/food/recipe_collection.yaml
index a6fbed8..3b8abc8 100644
--- a/hyperextract/templates/legacy/presets/food/recipe_collection.yaml
+++ b/hyperextract/templates/legacy/presets/food/recipe_collection.yaml
@@ -34,7 +34,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的餐饮知识专家,请从文本中提取所有独立菜品实体,形成菜谱名录。
diff --git a/hyperextract/templates/legacy/presets/food/sensory_evaluation_graph.yaml b/hyperextract/templates/legacy/presets/food/sensory_evaluation_graph.yaml
index be67eb3..49eec98 100644
--- a/hyperextract/templates/legacy/presets/food/sensory_evaluation_graph.yaml
+++ b/hyperextract/templates/legacy/presets/food/sensory_evaluation_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的美食评论家,请从文本中提取感官评价图谱,包括菜品、口感/味道、食材/技法之间的归因关系。
diff --git a/hyperextract/templates/legacy/presets/food/standard_recipe_card.yaml b/hyperextract/templates/legacy/presets/food/standard_recipe_card.yaml
index c541537..f12d3ae 100644
--- a/hyperextract/templates/legacy/presets/food/standard_recipe_card.yaml
+++ b/hyperextract/templates/legacy/presets/food/standard_recipe_card.yaml
@@ -88,7 +88,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的烹饪大师,请从文本中提取单个菜品的完整标准食谱信息。
diff --git a/hyperextract/templates/legacy/presets/history/chronological_event_chain.yaml b/hyperextract/templates/legacy/presets/history/chronological_event_chain.yaml
index aa17abc..3f09f89 100644
--- a/hyperextract/templates/legacy/presets/history/chronological_event_chain.yaml
+++ b/hyperextract/templates/legacy/presets/history/chronological_event_chain.yaml
@@ -45,7 +45,7 @@ edge_schema:
description:
zh: "事件因果描述,说明两事件之间的逻辑关系"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取历史事件以及它们之间的时间因果关系。
diff --git a/hyperextract/templates/legacy/presets/history/epistolary_knowledge_graph.yaml b/hyperextract/templates/legacy/presets/history/epistolary_knowledge_graph.yaml
index c224da3..8e783b4 100644
--- a/hyperextract/templates/legacy/presets/history/epistolary_knowledge_graph.yaml
+++ b/hyperextract/templates/legacy/presets/history/epistolary_knowledge_graph.yaml
@@ -58,7 +58,7 @@ edge_schema:
description:
zh: "信件内容摘要"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取书信中的人物以及书信内容关系。
diff --git a/hyperextract/templates/legacy/presets/history/historical_context_graph.yaml b/hyperextract/templates/legacy/presets/history/historical_context_graph.yaml
index b6d5bca..8fe656b 100644
--- a/hyperextract/templates/legacy/presets/history/historical_context_graph.yaml
+++ b/hyperextract/templates/legacy/presets/history/historical_context_graph.yaml
@@ -41,7 +41,7 @@ edge_schema:
description:
zh: "关系描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取历史背景相关的实体以及它们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/history/historical_knowledge_graph.yaml b/hyperextract/templates/legacy/presets/history/historical_knowledge_graph.yaml
index d90e570..b7a63ba 100644
--- a/hyperextract/templates/legacy/presets/history/historical_knowledge_graph.yaml
+++ b/hyperextract/templates/legacy/presets/history/historical_knowledge_graph.yaml
@@ -46,7 +46,7 @@ edge_schema:
description:
zh: "关系描述,描述两人之间的具体互动或关系详情"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取所有历史人物以及他们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/history/memory_flashback_list.yaml b/hyperextract/templates/legacy/presets/history/memory_flashback_list.yaml
index edcc639..9dcb70a 100644
--- a/hyperextract/templates/legacy/presets/history/memory_flashback_list.yaml
+++ b/hyperextract/templates/legacy/presets/history/memory_flashback_list.yaml
@@ -38,7 +38,7 @@ item_schema:
zh: "补充描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
请从文本中提取口述历史或回忆录中的回忆片段。
diff --git a/hyperextract/templates/legacy/presets/history/multi_participant_event_map.yaml b/hyperextract/templates/legacy/presets/history/multi_participant_event_map.yaml
index 9e1a66f..9c6af56 100644
--- a/hyperextract/templates/legacy/presets/history/multi_participant_event_map.yaml
+++ b/hyperextract/templates/legacy/presets/history/multi_participant_event_map.yaml
@@ -51,7 +51,7 @@ edge_schema:
description:
zh: "参与者列表,与节点对应"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取历史事件中的参与者以及他们组成的事件超边。
diff --git a/hyperextract/templates/legacy/presets/history/narrative_relation_graph.yaml b/hyperextract/templates/legacy/presets/history/narrative_relation_graph.yaml
index 5f0f7f7..3bcd26f 100644
--- a/hyperextract/templates/legacy/presets/history/narrative_relation_graph.yaml
+++ b/hyperextract/templates/legacy/presets/history/narrative_relation_graph.yaml
@@ -42,7 +42,7 @@ edge_schema:
description:
zh: "互动内容或评价具体描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取口述历史或回忆录中的人物以及他们之间的互动与评价关系。
diff --git a/hyperextract/templates/legacy/presets/history/personal_trajectory_hypergraph.yaml b/hyperextract/templates/legacy/presets/history/personal_trajectory_hypergraph.yaml
index 56c368d..7357daf 100644
--- a/hyperextract/templates/legacy/presets/history/personal_trajectory_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/history/personal_trajectory_hypergraph.yaml
@@ -48,7 +48,7 @@ edge_schema:
zh: "阶段描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取人物的人生阶段轨迹。
diff --git a/hyperextract/templates/legacy/presets/history/political_struggle_hypergraph.yaml b/hyperextract/templates/legacy/presets/history/political_struggle_hypergraph.yaml
index b6d027f..c9d40c4 100644
--- a/hyperextract/templates/legacy/presets/history/political_struggle_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/history/political_struggle_hypergraph.yaml
@@ -64,7 +64,7 @@ edge_schema:
description:
zh: "结果描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的历史学专家,请从文本中提取政治博弈或战役中的人物以及他们组成的博弈事件超边。
diff --git a/hyperextract/templates/legacy/presets/literature/character_arc_timeline.yaml b/hyperextract/templates/legacy/presets/literature/character_arc_timeline.yaml
index 46d0e2e..217e2d5 100644
--- a/hyperextract/templates/legacy/presets/literature/character_arc_timeline.yaml
+++ b/hyperextract/templates/legacy/presets/literature/character_arc_timeline.yaml
@@ -46,7 +46,7 @@ edge_schema:
description:
zh: "关系描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的影视剧本分析师,请从文本中提取叙事元素以及它们之间的关系,构建异质图。
diff --git a/hyperextract/templates/legacy/presets/literature/complex_character_relation.yaml b/hyperextract/templates/legacy/presets/literature/complex_character_relation.yaml
index 937fbd0..20e15e0 100644
--- a/hyperextract/templates/legacy/presets/literature/complex_character_relation.yaml
+++ b/hyperextract/templates/legacy/presets/literature/complex_character_relation.yaml
@@ -47,7 +47,7 @@ edge_schema:
zh: "来源情节"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的小说分析师,请从文本中提取人物以及它们之间的复杂关系超边。
diff --git a/hyperextract/templates/legacy/presets/literature/critique_argument_hypergraph.yaml b/hyperextract/templates/legacy/presets/literature/critique_argument_hypergraph.yaml
index 22821dc..341c086 100644
--- a/hyperextract/templates/legacy/presets/literature/critique_argument_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/literature/critique_argument_hypergraph.yaml
@@ -47,7 +47,7 @@ edge_schema:
description:
zh: "论证描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的文学评论家,请从文本中提取论证元素以及它们组成的论证超边。
diff --git a/hyperextract/templates/legacy/presets/literature/motif_association_net.yaml b/hyperextract/templates/legacy/presets/literature/motif_association_net.yaml
index 8cdb797..5cd99ab 100644
--- a/hyperextract/templates/legacy/presets/literature/motif_association_net.yaml
+++ b/hyperextract/templates/legacy/presets/literature/motif_association_net.yaml
@@ -37,7 +37,7 @@ edge_schema:
description:
zh: "关联描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的文学评论家,请从文本中提取意象以及它们之间的关联关系。
diff --git a/hyperextract/templates/legacy/presets/literature/narrative_event_chain.yaml b/hyperextract/templates/legacy/presets/literature/narrative_event_chain.yaml
index fab458e..31009df 100644
--- a/hyperextract/templates/legacy/presets/literature/narrative_event_chain.yaml
+++ b/hyperextract/templates/legacy/presets/literature/narrative_event_chain.yaml
@@ -37,7 +37,7 @@ edge_schema:
description:
zh: "因果关系描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的小说分析师,请从文本中提取情节转折点以及它们之间的因果关系。
diff --git a/hyperextract/templates/legacy/presets/literature/narrative_structure_tree.yaml b/hyperextract/templates/legacy/presets/literature/narrative_structure_tree.yaml
index 010ab42..195c1e4 100644
--- a/hyperextract/templates/legacy/presets/literature/narrative_structure_tree.yaml
+++ b/hyperextract/templates/legacy/presets/literature/narrative_structure_tree.yaml
@@ -41,7 +41,7 @@ edge_schema:
description:
zh: "描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的文学评论家,请从文本中提取叙事结构单元以及它们之间的层级关系。
diff --git a/hyperextract/templates/legacy/presets/literature/scene_event_hypergraph.yaml b/hyperextract/templates/legacy/presets/literature/scene_event_hypergraph.yaml
index 3b10629..46bf745 100644
--- a/hyperextract/templates/legacy/presets/literature/scene_event_hypergraph.yaml
+++ b/hyperextract/templates/legacy/presets/literature/scene_event_hypergraph.yaml
@@ -50,7 +50,7 @@ edge_schema:
description:
zh: "时间段:日/夜/晨/昏"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的影视剧本分析师,请从文本中提取场景元素以及它们组成的场景事件超边。
diff --git a/hyperextract/templates/legacy/presets/literature/story_entity_graph.yaml b/hyperextract/templates/legacy/presets/literature/story_entity_graph.yaml
index 390659c..34fa693 100644
--- a/hyperextract/templates/legacy/presets/literature/story_entity_graph.yaml
+++ b/hyperextract/templates/legacy/presets/literature/story_entity_graph.yaml
@@ -41,7 +41,7 @@ edge_schema:
description:
zh: "描述"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的小说分析师,请从文本中提取故事实体以及它们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/news/complex_relation_net.yaml b/hyperextract/templates/legacy/presets/news/complex_relation_net.yaml
index 44be3c8..72162c2 100644
--- a/hyperextract/templates/legacy/presets/news/complex_relation_net.yaml
+++ b/hyperextract/templates/legacy/presets/news/complex_relation_net.yaml
@@ -49,7 +49,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻调查记者,请从调查报道文本中提取参与者以及它们之间的复杂关系。
diff --git a/hyperextract/templates/legacy/presets/news/impact_chain.yaml b/hyperextract/templates/legacy/presets/news/impact_chain.yaml
index 0f840f6..f0df671 100644
--- a/hyperextract/templates/legacy/presets/news/impact_chain.yaml
+++ b/hyperextract/templates/legacy/presets/news/impact_chain.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的政策分析师,请从政策分析文本中提取影响链实体和它们之间的因果关系。
diff --git a/hyperextract/templates/legacy/presets/news/investigative_context_graph.yaml b/hyperextract/templates/legacy/presets/news/investigative_context_graph.yaml
index 4c06288..fd8be49 100644
--- a/hyperextract/templates/legacy/presets/news/investigative_context_graph.yaml
+++ b/hyperextract/templates/legacy/presets/news/investigative_context_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻调查记者,请从调查报道文本中提取实体和它们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/news/key_event_sequence.yaml b/hyperextract/templates/legacy/presets/news/key_event_sequence.yaml
index 0f09b3a..1184d6c 100644
--- a/hyperextract/templates/legacy/presets/news/key_event_sequence.yaml
+++ b/hyperextract/templates/legacy/presets/news/key_event_sequence.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻调查记者,请从调查报道文本中提取关键事件以及它们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/news/live_update_timeline.yaml b/hyperextract/templates/legacy/presets/news/live_update_timeline.yaml
index 611ea64..497e7e3 100644
--- a/hyperextract/templates/legacy/presets/news/live_update_timeline.yaml
+++ b/hyperextract/templates/legacy/presets/news/live_update_timeline.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻直播编辑,请从实时直播文本中提取时间更新点以及它们之间的关系。
diff --git a/hyperextract/templates/legacy/presets/news/news_entity_graph.yaml b/hyperextract/templates/legacy/presets/news/news_entity_graph.yaml
index 54f4936..97a3120 100644
--- a/hyperextract/templates/legacy/presets/news/news_entity_graph.yaml
+++ b/hyperextract/templates/legacy/presets/news/news_entity_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻编辑,请从新闻文本中提取实体和它们之间的动作或关系。
diff --git a/hyperextract/templates/legacy/presets/news/news_summary_model.yaml b/hyperextract/templates/legacy/presets/news/news_summary_model.yaml
index bc3ca55..ea61545 100644
--- a/hyperextract/templates/legacy/presets/news/news_summary_model.yaml
+++ b/hyperextract/templates/legacy/presets/news/news_summary_model.yaml
@@ -58,7 +58,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的新闻编辑,请从新闻文本中提取结构化的5W1H要素,构建新闻摘要。
diff --git a/hyperextract/templates/legacy/presets/news/viewpoint_structure.yaml b/hyperextract/templates/legacy/presets/news/viewpoint_structure.yaml
index 4c3b1b2..73649c1 100644
--- a/hyperextract/templates/legacy/presets/news/viewpoint_structure.yaml
+++ b/hyperextract/templates/legacy/presets/news/viewpoint_structure.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的政策分析师,请从文本中提取论证元素以及它们组成的观点聚合超边。
diff --git a/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml b/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml
index 3bb4c00..ac16c87 100644
--- a/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml
+++ b/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的财报电话会议情绪分析师,请从文本中提取主题、发言人、情绪信号及其多维关系。
diff --git a/hyperextract/templates/presets/finance/company_history_timeline.yaml b/hyperextract/templates/presets/finance/company_history_timeline.yaml
index 5be91ef..3a6a95c 100644
--- a/hyperextract/templates/presets/finance/company_history_timeline.yaml
+++ b/hyperextract/templates/presets/finance/company_history_timeline.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的公司历史分析师,请从文本中提取公司相关的实体以及里程碑事件。
diff --git a/hyperextract/templates/presets/finance/discussion_graph.yaml b/hyperextract/templates/presets/finance/discussion_graph.yaml
index 4a3c50d..eb8b65a 100644
--- a/hyperextract/templates/presets/finance/discussion_graph.yaml
+++ b/hyperextract/templates/presets/finance/discussion_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的财报会议分析师,请从文本中提取讨论中出现的实体以及它们之间的关系。
diff --git a/hyperextract/templates/presets/finance/earnings_call_summary.yaml b/hyperextract/templates/presets/finance/earnings_call_summary.yaml
index f0e8c70..f9970fb 100644
--- a/hyperextract/templates/presets/finance/earnings_call_summary.yaml
+++ b/hyperextract/templates/presets/finance/earnings_call_summary.yaml
@@ -106,7 +106,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的分析师,请从财报电话会议记录中提取关键财务指标、业绩指引和整体基调。
diff --git a/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml b/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml
index 8a46336..7ce028b 100644
--- a/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml
+++ b/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml
@@ -49,7 +49,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的金融多因子分析师,请从文本中提取因子(作为节点)和因子导致的结果(作为超边)。
diff --git a/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml b/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml
index 3d222f5..efce097 100644
--- a/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml
+++ b/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml
@@ -88,7 +88,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的财务分析师,请从 SEC 申报文件中提取关键财务数据。
diff --git a/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml b/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml
index f1a6221..cc47a0a 100644
--- a/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml
+++ b/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml
@@ -52,7 +52,7 @@ item_schema:
required: false
default: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的监管申报分析师,请从 SEC 申报文件的风险因素章节中提取并归类所有单项风险因素。
diff --git a/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml b/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml
index 5726874..75619c7 100644
--- a/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml
+++ b/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的财务分析师,请从文本中提取财务实体及其跨时间的量化关系。
diff --git a/hyperextract/templates/presets/finance/financial_forecast.yaml b/hyperextract/templates/presets/finance/financial_forecast.yaml
index 0c5e302..b8e0629 100644
--- a/hyperextract/templates/presets/finance/financial_forecast.yaml
+++ b/hyperextract/templates/presets/finance/financial_forecast.yaml
@@ -58,7 +58,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的金融分析师,请从文本中提取所有财务预测和估算。
diff --git a/hyperextract/templates/presets/finance/management_guidance_list.yaml b/hyperextract/templates/presets/finance/management_guidance_list.yaml
index 5446e57..401c6f2 100644
--- a/hyperextract/templates/presets/finance/management_guidance_list.yaml
+++ b/hyperextract/templates/presets/finance/management_guidance_list.yaml
@@ -58,7 +58,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的分析师,请从财报电话会议记录中提取所有前瞻性声明和业绩指引。
diff --git a/hyperextract/templates/presets/finance/market_narrative_timeline.yaml b/hyperextract/templates/presets/finance/market_narrative_timeline.yaml
index 0f258f8..05707a2 100644
--- a/hyperextract/templates/presets/finance/market_narrative_timeline.yaml
+++ b/hyperextract/templates/presets/finance/market_narrative_timeline.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的策略师,请从财经评论中提取市场叙事以及它们随时间的演变。
diff --git a/hyperextract/templates/presets/finance/market_sentiment_model.yaml b/hyperextract/templates/presets/finance/market_sentiment_model.yaml
index abd98f2..188e831 100644
--- a/hyperextract/templates/presets/finance/market_sentiment_model.yaml
+++ b/hyperextract/templates/presets/finance/market_sentiment_model.yaml
@@ -76,7 +76,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的金融情绪分析师,请从财经新闻文章或市场评论中提取情绪快照。
diff --git a/hyperextract/templates/presets/finance/material_event_timeline.yaml b/hyperextract/templates/presets/finance/material_event_timeline.yaml
index 08bf315..b5e86d1 100644
--- a/hyperextract/templates/presets/finance/material_event_timeline.yaml
+++ b/hyperextract/templates/presets/finance/material_event_timeline.yaml
@@ -73,7 +73,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的监管申报分析师,请从文本中提取参与重大事件的实体及其之间的时序关系。
diff --git a/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml b/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml
index 618df62..dbedcad 100644
--- a/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml
+++ b/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml
@@ -79,7 +79,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的多源情绪融合分析师,请从不同来源提取情绪信号并创建聚合情绪视图。
diff --git a/hyperextract/templates/presets/finance/proceeds_usage.yaml b/hyperextract/templates/presets/finance/proceeds_usage.yaml
index 1393da0..0b9d6fa 100644
--- a/hyperextract/templates/presets/finance/proceeds_usage.yaml
+++ b/hyperextract/templates/presets/finance/proceeds_usage.yaml
@@ -46,7 +46,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的 IPO 分析师,请从招股说明书中提取所有募集资金用途分配信息。
diff --git a/hyperextract/templates/presets/finance/research_note_summary.yaml b/hyperextract/templates/presets/finance/research_note_summary.yaml
index b549b28..6cfd53a 100644
--- a/hyperextract/templates/presets/finance/research_note_summary.yaml
+++ b/hyperextract/templates/presets/finance/research_note_summary.yaml
@@ -100,7 +100,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的股票研究分析师,请从研究报告中提取核心投资论点、评级、目标价和关键论据。
diff --git a/hyperextract/templates/presets/finance/risk_assessment.yaml b/hyperextract/templates/presets/finance/risk_assessment.yaml
index c50666f..19b6b3d 100644
--- a/hyperextract/templates/presets/finance/risk_assessment.yaml
+++ b/hyperextract/templates/presets/finance/risk_assessment.yaml
@@ -73,7 +73,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的金融风险分析师,请从企业披露文件中提取风险因素、财务指标、运营结果等实体,以及它们之间的风险传导关系。
diff --git a/hyperextract/templates/presets/finance/risk_factor_list.yaml b/hyperextract/templates/presets/finance/risk_factor_list.yaml
index 666eb3c..66a0466 100644
--- a/hyperextract/templates/presets/finance/risk_factor_list.yaml
+++ b/hyperextract/templates/presets/finance/risk_factor_list.yaml
@@ -46,7 +46,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的风险分析师,请从文本中提取所有下行风险和风险因素。
diff --git a/hyperextract/templates/presets/finance/segment_performance_list.yaml b/hyperextract/templates/presets/finance/segment_performance_list.yaml
index f005959..dbf7271 100644
--- a/hyperextract/templates/presets/finance/segment_performance_list.yaml
+++ b/hyperextract/templates/presets/finance/segment_performance_list.yaml
@@ -52,7 +52,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的财务分析师,请从 SEC 申报文件中提取每个业务板块或地理区域的业绩数据。
diff --git a/hyperextract/templates/presets/finance/shareholder_structure.yaml b/hyperextract/templates/presets/finance/shareholder_structure.yaml
index 8eba2f8..6d6b798 100644
--- a/hyperextract/templates/presets/finance/shareholder_structure.yaml
+++ b/hyperextract/templates/presets/finance/shareholder_structure.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的公司治理分析师,请从招股说明书或委托声明文件中提取股权结构。
diff --git a/hyperextract/templates/presets/finance/supply_chain.yaml b/hyperextract/templates/presets/finance/supply_chain.yaml
index 6425da5..f4458f9 100644
--- a/hyperextract/templates/presets/finance/supply_chain.yaml
+++ b/hyperextract/templates/presets/finance/supply_chain.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的供应链分析师,请从文本中提取供应链实体及其关系。
diff --git a/hyperextract/templates/presets/general/clause_list.yaml b/hyperextract/templates/presets/general/clause_list.yaml
index e7389d2..50f868a 100644
--- a/hyperextract/templates/presets/general/clause_list.yaml
+++ b/hyperextract/templates/presets/general/clause_list.yaml
@@ -28,7 +28,7 @@ item_schema:
zh: "条文分类:总则、权利义务、程序、处罚、附则、其他"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的规章制度条文拆解专家,请将文本拆解为逐条的原子化条文。
diff --git a/hyperextract/templates/presets/general/compliance_logic.yaml b/hyperextract/templates/presets/general/compliance_logic.yaml
index 86dda36..8d1fa5f 100644
--- a/hyperextract/templates/presets/general/compliance_logic.yaml
+++ b/hyperextract/templates/presets/general/compliance_logic.yaml
@@ -53,7 +53,7 @@ edge_schema:
zh: "规则来源条款"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合规评估员,请从文本中提取合规要素和规则。
diff --git a/hyperextract/templates/presets/general/concept_hierarchy.yaml b/hyperextract/templates/presets/general/concept_hierarchy.yaml
index 5c7cf8f..1b54879 100644
--- a/hyperextract/templates/presets/general/concept_hierarchy.yaml
+++ b/hyperextract/templates/presets/general/concept_hierarchy.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "关系详细说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的概念结构分析专家,请从文本中提取概念及其层级关系。
diff --git a/hyperextract/templates/presets/general/cross_reference_net.yaml b/hyperextract/templates/presets/general/cross_reference_net.yaml
index 56fe140..86e0862 100644
--- a/hyperextract/templates/presets/general/cross_reference_net.yaml
+++ b/hyperextract/templates/presets/general/cross_reference_net.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "引用上下文描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的知识网络分析专家,请从文本中提取概念/条目及其相互引用关系。
diff --git a/hyperextract/templates/presets/general/encyclopedia_item.yaml b/hyperextract/templates/presets/general/encyclopedia_item.yaml
index 26cc180..e047e2d 100644
--- a/hyperextract/templates/presets/general/encyclopedia_item.yaml
+++ b/hyperextract/templates/presets/general/encyclopedia_item.yaml
@@ -48,7 +48,7 @@ schema:
zh: "相关概念/条目"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的百科全书编辑,请从文本中提取单一主体的结构化属性信息,构建百科条目信息框。
diff --git a/hyperextract/templates/presets/general/entity_registry.yaml b/hyperextract/templates/presets/general/entity_registry.yaml
index e4cd526..9072f58 100644
--- a/hyperextract/templates/presets/general/entity_registry.yaml
+++ b/hyperextract/templates/presets/general/entity_registry.yaml
@@ -23,7 +23,7 @@ item_schema:
zh: "简要描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的实体识别专家,请从文本中提取所有唯一实体,形成实体注册表。
diff --git a/hyperextract/templates/presets/general/keyword_list.yaml b/hyperextract/templates/presets/general/keyword_list.yaml
index 80d5824..aaf0870 100644
--- a/hyperextract/templates/presets/general/keyword_list.yaml
+++ b/hyperextract/templates/presets/general/keyword_list.yaml
@@ -23,7 +23,7 @@ item_schema:
zh: "关键词简要描述或上下文说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的关键词提取专家,请从文本中提取所有关键词并附带分类和描述信息。
diff --git a/hyperextract/templates/presets/general/knowledge_graph.yaml b/hyperextract/templates/presets/general/knowledge_graph.yaml
index 7bd2994..e4d6f3f 100644
--- a/hyperextract/templates/presets/general/knowledge_graph.yaml
+++ b/hyperextract/templates/presets/general/knowledge_graph.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的知识图谱提取专家,请从文本中提取实体及其关系。
diff --git a/hyperextract/templates/presets/general/life_event_timeline.yaml b/hyperextract/templates/presets/general/life_event_timeline.yaml
index fb58468..61e4739 100644
--- a/hyperextract/templates/presets/general/life_event_timeline.yaml
+++ b/hyperextract/templates/presets/general/life_event_timeline.yaml
@@ -48,7 +48,7 @@ edge_schema:
zh: "事件详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的传记年表专家,请从文本中提取人物、地点、组织等实体以及生活事件。
diff --git a/hyperextract/templates/presets/general/operational_procedure.yaml b/hyperextract/templates/presets/general/operational_procedure.yaml
index cc84fb3..1a2898e 100644
--- a/hyperextract/templates/presets/general/operational_procedure.yaml
+++ b/hyperextract/templates/presets/general/operational_procedure.yaml
@@ -58,7 +58,7 @@ edge_schema:
zh: "详细说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的流程分析专家,请从文本中提取执行程序的步骤和转换关系。
diff --git a/hyperextract/templates/presets/general/penalty_mapping.yaml b/hyperextract/templates/presets/general/penalty_mapping.yaml
index 3e9aad1..0b48df7 100644
--- a/hyperextract/templates/presets/general/penalty_mapping.yaml
+++ b/hyperextract/templates/presets/general/penalty_mapping.yaml
@@ -42,7 +42,7 @@ edge_schema:
zh: "详细说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的处罚逻辑分析专家,请从文本中提取违规处罚的因果链。
diff --git a/hyperextract/templates/presets/general/penalty_registry.yaml b/hyperextract/templates/presets/general/penalty_registry.yaml
index b8dc4f7..bdbe661 100644
--- a/hyperextract/templates/presets/general/penalty_registry.yaml
+++ b/hyperextract/templates/presets/general/penalty_registry.yaml
@@ -32,7 +32,7 @@ item_schema:
zh: "备注说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合规分析专家,请从文本中提取所有违规行为及其对应的处罚措施,形成违规处罚对照表。
diff --git a/hyperextract/templates/presets/general/personal_profile.yaml b/hyperextract/templates/presets/general/personal_profile.yaml
index 6c30683..7928ff6 100644
--- a/hyperextract/templates/presets/general/personal_profile.yaml
+++ b/hyperextract/templates/presets/general/personal_profile.yaml
@@ -69,7 +69,7 @@ schema:
zh: "个人简介"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的人物档案编辑,请从文本中提取该人物的静态属性信息,构建个人档案。
diff --git a/hyperextract/templates/presets/general/regulation_profile.yaml b/hyperextract/templates/presets/general/regulation_profile.yaml
index 4940569..b095754 100644
--- a/hyperextract/templates/presets/general/regulation_profile.yaml
+++ b/hyperextract/templates/presets/general/regulation_profile.yaml
@@ -64,7 +64,7 @@ schema:
zh: "关联规章"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的规章制度分析专家,请从文本中提取该规章制度的元数据信息,构建规章元数据快照。
diff --git a/hyperextract/templates/presets/general/social_network.yaml b/hyperextract/templates/presets/general/social_network.yaml
index 54f712d..fe6e6bd 100644
--- a/hyperextract/templates/presets/general/social_network.yaml
+++ b/hyperextract/templates/presets/general/social_network.yaml
@@ -48,7 +48,7 @@ edge_schema:
zh: "关系详细说明"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的社会关系分析专家,请从文本中提取人物、组织及其相互关系。
diff --git a/hyperextract/templates/presets/industry/emergency_response_graph.yaml b/hyperextract/templates/presets/industry/emergency_response_graph.yaml
index 71c47ab..298a894 100644
--- a/hyperextract/templates/presets/industry/emergency_response_graph.yaml
+++ b/hyperextract/templates/presets/industry/emergency_response_graph.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业应急管理分析专家,请从文本中提取事故场景、响应动作和部门,构建应急响应流程。
diff --git a/hyperextract/templates/presets/industry/equipment_topology_graph.yaml b/hyperextract/templates/presets/industry/equipment_topology_graph.yaml
index f3b3e25..972f233 100644
--- a/hyperextract/templates/presets/industry/equipment_topology_graph.yaml
+++ b/hyperextract/templates/presets/industry/equipment_topology_graph.yaml
@@ -73,7 +73,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备管理专家,请从文本中提取设备实体及其相互连接关系。
diff --git a/hyperextract/templates/presets/industry/failure_case_graph.yaml b/hyperextract/templates/presets/industry/failure_case_graph.yaml
index 07625b0..ed07afc 100644
--- a/hyperextract/templates/presets/industry/failure_case_graph.yaml
+++ b/hyperextract/templates/presets/industry/failure_case_graph.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备故障分析专家,请从文本中提取故障现象、原因、处理措施和经验教训。
diff --git a/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml b/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml
index e56b5b4..6f82a0a 100644
--- a/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml
+++ b/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml
@@ -49,7 +49,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位设备故障诊断专家,请从故障案例中提取故障知识实体和故障诊断推理作为超边。
diff --git a/hyperextract/templates/presets/industry/incident_causality_map.yaml b/hyperextract/templates/presets/industry/incident_causality_map.yaml
index ca60b09..99c199a 100644
--- a/hyperextract/templates/presets/industry/incident_causality_map.yaml
+++ b/hyperextract/templates/presets/industry/incident_causality_map.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业安全事故调查专家,请从事故调查报告中提取实体和事故因果链条作为超边。
diff --git a/hyperextract/templates/presets/industry/inspection_record_graph.yaml b/hyperextract/templates/presets/industry/inspection_record_graph.yaml
index 9b162d7..c33501e 100644
--- a/hyperextract/templates/presets/industry/inspection_record_graph.yaml
+++ b/hyperextract/templates/presets/industry/inspection_record_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备巡检分析专家,请从文本中提取设备和巡检项,构建巡检层级结构。
diff --git a/hyperextract/templates/presets/industry/maintenace_operation_map.yaml b/hyperextract/templates/presets/industry/maintenace_operation_map.yaml
index e3a87bb..5a3b523 100644
--- a/hyperextract/templates/presets/industry/maintenace_operation_map.yaml
+++ b/hyperextract/templates/presets/industry/maintenace_operation_map.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位设备维修管理专家,请从维修作业指导书中提取实体和维修作业中的复杂关联作为超边。
diff --git a/hyperextract/templates/presets/industry/operating_mode_graph.yaml b/hyperextract/templates/presets/industry/operating_mode_graph.yaml
index 027abbb..cd7cd21 100644
--- a/hyperextract/templates/presets/industry/operating_mode_graph.yaml
+++ b/hyperextract/templates/presets/industry/operating_mode_graph.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备工况分析专家,请从文本中提取工况和条件实体,以及它们之间的关系。
diff --git a/hyperextract/templates/presets/industry/operation_flow_graph.yaml b/hyperextract/templates/presets/industry/operation_flow_graph.yaml
index a2e9aea..6542167 100644
--- a/hyperextract/templates/presets/industry/operation_flow_graph.yaml
+++ b/hyperextract/templates/presets/industry/operation_flow_graph.yaml
@@ -73,7 +73,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业操作流程分析专家,请从文本中提取操作步骤、设备状态和预期结果。
diff --git a/hyperextract/templates/presets/industry/part_replacement_list.yaml b/hyperextract/templates/presets/industry/part_replacement_list.yaml
index c016fb0..5177522 100644
--- a/hyperextract/templates/presets/industry/part_replacement_list.yaml
+++ b/hyperextract/templates/presets/industry/part_replacement_list.yaml
@@ -52,7 +52,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位设备维护管理专家,请从备件更换记录中提取所有备件消耗条目。
diff --git a/hyperextract/templates/presets/industry/safety_control_graph.yaml b/hyperextract/templates/presets/industry/safety_control_graph.yaml
index 0bfcffb..07ec21d 100644
--- a/hyperextract/templates/presets/industry/safety_control_graph.yaml
+++ b/hyperextract/templates/presets/industry/safety_control_graph.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业安全管理分析专家,请从文本中提取危险源、风险点和管控措施,构建安全管控关系。
diff --git a/hyperextract/templates/presets/industry/safety_timeline.yaml b/hyperextract/templates/presets/industry/safety_timeline.yaml
index 01f592e..754e79c 100644
--- a/hyperextract/templates/presets/industry/safety_timeline.yaml
+++ b/hyperextract/templates/presets/industry/safety_timeline.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业安全事故调查专家,请从事故调查报告中提取时间线,还原事故发生前后的操作与响应序列。
diff --git a/hyperextract/templates/presets/industry/spec_parameter_table.yaml b/hyperextract/templates/presets/industry/spec_parameter_table.yaml
index 2960b4f..f414c4a 100644
--- a/hyperextract/templates/presets/industry/spec_parameter_table.yaml
+++ b/hyperextract/templates/presets/industry/spec_parameter_table.yaml
@@ -124,7 +124,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备技术专家,请从技术规格书中提取所有关键技术参数。
diff --git a/hyperextract/templates/presets/industry/system_compatibility_graph.yaml b/hyperextract/templates/presets/industry/system_compatibility_graph.yaml
index ca93685..2956f35 100644
--- a/hyperextract/templates/presets/industry/system_compatibility_graph.yaml
+++ b/hyperextract/templates/presets/industry/system_compatibility_graph.yaml
@@ -49,7 +49,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业设备选型专家,请从技术规格书中提取实体和设备与环境、介质的兼容性关系作为超边。
diff --git a/hyperextract/templates/presets/industry/system_topology_graph.yaml b/hyperextract/templates/presets/industry/system_topology_graph.yaml
index 10db873..60e12b9 100644
--- a/hyperextract/templates/presets/industry/system_topology_graph.yaml
+++ b/hyperextract/templates/presets/industry/system_topology_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位工业系统架构分析专家,请从文本中提取实体和它们之间的层级关系。
diff --git a/hyperextract/templates/presets/legal/adjudication_logic.yaml b/hyperextract/templates/presets/legal/adjudication_logic.yaml
index 84cebc0..200f48b 100644
--- a/hyperextract/templates/presets/legal/adjudication_logic.yaml
+++ b/hyperextract/templates/presets/legal/adjudication_logic.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的法律工作者,请从裁判文书中提取裁判要素和裁判逻辑。
diff --git a/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml b/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml
index cc744e0..78ad3a0 100644
--- a/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml
+++ b/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的反洗钱合规专员,请从文本中提取股权结构和受益所有权信息。
diff --git a/hyperextract/templates/presets/legal/case_fact_timeline.yaml b/hyperextract/templates/presets/legal/case_fact_timeline.yaml
index 7a900dd..7904ae1 100644
--- a/hyperextract/templates/presets/legal/case_fact_timeline.yaml
+++ b/hyperextract/templates/presets/legal/case_fact_timeline.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的法律工作者,请从文本中提取案件相关的法律实体以及它们之间的法律行为。
diff --git a/hyperextract/templates/presets/legal/case_law_citation_net.yaml b/hyperextract/templates/presets/legal/case_law_citation_net.yaml
index 01a509a..7d5abc7 100644
--- a/hyperextract/templates/presets/legal/case_law_citation_net.yaml
+++ b/hyperextract/templates/presets/legal/case_law_citation_net.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的法学专家,请从文本中提取所有判例以及它们之间的引用或关联关系。
diff --git a/hyperextract/templates/presets/legal/compliance_requirement_list.yaml b/hyperextract/templates/presets/legal/compliance_requirement_list.yaml
index 514feda..d56cc99 100644
--- a/hyperextract/templates/presets/legal/compliance_requirement_list.yaml
+++ b/hyperextract/templates/presets/legal/compliance_requirement_list.yaml
@@ -52,7 +52,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合规顾问,请从法规或政策文件中提取所有合规义务。
diff --git a/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml b/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml
index 6e43be3..bb82a24 100644
--- a/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml
+++ b/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合同法律师,请从文本中提取合同要素和合同义务。
diff --git a/hyperextract/templates/presets/legal/defined_term_registry.yaml b/hyperextract/templates/presets/legal/defined_term_registry.yaml
index 6582027..edc6f74 100644
--- a/hyperextract/templates/presets/legal/defined_term_registry.yaml
+++ b/hyperextract/templates/presets/legal/defined_term_registry.yaml
@@ -28,7 +28,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合同法律师,请从文本中提取所有定义的术语,形成术语定义表。
diff --git a/hyperextract/templates/presets/legal/legal_concept_ontology.yaml b/hyperextract/templates/presets/legal/legal_concept_ontology.yaml
index 5c90e4f..81d9f5b 100644
--- a/hyperextract/templates/presets/legal/legal_concept_ontology.yaml
+++ b/hyperextract/templates/presets/legal/legal_concept_ontology.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的法学专家,请从文本中提取所有法律概念以及它们之间的关系。
diff --git a/hyperextract/templates/presets/legal/liability_clause_list.yaml b/hyperextract/templates/presets/legal/liability_clause_list.yaml
index 04fca90..43dc106 100644
--- a/hyperextract/templates/presets/legal/liability_clause_list.yaml
+++ b/hyperextract/templates/presets/legal/liability_clause_list.yaml
@@ -40,7 +40,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的合同法律师,请从文本中提取所有关于责任、赔偿、保证的条款。
diff --git a/hyperextract/templates/presets/legal/litigation_participant_map.yaml b/hyperextract/templates/presets/legal/litigation_participant_map.yaml
index f93b240..1562c4a 100644
--- a/hyperextract/templates/presets/legal/litigation_participant_map.yaml
+++ b/hyperextract/templates/presets/legal/litigation_participant_map.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的法律文书分析师,请从文本中提取诉讼参与人及其之间的关系。
diff --git a/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml b/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml
index a2b6655..1fef34b 100644
--- a/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml
+++ b/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml
@@ -27,7 +27,7 @@ item_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的临床药师,请从文本中提取各系统的不良反应表现及其发生率描述,构建不良反应统计。
diff --git a/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml b/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml
index 37725d8..c105ce6 100644
--- a/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml
+++ b/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的解剖学家,请从文本中提取解剖结构及其关系,构建解剖层级树。
diff --git a/hyperextract/templates/presets/medicine/clinical_pathway.yaml b/hyperextract/templates/presets/medicine/clinical_pathway.yaml
index 9e8aba4..45f4e3e 100644
--- a/hyperextract/templates/presets/medicine/clinical_pathway.yaml
+++ b/hyperextract/templates/presets/medicine/clinical_pathway.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的临床医生,请从文本中提取"如果症状A则检查B否则治疗C"的决策树结构,构建临床路径图。
diff --git a/hyperextract/templates/presets/medicine/complex_interaction_net.yaml b/hyperextract/templates/presets/medicine/complex_interaction_net.yaml
index db0c387..88bd7b3 100644
--- a/hyperextract/templates/presets/medicine/complex_interaction_net.yaml
+++ b/hyperextract/templates/presets/medicine/complex_interaction_net.yaml
@@ -42,7 +42,7 @@ edge_schema:
description:
zh: "详细描述,如具体的相互作用机制"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的临床药师,请从文本中提取药物相互作用信息,构建条件性相互作用网。
diff --git a/hyperextract/templates/presets/medicine/contraindication_list.yaml b/hyperextract/templates/presets/medicine/contraindication_list.yaml
index 5186319..6ba0c83 100644
--- a/hyperextract/templates/presets/medicine/contraindication_list.yaml
+++ b/hyperextract/templates/presets/medicine/contraindication_list.yaml
@@ -23,7 +23,7 @@ item_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的临床药师,请从文本中提取绝对禁忌(如孕妇、严重肾衰竭等)的明确列表,构建禁忌症清单。
diff --git a/hyperextract/templates/presets/medicine/discharge_instruction.yaml b/hyperextract/templates/presets/medicine/discharge_instruction.yaml
index 933ef74..dcbe79d 100644
--- a/hyperextract/templates/presets/medicine/discharge_instruction.yaml
+++ b/hyperextract/templates/presets/medicine/discharge_instruction.yaml
@@ -40,7 +40,7 @@ schema:
zh: "其他注意事项列表"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的医生,请从文本中提取出院带药、复诊计划及康复建议的结构化信息,构建出院医嘱摘要。
diff --git a/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml b/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml
index 9b331c0..711869b 100644
--- a/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml
+++ b/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml
@@ -47,7 +47,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的医院管理人员,请从文本中严格按时间顺序提取入院、检查、治疗、转归等节点,构建住院病程时间轴。
diff --git a/hyperextract/templates/presets/medicine/level_of_evidence.yaml b/hyperextract/templates/presets/medicine/level_of_evidence.yaml
index e41b060..fd014e4 100644
--- a/hyperextract/templates/presets/medicine/level_of_evidence.yaml
+++ b/hyperextract/templates/presets/medicine/level_of_evidence.yaml
@@ -35,7 +35,7 @@ item_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的循证医学专家,请从文本中提取指南中的具体推荐意见及其对应的证据等级,构建证据评级表。
diff --git a/hyperextract/templates/presets/medicine/medical_concept_net.yaml b/hyperextract/templates/presets/medicine/medical_concept_net.yaml
index dadb649..d58ed57 100644
--- a/hyperextract/templates/presets/medicine/medical_concept_net.yaml
+++ b/hyperextract/templates/presets/medicine/medical_concept_net.yaml
@@ -43,7 +43,7 @@ edge_schema:
zh: "详细描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的医学术语专家,请从文本中提取医学术语及其关联属性,构建医学概念网络。
diff --git a/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml b/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml
index e160e77..d0147e4 100644
--- a/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml
+++ b/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml
@@ -27,7 +27,7 @@ item_schema:
zh: "特征描述"
required: false
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的病理学家,请从文本中提取免疫组化指标(如 HER2+, Ki67)及基因突变状态,构建微观特征集。
diff --git a/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml b/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml
index 154d101..44d1940 100644
--- a/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml
+++ b/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml
@@ -46,7 +46,7 @@ edge_schema:
description:
zh: "该机制导致的结果或效应"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的病理学家,请从文本中提取与疾病病理机制相关的实体和它们之间的复杂关联关系,构建多因素病理机制图。
diff --git a/hyperextract/templates/presets/medicine/pharmacology_graph.yaml b/hyperextract/templates/presets/medicine/pharmacology_graph.yaml
index 0d3f50f..fa6c406 100644
--- a/hyperextract/templates/presets/medicine/pharmacology_graph.yaml
+++ b/hyperextract/templates/presets/medicine/pharmacology_graph.yaml
@@ -42,7 +42,7 @@ edge_schema:
description:
zh: "详细描述,如具体的作用机制"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的药理学家,请从文本中提取药物、受体、靶点及生理反应之间的相互作用路径,构建药理机制图。
diff --git a/hyperextract/templates/presets/medicine/surgical_event_graph.yaml b/hyperextract/templates/presets/medicine/surgical_event_graph.yaml
index 2c56f68..8a2a443 100644
--- a/hyperextract/templates/presets/medicine/surgical_event_graph.yaml
+++ b/hyperextract/templates/presets/medicine/surgical_event_graph.yaml
@@ -47,7 +47,7 @@ edge_schema:
description:
zh: "详细描述,如手术过程"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的外科医生,请从文本中提取手术事件及其相关实体,构建手术事件超图。
diff --git a/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml b/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml
index 46d1226..371c525 100644
--- a/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml
+++ b/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml
@@ -42,7 +42,7 @@ edge_schema:
description:
zh: "详细描述,如具体的治疗方案内容"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的临床医生,请从文本中提取由"药物组合+理疗+生活干预"构成的多因素治疗方案,构建综合治疗方案图。
diff --git a/hyperextract/templates/presets/medicine/tumor_staging_item.yaml b/hyperextract/templates/presets/medicine/tumor_staging_item.yaml
index 2a87c2b..0ff347f 100644
--- a/hyperextract/templates/presets/medicine/tumor_staging_item.yaml
+++ b/hyperextract/templates/presets/medicine/tumor_staging_item.yaml
@@ -38,7 +38,7 @@ schema:
description:
zh: "M分期详细描述,如远处转移部位"
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的病理学家,请从文本中提取肿瘤大小(T)、淋巴结(N)、转移(M)及分期结果,构建TNM分期表。
diff --git a/hyperextract/templates/presets/tcm/acupoint_location_map.yaml b/hyperextract/templates/presets/tcm/acupoint_location_map.yaml
index acbea2f..604b14a 100644
--- a/hyperextract/templates/presets/tcm/acupoint_location_map.yaml
+++ b/hyperextract/templates/presets/tcm/acupoint_location_map.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的针灸学专家,请从文本中提取穴位的相对位置关系。
diff --git a/hyperextract/templates/presets/tcm/compatibility_net.yaml b/hyperextract/templates/presets/tcm/compatibility_net.yaml
index 326578a..a45734e 100644
--- a/hyperextract/templates/presets/tcm/compatibility_net.yaml
+++ b/hyperextract/templates/presets/tcm/compatibility_net.yaml
@@ -49,7 +49,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中药配伍专家,请从文本中提取药物间的配伍关系。
diff --git a/hyperextract/templates/presets/tcm/formula_composition.yaml b/hyperextract/templates/presets/tcm/formula_composition.yaml
index f5dc307..b9232c8 100644
--- a/hyperextract/templates/presets/tcm/formula_composition.yaml
+++ b/hyperextract/templates/presets/tcm/formula_composition.yaml
@@ -91,7 +91,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的方剂学专家,请从文本中提取方剂的君臣佐使结构。
diff --git a/hyperextract/templates/presets/tcm/function_indication_map.yaml b/hyperextract/templates/presets/tcm/function_indication_map.yaml
index 0ae54ec..403af2b 100644
--- a/hyperextract/templates/presets/tcm/function_indication_map.yaml
+++ b/hyperextract/templates/presets/tcm/function_indication_map.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的方剂学专家,请从文本中提取方剂、功能和主治证候之间的关联关系。
diff --git a/hyperextract/templates/presets/tcm/herb_property_model.yaml b/hyperextract/templates/presets/tcm/herb_property_model.yaml
index 4b0b902..b90ee65 100644
--- a/hyperextract/templates/presets/tcm/herb_property_model.yaml
+++ b/hyperextract/templates/presets/tcm/herb_property_model.yaml
@@ -76,7 +76,7 @@ schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中药学家,请从文本中提取单味药的性味归经、毒性及推荐剂量等信息。
diff --git a/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml b/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml
index 5b51d8d..a13101b 100644
--- a/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml
+++ b/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml
@@ -67,7 +67,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的经络学专家,请从文本中提取十二经脉的循行路线及经气流注次序。
diff --git a/hyperextract/templates/presets/tcm/prescription_modification.yaml b/hyperextract/templates/presets/tcm/prescription_modification.yaml
index 00d678d..71ea76d 100644
--- a/hyperextract/templates/presets/tcm/prescription_modification.yaml
+++ b/hyperextract/templates/presets/tcm/prescription_modification.yaml
@@ -61,7 +61,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中医方剂专家,请从文本中提取处方加减的实体和超边结构。
diff --git a/hyperextract/templates/presets/tcm/processing_method.yaml b/hyperextract/templates/presets/tcm/processing_method.yaml
index 7c40d47..5764c11 100644
--- a/hyperextract/templates/presets/tcm/processing_method.yaml
+++ b/hyperextract/templates/presets/tcm/processing_method.yaml
@@ -40,7 +40,7 @@ item_schema:
required: true
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中药炮制专家,请从文本中提取药物的不同炮制方法及其对药效的影响。
diff --git a/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml b/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml
index 0b0d033..0357b92 100644
--- a/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml
+++ b/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml
@@ -46,7 +46,7 @@ item_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中医诊断专家,请从文本中提取舌象和脉象的特征信息。
diff --git a/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml b/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml
index 3133bad..50e8572 100644
--- a/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml
+++ b/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml
@@ -55,7 +55,7 @@ edge_schema:
required: false
default: ""
-extraction_guide:
+guide:
target:
zh: |
你是一位专业的中医辨证论治专家,请从文本中提取中医实体和辨证论治推理逻辑作为超边。
diff --git "a/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md" "b/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md"
index f6404ec..dc83373 100644
--- "a/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md"
+++ "b/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md"
@@ -45,7 +45,7 @@ YAML(YAML Ain't Markup Language)是一种人类可读的数据序列化格
┌─────────────────────────────────────────────────────────────┐
│ YAML 配置文件 │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────────┐ │
-│ │ name │ │ autotype│ │ schema │ │ extraction_guide│ │
+│ │ name │ │ autotype│ │ schema │ │ guide│ │
│ │ tag │ │ language│ │ ... │ │ identifiers │ │
│ │ ... │ │ │ │ │ │ display │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────────────┘ │
@@ -128,7 +128,7 @@ schema:
type: string
description: "字段描述"
-extraction_guide:
+guide:
target: "你是一位专家,请从文本中提取信息。"
rules: |
@@ -171,7 +171,7 @@ edge_schema:
type: string
description: "关系类型"
-extraction_guide:
+guide:
target: "你是一位领域专家,请从文本中提取知识图谱关系。"
rules_for_nodes: |
@@ -218,14 +218,14 @@ display:
| 字段 | 说明 |
|------|------|
| `schema` / `item_schema` / `node_schema` / `edge_schema` | 数据结构定义 |
-| `extraction_guide` | 提取指南 |
+| `guide` | 提取指南 |
| `identifiers` | 标识配置 |
| `parameters` | 运行时参数 |
| `display` | 展示配置 |
### 3.3 Rules 字段格式说明
-`extraction_guide` 中的 `rules`、`rules_for_nodes`、`rules_for_edges`、`rules_for_time`、`rules_for_location` 等字段使用 List 格式:
+`guide` 中的 `rules`、`rules_for_nodes`、`rules_for_edges`、`rules_for_time`、`rules_for_location` 等字段使用 List 格式:
```yaml
rules:
@@ -328,9 +328,9 @@ schema:
default: "N/A"
```
-**extraction_guide 编写**:
+**guide 编写**:
```yaml
-extraction_guide:
+guide:
target: "你是一位财务分析师,请从财报中提取关键信息。"
rules:
@@ -363,7 +363,7 @@ schema:
type: string
description: "营收金额"
-extraction_guide:
+guide:
target: "你是一位财务分析师,请从财报中提取关键信息。"
rules:
@@ -411,7 +411,7 @@ item_schema:
type: string
description: "关键词"
-extraction_guide:
+guide:
target: "你是一位关键词提取专家"
rules:
@@ -451,7 +451,7 @@ item_schema:
type: string
description: "实体类型"
-extraction_guide:
+guide:
target: "你是一位实体识别专家"
rules:
@@ -505,9 +505,9 @@ identifiers:
target: target
```
-**extraction_guide 编写**:
+**guide 编写**:
```yaml
-extraction_guide:
+guide:
target: "你是一位知识图谱专家,请从文本中提取实体关系。"
rules_for_nodes:
@@ -577,9 +577,9 @@ identifiers:
time_field: "fiscal_period"
```
-**特有 extraction_guide 编写**:
+**特有 guide 编写**:
```yaml
-extraction_guide:
+guide:
rules_for_time:
- "当前观察日期:{observation_time}"
- "'去年' → {observation_time} 的前一年"
@@ -602,9 +602,9 @@ identifiers:
location_field: "location"
```
-**特有 extraction_guide 编写**:
+**特有 guide 编写**:
```yaml
-extraction_guide:
+guide:
rules_for_location:
- "当前观察位置:{observation_location}"
- "'这里' → {observation_location}"
diff --git a/hyperextract/utils/__init__.py b/hyperextract/utils/__init__.py
index 5407d0f..cd61787 100644
--- a/hyperextract/utils/__init__.py
+++ b/hyperextract/utils/__init__.py
@@ -1,8 +1,12 @@
"""Hyperextract utilities module."""
from .logging import logger, setup_logger
+from .client import get_client
+from .template_engine import Template
__all__ = [
"logger",
"setup_logger",
+ "get_client",
+ "Template",
]
diff --git a/hyperextract/utils/client.py b/hyperextract/utils/client.py
new file mode 100644
index 0000000..0599a2d
--- /dev/null
+++ b/hyperextract/utils/client.py
@@ -0,0 +1,129 @@
+"""Client Factory - Create LLM and Embedder clients from config file."""
+
+import os
+from pathlib import Path
+from typing import Optional, Tuple, Union
+
+from langchain_core.embeddings import Embeddings
+from langchain_core.language_models.chat_models import BaseChatModel
+
+DEFAULT_CONFIG_DIR = Path.home() / ".he"
+DEFAULT_CONFIG_FILE = DEFAULT_CONFIG_DIR / "config.toml"
+
+
+def get_client(config_path: Optional[Union[str, Path]] = None) -> Tuple:
+ """Get LLM client and Embedder from config file.
+
+ Args:
+ config_path: Config file path, default ~/.he/config.toml
+
+ Returns:
+ (llm_client, embedder) tuple
+
+ Examples:
+ >>> from hyperextract.utils import get_client
+ >>> llm, emb = get_client()
+ >>> # Or with custom config path
+ >>> llm, emb = get_client("/path/to/config.toml")
+ """
+ from hyperextract.cli.config import ConfigManager
+
+ path = Path(config_path) if config_path else DEFAULT_CONFIG_FILE
+ manager = ConfigManager(path)
+
+ llm_config = manager.get_llm_config()
+ emb_config = manager.get_embedder_config()
+
+ llm_client = _create_llm_client(llm_config)
+ embedder = _create_embedder(emb_config)
+
+ return llm_client, embedder
+
+
+def _create_llm_client(config) -> "BaseChatModel":
+ """Create LLM client from config."""
+ if config.provider == "openai":
+ from langchain_openai import ChatOpenAI
+
+ return ChatOpenAI(
+ model=config.model,
+ api_key=config.api_key or os.environ.get("OPENAI_API_KEY", ""),
+ base_url=config.base_url or None,
+ temperature=0,
+ )
+ elif config.provider == "anthropic":
+ try:
+ from langchain_anthropic import ChatAnthropic
+ except ImportError:
+ raise ImportError(
+ "Anthropic support requires the 'langchain-anthropic' package.\n"
+ "Install it with one of:\n"
+ " pip install hyperextract[anthropic]\n"
+ " pip install langchain-anthropic"
+ )
+
+ return ChatAnthropic(
+ model=config.model,
+ api_key=config.api_key or os.environ.get("ANTHROPIC_API_KEY", ""),
+ )
+ elif config.provider == "google":
+ try:
+ from langchain_google_genai import ChatGoogleGenerativeAI
+ except ImportError:
+ raise ImportError(
+ "Google support requires the 'langchain-google-genai' package.\n"
+ "Install it with one of:\n"
+ " pip install hyperextract[google]\n"
+ " pip install langchain-google-genai"
+ )
+
+ return ChatGoogleGenerativeAI(
+ model=config.model,
+ google_api_key=config.api_key or os.environ.get("GOOGLE_API_KEY", ""),
+ )
+ else:
+ raise ValueError(f"Unsupported LLM provider: {config.provider}")
+
+
+def _create_embedder(config) -> "Embeddings":
+ """Create Embedder from config."""
+ if config.provider == "openai":
+ from langchain_openai import OpenAIEmbeddings
+
+ return OpenAIEmbeddings(
+ model=config.model,
+ api_key=config.api_key or os.environ.get("OPENAI_API_KEY", ""),
+ base_url=config.base_url or None,
+ )
+ elif config.provider == "anthropic":
+ try:
+ from langchain_anthropic import AnthropicEmbeddings
+ except ImportError:
+ raise ImportError(
+ "Anthropic support requires the 'langchain-anthropic' package.\n"
+ "Install it with one of:\n"
+ " pip install hyperextract[anthropic]\n"
+ " pip install langchain-anthropic"
+ )
+
+ return AnthropicEmbeddings(
+ model=config.model,
+ api_key=config.api_key or os.environ.get("ANTHROPIC_API_KEY", ""),
+ )
+ elif config.provider == "google":
+ try:
+ from langchain_google_genai import GoogleGenerativeAIEmbeddings
+ except ImportError:
+ raise ImportError(
+ "Google support requires the 'langchain-google-genai' package.\n"
+ "Install it with one of:\n"
+ " pip install hyperextract[google]\n"
+ " pip install langchain-google-genai"
+ )
+
+ return GoogleGenerativeAIEmbeddings(
+ model=config.model,
+ google_api_key=config.api_key or os.environ.get("GOOGLE_API_KEY", ""),
+ )
+ else:
+ raise ValueError(f"Unsupported Embedder provider: {config.provider}")
diff --git a/hyperextract/utils/template_engine/__init__.py b/hyperextract/utils/template_engine/__init__.py
index 09c0942..2c86c38 100644
--- a/hyperextract/utils/template_engine/__init__.py
+++ b/hyperextract/utils/template_engine/__init__.py
@@ -2,54 +2,36 @@
This module provides functionality to dynamically generate HyperExtract templates from YAML configuration files.
-Usage Examples:
- >>> from hyperextract.utils.template_engine import Gallery, TemplateFactory
- >>>
- >>> # Get template (auto-loaded presets and customs)
- >>> config = Gallery.get("KnowledgeGraph")
- >>> template = TemplateFactory.create(config, llm_client, embedder)
- >>>
- >>> # List all templates
- >>> print(Gallery.list_all())
- >>>
- >>> # Add custom template directory (auto-loaded)
- >>> Gallery.add_path("/path/to/my/templates")
+Usage:
+ # Recommended: use Template class
+ from hyperextract.utils import Template
+
+ Template.list()
+ Template.search("知识图谱")
+ template = Template.create("knowledge_graph")
+
+ # Advanced: use Gallery and Factory directly
+ from hyperextract.utils.template_engine import Gallery, TemplateFactory
"""
-from .config_loader import (
+from .template import Template
+from .gallery import Gallery
+from .factory import TemplateFactory
+from .builder import (
TemplateConfig,
ConfigLoader,
- FieldDescription,
- SchemaField,
- ExtractionGuide,
- Identifiers,
- Parameters,
- Display,
+ SchemaBuilder,
+ PromptBuilder,
+ IdentifierResolver,
)
-from .schema_builder import SchemaBuilder
-
-from .identifier_resolver import IdentifierResolver
-
-from .prompt_builder import PromptBuilder
-
-from .template_factory import TemplateFactory
-
-from .template_gallery import Gallery
-
-
__all__ = [
+ "Template",
+ "Gallery",
+ "TemplateFactory",
"TemplateConfig",
"ConfigLoader",
- "FieldDescription",
- "SchemaField",
- "ExtractionGuide",
- "Identifiers",
- "Parameters",
- "Display",
"SchemaBuilder",
- "IdentifierResolver",
"PromptBuilder",
- "TemplateFactory",
- "Gallery",
+ "IdentifierResolver",
]
diff --git a/hyperextract/utils/template_engine/builder/__init__.py b/hyperextract/utils/template_engine/builder/__init__.py
new file mode 100644
index 0000000..97ca9de
--- /dev/null
+++ b/hyperextract/utils/template_engine/builder/__init__.py
@@ -0,0 +1,36 @@
+"""Builder module - Configuration models, loaders and builders."""
+
+from .loader import TemplateConfig, ConfigLoader, Parameters, Display
+from .schema import (
+ FieldDescription,
+ SchemaField,
+ BaseSchema,
+ ModelSchema,
+ ItemSchema,
+ NodeSchema,
+ EdgeSchema,
+ SchemaBuilder,
+)
+from .extraction import GuideTarget, Guide, PromptBuilder
+from .identifiers import Identifiers, IdentifierResolver
+
+
+__all__ = [
+ "TemplateConfig",
+ "ConfigLoader",
+ "Parameters",
+ "Display",
+ "FieldDescription",
+ "SchemaField",
+ "BaseSchema",
+ "ModelSchema",
+ "ItemSchema",
+ "NodeSchema",
+ "EdgeSchema",
+ "SchemaBuilder",
+ "GuideTarget",
+ "Guide",
+ "PromptBuilder",
+ "Identifiers",
+ "IdentifierResolver",
+]
diff --git a/hyperextract/utils/template_engine/prompt_builder.py b/hyperextract/utils/template_engine/builder/extraction.py
similarity index 58%
rename from hyperextract/utils/template_engine/prompt_builder.py
rename to hyperextract/utils/template_engine/builder/extraction.py
index fbcfb86..d5c0ca0 100644
--- a/hyperextract/utils/template_engine/prompt_builder.py
+++ b/hyperextract/utils/template_engine/builder/extraction.py
@@ -1,10 +1,55 @@
-"""Prompt Builder - Builds extraction prompts for various AutoType.
-
-Supports extraction_guide target field, automatically adds titles to rules.
-"""
+"""Extraction models and prompt builder."""
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
-from .config_loader import ExtractionGuide
+from pydantic import BaseModel
+
+
+class GuideTarget(BaseModel):
+ """Extraction target with role definition and content description."""
+
+ zh: Optional[str] = None
+ en: Optional[str] = None
+
+ @classmethod
+ def from_value(cls, value: Union[str, Dict[str, str], None]) -> Optional["GuideTarget"]:
+ """Create instance from string or dict."""
+ if value is None:
+ return None
+ if isinstance(value, str):
+ return cls(zh=value)
+ if isinstance(value, dict):
+ return cls(**value)
+ return None
+
+ def get(self, language: str = "zh") -> str:
+ """Get content for specified language."""
+ return getattr(self, language) or self.zh or ""
+
+
+class Guide(BaseModel):
+ """Guide configuration."""
+
+ target: Optional[Union[str, List[str], Dict[str, Union[str, List[str]]]]] = None
+ rules: Optional[Union[List[str], Dict[str, List[str]]]] = None
+ rules_for_nodes: Optional[Union[List[str], Dict[str, List[str]]]] = None
+ rules_for_edges: Optional[Union[List[str], Dict[str, List[str]]]] = None
+ rules_for_time: Optional[Union[List[str], Dict[str, List[str]]]] = None
+ rules_for_location: Optional[Union[List[str], Dict[str, List[str]]]] = None
+
+ def get_field(self, field_name: str, language: str = "zh") -> Optional[str]:
+ """Get specified field content for specified language."""
+ value = getattr(self, field_name, None)
+ if value is None:
+ return None
+ if isinstance(value, list):
+ return "\n".join(f"{i+1}. {item}" for i, item in enumerate(value))
+ if isinstance(value, dict):
+ dict_value = value.get(language) or value.get("zh")
+ if dict_value is None:
+ return None
+ if isinstance(dict_value, list):
+ return "\n".join(f"{i+1}. {item}" for i, item in enumerate(dict_value))
+ return None
LABEL_MAPPING = {
@@ -32,7 +77,7 @@ LABEL_MAPPING = {
class PromptBuilder:
- """Prompt Builder."""
+ """Prompt Builder - Builds extraction prompts for various AutoType."""
def __init__(self, language: str = "zh"):
"""Initialize Prompt Builder."""
@@ -59,57 +104,57 @@ class PromptBuilder:
title = self.labels.get(title_key, title_key)
return f"### {title}\n{text}"
- def build_target(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_target(self, guide: Guide) -> Optional[str]:
"""Build target field (role definition + extraction content description)."""
- target = extraction_guide.target
+ target = guide.target
if target is None:
return None
return self._get_text(target, self.language)
- def build_rules(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_rules(self, guide: Guide) -> Optional[str]:
"""Build rules field (with title)."""
- rules = self._get_text(extraction_guide.rules, self.language)
+ rules = self._get_text(guide.rules, self.language)
if rules:
return self._add_title(rules, "extraction_rules")
return None
- def build_rules_for_nodes(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_rules_for_nodes(self, guide: Guide) -> Optional[str]:
"""Build rules_for_nodes field (with title)."""
- rules = self._get_text(extraction_guide.rules_for_nodes, self.language)
+ rules = self._get_text(guide.rules_for_nodes, self.language)
if rules:
return self._add_title(rules, "node_extraction_rules")
return None
- def build_rules_for_edges(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_rules_for_edges(self, guide: Guide) -> Optional[str]:
"""Build rules_for_edges field (with title)."""
- rules = self._get_text(extraction_guide.rules_for_edges, self.language)
+ rules = self._get_text(guide.rules_for_edges, self.language)
if rules:
return self._add_title(rules, "edge_extraction_rules")
return None
- def build_rules_for_time(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_rules_for_time(self, guide: Guide) -> Optional[str]:
"""Build rules_for_time field (with title)."""
- rules = self._get_text(extraction_guide.rules_for_time, self.language)
+ rules = self._get_text(guide.rules_for_time, self.language)
if rules:
return self._add_title(rules, "time_rules")
return None
- def build_rules_for_location(self, extraction_guide: ExtractionGuide) -> Optional[str]:
+ def build_rules_for_location(self, guide: Guide) -> Optional[str]:
"""Build rules_for_location field (with title)."""
- rules = self._get_text(extraction_guide.rules_for_location, self.language)
+ rules = self._get_text(guide.rules_for_location, self.language)
if rules:
return self._add_title(rules, "location_rules")
return None
- def build_model_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_model_prompt(self, guide: Guide) -> str:
"""Build Model/List/Set type Prompt."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules = self.build_rules(extraction_guide)
+ rules = self.build_rules(guide)
if rules:
parts.append(rules)
@@ -118,19 +163,19 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_graph_main_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_graph_main_prompt(self, guide: Guide) -> str:
"""Build Graph type main Prompt (single-stage mode)."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_nodes = self.build_rules_for_nodes(extraction_guide)
+ rules_for_nodes = self.build_rules_for_nodes(guide)
if rules_for_nodes:
parts.append(rules_for_nodes)
- rules_for_edges = self.build_rules_for_edges(extraction_guide)
+ rules_for_edges = self.build_rules_for_edges(guide)
if rules_for_edges:
parts.append(rules_for_edges)
@@ -139,15 +184,15 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_graph_node_prompt(self, guide: Guide) -> str:
"""Build Graph type node extraction Prompt (two-stage mode)."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_nodes = self.build_rules_for_nodes(extraction_guide)
+ rules_for_nodes = self.build_rules_for_nodes(guide)
if rules_for_nodes:
parts.append(rules_for_nodes)
@@ -156,15 +201,15 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_graph_edge_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_graph_edge_prompt(self, guide: Guide) -> str:
"""Build Graph type edge extraction Prompt (two-stage mode)."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_edges = self.build_rules_for_edges(extraction_guide)
+ rules_for_edges = self.build_rules_for_edges(guide)
if rules_for_edges:
parts.append(rules_for_edges)
@@ -176,19 +221,19 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_temporal_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_temporal_graph_node_prompt(self, guide: Guide) -> str:
"""Build TemporalGraph node extraction Prompt."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_nodes = self.build_rules_for_nodes(extraction_guide)
+ rules_for_nodes = self.build_rules_for_nodes(guide)
if rules_for_nodes:
parts.append(rules_for_nodes)
- rules_for_time = self.build_rules_for_time(extraction_guide)
+ rules_for_time = self.build_rules_for_time(guide)
if rules_for_time:
parts.append(rules_for_time)
@@ -197,19 +242,19 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_spatial_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_spatial_graph_node_prompt(self, guide: Guide) -> str:
"""Build SpatialGraph node extraction Prompt."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_nodes = self.build_rules_for_nodes(extraction_guide)
+ rules_for_nodes = self.build_rules_for_nodes(guide)
if rules_for_nodes:
parts.append(rules_for_nodes)
- rules_for_location = self.build_rules_for_location(extraction_guide)
+ rules_for_location = self.build_rules_for_location(guide)
if rules_for_location:
parts.append(rules_for_location)
@@ -218,23 +263,23 @@ class PromptBuilder:
return "\n\n".join(parts)
- def build_spatio_temporal_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:
+ def build_spatio_temporal_graph_node_prompt(self, guide: Guide) -> str:
"""Build SpatioTemporalGraph node extraction Prompt."""
parts = []
- target = self.build_target(extraction_guide)
+ target = self.build_target(guide)
if target:
parts.append(target)
- rules_for_nodes = self.build_rules_for_nodes(extraction_guide)
+ rules_for_nodes = self.build_rules_for_nodes(guide)
if rules_for_nodes:
parts.append(rules_for_nodes)
- rules_for_time = self.build_rules_for_time(extraction_guide)
+ rules_for_time = self.build_rules_for_time(guide)
if rules_for_time:
parts.append(rules_for_time)
- rules_for_location = self.build_rules_for_location(extraction_guide)
+ rules_for_location = self.build_rules_for_location(guide)
if rules_for_location:
parts.append(rules_for_location)
@@ -242,3 +287,10 @@ class PromptBuilder:
parts.append(f"## {source_label}:\n{{source_text}}")
return "\n\n".join(parts)
+
+
+__all__ = [
+ "GuideTarget",
+ "Guide",
+ "PromptBuilder",
+]
diff --git a/hyperextract/utils/template_engine/identifier_resolver.py b/hyperextract/utils/template_engine/builder/identifiers.py
similarity index 91%
rename from hyperextract/utils/template_engine/identifier_resolver.py
rename to hyperextract/utils/template_engine/builder/identifiers.py
index 4e39292..5677926 100644
--- a/hyperextract/utils/template_engine/identifier_resolver.py
+++ b/hyperextract/utils/template_engine/builder/identifiers.py
@@ -1,14 +1,22 @@
-"""Identifier Resolver - Generates extraction functions for nodes and edges.
-
-Converts identifier definitions in configuration to callable functions.
-"""
+"""Identifier models and resolver."""
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from pydantic import BaseModel
+class Identifiers(BaseModel):
+ """Identifier configuration."""
+
+ item_id: Optional[str] = None
+ node_id: Optional[str] = None
+ edge_id: Optional[str] = None
+ edge_members: Optional[Union[str, Dict[str, str], List[str]]] = None
+ time_field: Optional[str] = None
+ location_field: Optional[str] = None
+
+
class IdentifierResolver:
- """Identifier Resolver."""
+ """Identifier Resolver - Generates extraction functions for nodes and edges."""
@staticmethod
def resolve_item_id(field_name: str) -> Callable[[BaseModel], str]:
@@ -136,3 +144,9 @@ class IdentifierResolver:
result["location_in_edge_extractor"] = cls.resolve_location(identifiers_dict["location_field"])
return result
+
+
+__all__ = [
+ "Identifiers",
+ "IdentifierResolver",
+]
diff --git a/hyperextract/utils/template_engine/config_loader.py b/hyperextract/utils/template_engine/builder/loader.py
similarity index 54%
rename from hyperextract/utils/template_engine/config_loader.py
rename to hyperextract/utils/template_engine/builder/loader.py
index 2619870..c600bfc 100644
--- a/hyperextract/utils/template_engine/config_loader.py
+++ b/hyperextract/utils/template_engine/builder/loader.py
@@ -1,127 +1,13 @@
-"""Config Loader - Loads and validates YAML configuration files.
-
-Provides configuration schema definition, multilingual field parsing, and configuration validation.
-"""
+"""Config loader, parameters and display models."""
from typing import Any, Dict, List, Literal, Optional, Union
from pathlib import Path
from pydantic import BaseModel, Field, field_validator, ConfigDict
import yaml
-
-class FieldDescription(BaseModel):
- """Field description with multilingual support."""
-
- zh: Optional[str] = None
- en: Optional[str] = None
-
- def get(self, language: str = "zh") -> str:
- """Get description for specified language."""
- if isinstance(self, str):
- return self
- return getattr(self, language) or self.zh or ""
-
-
-class SchemaField(BaseModel):
- """Schema field definition."""
-
- name: str
- type: Literal["string", "int", "float", "bool", "array"]
- description: Optional[Union[str, Dict[str, str]]] = None
- required: bool = False
- default: Optional[Any] = None
- item_type: Optional[str] = None
-
- @field_validator("description", mode="before")
- @classmethod
- def parse_description(cls, v):
- """Parse description field, supports plain string or multilingual dict."""
- return v
-
-
-class BaseSchema(BaseModel):
- """Base schema configuration."""
-
- fields: List[SchemaField] = Field(default_factory=list)
-
-
-class ModelSchema(BaseSchema):
- """Model type schema."""
- pass
-
-
-class ItemSchema(BaseSchema):
- """List/Set type item schema."""
- pass
-
-
-class NodeSchema(BaseSchema):
- """Graph type node schema."""
- pass
-
-
-class EdgeSchema(BaseSchema):
- """Graph type edge schema."""
- pass
-
-
-class ExtractionGuideTarget(BaseModel):
- """Extraction target with role definition and content description."""
-
- zh: Optional[str] = None
- en: Optional[str] = None
-
- @classmethod
- def from_value(cls, value: Union[str, Dict[str, str], None]) -> Optional["ExtractionGuideTarget"]:
- """Create instance from string or dict."""
- if value is None:
- return None
- if isinstance(value, str):
- return cls(zh=value)
- if isinstance(value, dict):
- return cls(**value)
- return None
-
- def get(self, language: str = "zh") -> str:
- """Get content for specified language."""
- return getattr(self, language) or self.zh or ""
-
-
-class ExtractionGuide(BaseModel):
- """Extraction guide configuration."""
-
- target: Optional[Union[str, List[str], Dict[str, Union[str, List[str]]]]] = None
- rules: Optional[Union[List[str], Dict[str, List[str]]]] = None
- rules_for_nodes: Optional[Union[List[str], Dict[str, List[str]]]] = None
- rules_for_edges: Optional[Union[List[str], Dict[str, List[str]]]] = None
- rules_for_time: Optional[Union[List[str], Dict[str, List[str]]]] = None
- rules_for_location: Optional[Union[List[str], Dict[str, List[str]]]] = None
-
- def get_field(self, field_name: str, language: str = "zh") -> Optional[str]:
- """Get specified field content for specified language."""
- value = getattr(self, field_name, None)
- if value is None:
- return None
- if isinstance(value, list):
- return "\n".join(f"{i+1}. {item}" for i, item in enumerate(value))
- if isinstance(value, dict):
- dict_value = value.get(language) or value.get("zh")
- if dict_value is None:
- return None
- if isinstance(dict_value, list):
- return "\n".join(f"{i+1}. {item}" for i, item in enumerate(dict_value))
- return None
-
-
-class Identifiers(BaseModel):
- """Identifier configuration."""
-
- item_id: Optional[str] = None
- node_id: Optional[str] = None
- edge_id: Optional[str] = None
- edge_members: Optional[Union[str, Dict[str, str], List[str]]] = None
- time_field: Optional[str] = None
- location_field: Optional[str] = None
+from .schema import ModelSchema, ItemSchema, NodeSchema, EdgeSchema
+from .extraction import Guide
+from .identifiers import Identifiers
class Parameters(BaseModel):
@@ -183,7 +69,7 @@ class TemplateConfig(BaseModel):
item_schema: Optional[ItemSchema] = None
node_schema: Optional[NodeSchema] = None
edge_schema: Optional[EdgeSchema] = None
- extraction_guide: Optional[ExtractionGuide] = None
+ guide: Optional[Guide] = None
identifiers: Optional[Identifiers] = None
parameters: Optional[Parameters] = None
display: Optional[Display] = None
@@ -247,3 +133,11 @@ class ConfigLoader:
"temporal_graph", "spatial_graph", "spatio_temporal_graph"
}
return autotype in valid_types
+
+
+__all__ = [
+ "Parameters",
+ "Display",
+ "TemplateConfig",
+ "ConfigLoader",
+]
diff --git a/hyperextract/utils/template_engine/schema_builder.py b/hyperextract/utils/template_engine/builder/schema.py
similarity index 69%
rename from hyperextract/utils/template_engine/schema_builder.py
rename to hyperextract/utils/template_engine/builder/schema.py
index 4df0ec7..b4be810 100644
--- a/hyperextract/utils/template_engine/schema_builder.py
+++ b/hyperextract/utils/template_engine/builder/schema.py
@@ -1,19 +1,63 @@
-"""Schema Builder - Dynamically generates Pydantic Schema.
+"""Schema models and builder."""
-Converts Schema definitions in configuration files to Pydantic models.
-"""
+from typing import Any, Dict, List, Literal, Optional, Union, Type
+from pydantic import BaseModel, Field, field_validator, create_model
-from typing import Any, Dict, List, Optional, Type, Union, get_type_hints
-from pydantic import BaseModel, Field, create_model
-from pydantic.fields import FieldInfo
-from .config_loader import (
- SchemaField,
- ModelSchema,
- ItemSchema,
- NodeSchema,
- EdgeSchema,
-)
+class FieldDescription(BaseModel):
+ """Field description with multilingual support."""
+
+ zh: Optional[str] = None
+ en: Optional[str] = None
+
+ def get(self, language: str = "zh") -> str:
+ """Get description for specified language."""
+ if isinstance(self, str):
+ return self
+ return getattr(self, language) or self.zh or ""
+
+
+class SchemaField(BaseModel):
+ """Schema field definition."""
+
+ name: str
+ type: Literal["string", "int", "float", "bool", "array"]
+ description: Optional[Union[str, Dict[str, str]]] = None
+ required: bool = False
+ default: Optional[Any] = None
+ item_type: Optional[str] = None
+
+ @field_validator("description", mode="before")
+ @classmethod
+ def parse_description(cls, v):
+ """Parse description field, supports plain string or multilingual dict."""
+ return v
+
+
+class BaseSchema(BaseModel):
+ """Base schema configuration."""
+
+ fields: List[SchemaField] = Field(default_factory=list)
+
+
+class ModelSchema(BaseSchema):
+ """Model type schema."""
+ pass
+
+
+class ItemSchema(BaseSchema):
+ """List/Set type item schema."""
+ pass
+
+
+class NodeSchema(BaseSchema):
+ """Graph type node schema."""
+ pass
+
+
+class EdgeSchema(BaseSchema):
+ """Graph type edge schema."""
+ pass
TYPE_MAPPING = {
@@ -26,7 +70,7 @@ TYPE_MAPPING = {
class SchemaBuilder:
- """Schema Builder."""
+ """Schema Builder - Dynamically generates Pydantic Schema."""
@staticmethod
def build_field_type(field: SchemaField) -> Type:
@@ -126,3 +170,15 @@ class SchemaBuilder:
result["edge_schema"] = cls.build_edge_schema(config.edge_schema)
return result
+
+
+__all__ = [
+ "FieldDescription",
+ "SchemaField",
+ "BaseSchema",
+ "ModelSchema",
+ "ItemSchema",
+ "NodeSchema",
+ "EdgeSchema",
+ "SchemaBuilder",
+]
diff --git a/hyperextract/utils/template_engine/template_factory.py b/hyperextract/utils/template_engine/factory.py
similarity index 94%
rename from hyperextract/utils/template_engine/template_factory.py
rename to hyperextract/utils/template_engine/factory.py
index e121daf..3e886e2 100644
--- a/hyperextract/utils/template_engine/template_factory.py
+++ b/hyperextract/utils/template_engine/factory.py
@@ -21,10 +21,13 @@ from hyperextract.types import (
AutoSpatioTemporalGraph,
)
-from .config_loader import TemplateConfig, Parameters
-from .schema_builder import SchemaBuilder
-from .identifier_resolver import IdentifierResolver
-from .prompt_builder import PromptBuilder
+from .builder import (
+ TemplateConfig,
+ Parameters,
+ SchemaBuilder,
+ IdentifierResolver,
+ PromptBuilder,
+)
class TemplateFactory:
@@ -98,9 +101,9 @@ class TemplateFactory:
if schema_class is None:
raise ValueError(f"AutoModel requires schema definition: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
- prompt = prompt_builder.build_model_prompt(extraction_guide)
+ prompt = prompt_builder.build_model_prompt(guide)
parameters = config.parameters or Parameters()
merge_strategy = parameters.merge_strategy or "llm_balanced"
@@ -135,9 +138,9 @@ class TemplateFactory:
if item_schema_class is None:
raise ValueError(f"AutoList requires item_schema definition: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
- prompt = prompt_builder.build_model_prompt(extraction_guide)
+ prompt = prompt_builder.build_model_prompt(guide)
parameters = config.parameters or Parameters()
@@ -169,9 +172,9 @@ class TemplateFactory:
if item_id_extractor is None:
raise ValueError(f"AutoSet requires item_id configuration: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
- prompt = prompt_builder.build_model_prompt(extraction_guide)
+ prompt = prompt_builder.build_model_prompt(guide)
parameters = config.parameters or Parameters()
merge_strategy = parameters.merge_strategy or "llm_balanced"
@@ -216,19 +219,19 @@ class TemplateFactory:
if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):
raise ValueError(f"AutoGraph requires complete identifiers configuration: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"
if extraction_mode == "one_stage":
- prompt = prompt_builder.build_graph_main_prompt(extraction_guide)
+ prompt = prompt_builder.build_graph_main_prompt(guide)
prompt_for_node_extraction = ""
prompt_for_edge_extraction = ""
else:
prompt = ""
- prompt_for_node_extraction = prompt_builder.build_graph_node_prompt(extraction_guide)
- prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)
+ prompt_for_node_extraction = prompt_builder.build_graph_node_prompt(guide)
+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(guide)
parameters = config.parameters or Parameters()
@@ -297,19 +300,19 @@ class TemplateFactory:
if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):
raise ValueError(f"AutoTemporalGraph requires complete identifiers configuration: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"
if extraction_mode == "one_stage":
- prompt = prompt_builder.build_graph_main_prompt(extraction_guide)
+ prompt = prompt_builder.build_graph_main_prompt(guide)
prompt_for_node_extraction = ""
prompt_for_edge_extraction = ""
else:
prompt = ""
- prompt_for_node_extraction = prompt_builder.build_temporal_graph_node_prompt(extraction_guide)
- prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)
+ prompt_for_node_extraction = prompt_builder.build_temporal_graph_node_prompt(guide)
+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(guide)
parameters = config.parameters or Parameters()
@@ -375,19 +378,19 @@ class TemplateFactory:
if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):
raise ValueError(f"AutoSpatialGraph requires complete identifiers configuration: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"
if extraction_mode == "one_stage":
- prompt = prompt_builder.build_graph_main_prompt(extraction_guide)
+ prompt = prompt_builder.build_graph_main_prompt(guide)
prompt_for_node_extraction = ""
prompt_for_edge_extraction = ""
else:
prompt = ""
- prompt_for_node_extraction = prompt_builder.build_spatial_graph_node_prompt(extraction_guide)
- prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)
+ prompt_for_node_extraction = prompt_builder.build_spatial_graph_node_prompt(guide)
+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(guide)
parameters = config.parameters or Parameters()
@@ -454,19 +457,19 @@ class TemplateFactory:
if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):
raise ValueError(f"AutoSpatioTemporalGraph requires complete identifiers configuration: {config.name}")
- extraction_guide = config.extraction_guide
+ guide = config.guide
prompt_builder = PromptBuilder(language)
extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"
if extraction_mode == "one_stage":
- prompt = prompt_builder.build_graph_main_prompt(extraction_guide)
+ prompt = prompt_builder.build_graph_main_prompt(guide)
prompt_for_node_extraction = ""
prompt_for_edge_extraction = ""
else:
prompt = ""
- prompt_for_node_extraction = prompt_builder.build_spatio_temporal_graph_node_prompt(extraction_guide)
- prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)
+ prompt_for_node_extraction = prompt_builder.build_spatio_temporal_graph_node_prompt(guide)
+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(guide)
parameters = config.parameters or Parameters()
@@ -557,7 +560,6 @@ class TemplateFactory:
"""
# Merge parameters: user-provided kwargs have highest priority
if kwargs:
- from .config_loader import Parameters
base_params = config.parameters or Parameters()
params_dict = base_params.model_dump()
params_dict.update(kwargs)
diff --git a/hyperextract/utils/template_engine/template_gallery.py b/hyperextract/utils/template_engine/gallery.py
similarity index 73%
rename from hyperextract/utils/template_engine/template_gallery.py
rename to hyperextract/utils/template_engine/gallery.py
index 2e6181a..a349ab7 100644
--- a/hyperextract/utils/template_engine/template_gallery.py
+++ b/hyperextract/utils/template_engine/gallery.py
@@ -7,7 +7,7 @@ import os
from pathlib import Path
from typing import Dict, List, Optional
-from .config_loader import TemplateConfig, ConfigLoader
+from .builder import TemplateConfig, ConfigLoader
class Gallery:
@@ -167,6 +167,74 @@ class Gallery:
domains.append((item.name, count))
return domains
+ @classmethod
+ def create(
+ cls,
+ name: str,
+ lang: str = "zh",
+ llm_client=None,
+ embedder=None,
+ ):
+ """Create template instance.
+
+ Args:
+ name: Template name (e.g., "knowledge_graph", "zh/finance/risk_assessment")
+ lang: Language, default "zh"
+ llm_client: LLM client, optional, reads from global config if not provided
+ embedder: Embedder client, optional, reads from global config if not provided
+
+ Returns:
+ TemplateWrapper instance
+
+ Examples:
+ # Method 1: Use global config (recommended)
+ template = Gallery.create("knowledge_graph")
+
+ # Method 2: Custom client
+ from hyperextract.utils import get_client
+ llm, emb = get_client()
+ template = Gallery.create("knowledge_graph", llm_client=llm, embedder=emb)
+
+ # Method 3: Mixed usage
+ template = Gallery.create("knowledge_graph", llm_client=my_llm)
+ """
+ config = cls._resolve_config(name, lang)
+
+ if llm_client is None or embedder is None:
+ from hyperextract.utils import get_client
+ default_llm, default_emb = get_client()
+ llm_client = llm_client or default_llm
+ embedder = embedder or default_emb
+
+ from .factory import TemplateFactory
+ return TemplateFactory.create(config, llm_client, embedder)
+
+ @classmethod
+ def _resolve_config(cls, name: str, lang: str = "zh") -> TemplateConfig:
+ """Resolve template name to config object."""
+ config = cls.get(name)
+ if config is not None:
+ return config
+
+ parts = name.split("/")
+ if len(parts) == 1:
+ search_name = f"{lang}/{name}"
+ config = cls.get(search_name)
+ if config is not None:
+ return config
+ else:
+ template_lang = parts[0]
+ if template_lang not in ["zh", "en"]:
+ template_lang = lang
+ template_name = parts[-1]
+ full_name = f"{template_lang}/{template_name}"
+ config = cls.get(full_name)
+ if config is not None:
+ return config
+
+ available = cls.list_all()
+ raise ValueError(f"Template '{name}' not found. Available: {available[:10]}...")
+
def _load_config(self, file_path: Path) -> None:
try:
config = ConfigLoader.load_config(file_path)
diff --git a/hyperextract/utils/template_engine/template.py b/hyperextract/utils/template_engine/template.py
new file mode 100644
index 0000000..84d36a4
--- /dev/null
+++ b/hyperextract/utils/template_engine/template.py
@@ -0,0 +1,88 @@
+"""Template - Unified template API."""
+
+from .gallery import Gallery
+
+
+class Template:
+ """Unified template API for searching and creating templates.
+
+ Examples:
+ # List all templates
+ Template.list()
+
+ # Search templates
+ Template.search("知识图谱")
+ Template.search(autotype="graph")
+
+ # Get template config
+ config = Template.get("knowledge_graph")
+
+ # Create template (auto reads from global config)
+ template = Template.create("knowledge_graph")
+
+ # Create with custom clients
+ template = Template.create("knowledge_graph", llm_client=llm, embedder=emb)
+ """
+
+ @staticmethod
+ def list():
+ """List all available template names."""
+ return Gallery.list_all()
+
+ @staticmethod
+ def search(query=None, autotype=None, tag=None, language=None):
+ """Search templates by criteria.
+
+ Args:
+ query: Search in template name/description
+ autotype: Filter by autotype (e.g., "graph", "list")
+ tag: Filter by tag
+ language: Filter by language (e.g., "zh", "en")
+
+ Returns:
+ List of TemplateConfig
+ """
+ return Gallery.search(query, autotype, tag, language)
+
+ @staticmethod
+ def get(name, lang="zh"):
+ """Get template config by name.
+
+ Args:
+ name: Template name
+ lang: Language
+
+ Returns:
+ TemplateConfig
+ """
+ return Gallery._resolve_config(name, lang)
+
+ @staticmethod
+ def create(name, lang="zh", llm_client=None, embedder=None):
+ """Create template instance.
+
+ If llm_client or embedder is not provided, automatically reads
+ from global config (~/.he/config.toml).
+
+ Args:
+ name: Template name (e.g., "knowledge_graph", "zh/finance/risk_assessment")
+ lang: Language, default "zh"
+ llm_client: LLM client, optional
+ embedder: Embedder client, optional
+
+ Returns:
+ TemplateWrapper instance
+ """
+ return Gallery.create(name, lang, llm_client, embedder)
+
+ @staticmethod
+ def domains():
+ """List available domains with template count.
+
+ Returns:
+ List of (domain_name, template_count) tuples
+ """
+ return Gallery.list_domains()
+
+
+__all__ = ["Template"]
diff --git a/pyproject.toml b/pyproject.toml
index 8d3582a..63b962e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,7 +40,6 @@ dependencies = [
# cli dependencies
"typer>=0.13.0",
"rich>=13.7.0",
- "tomli>=2.0.1",
"tomli-w>=1.0.0",
]
@@ -53,6 +52,13 @@ dev = [
]
+[project.optional-dependencies]
+anthropic = ["langchain-anthropic>=0.3.0"]
+google = ["langchain-google-genai>=2.1.0"]
+all = [
+ "hyperextract[anthropic,google]",
+]
+
[project.urls]
Homepage = "https://github.com/yifanfeng97/hyper-extract"
Repository = "https://github.com/yifanfeng97/hyper-extract"
diff --git a/tests/fixtures/test_samples/legacy/agriculture/crop_technical_manual.md b/tests/test_data/test_samples/legacy/agriculture/crop_technical_manual.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/agriculture/crop_technical_manual.md
rename to tests/test_data/test_samples/legacy/agriculture/crop_technical_manual.md
diff --git a/tests/fixtures/test_samples/legacy/agriculture/field_scouting_report.md b/tests/test_data/test_samples/legacy/agriculture/field_scouting_report.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/agriculture/field_scouting_report.md
rename to tests/test_data/test_samples/legacy/agriculture/field_scouting_report.md
diff --git a/tests/fixtures/test_samples/legacy/agriculture/soil_analysis_report.md b/tests/test_data/test_samples/legacy/agriculture/soil_analysis_report.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/agriculture/soil_analysis_report.md
rename to tests/test_data/test_samples/legacy/agriculture/soil_analysis_report.md
diff --git a/tests/fixtures/test_samples/legacy/biology/glycolysis_pathway.md b/tests/test_data/test_samples/legacy/biology/glycolysis_pathway.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/biology/glycolysis_pathway.md
rename to tests/test_data/test_samples/legacy/biology/glycolysis_pathway.md
diff --git a/tests/fixtures/test_samples/legacy/biology/lake_ecosystem.md b/tests/test_data/test_samples/legacy/biology/lake_ecosystem.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/biology/lake_ecosystem.md
rename to tests/test_data/test_samples/legacy/biology/lake_ecosystem.md
diff --git a/tests/fixtures/test_samples/legacy/biology/protein_signal_complex.md b/tests/test_data/test_samples/legacy/biology/protein_signal_complex.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/biology/protein_signal_complex.md
rename to tests/test_data/test_samples/legacy/biology/protein_signal_complex.md
diff --git a/tests/fixtures/test_samples/legacy/biology/wetland_survey.md b/tests/test_data/test_samples/legacy/biology/wetland_survey.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/biology/wetland_survey.md
rename to tests/test_data/test_samples/legacy/biology/wetland_survey.md
diff --git a/tests/fixtures/test_samples/legacy/food/food_review_article.md b/tests/test_data/test_samples/legacy/food/food_review_article.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/food/food_review_article.md
rename to tests/test_data/test_samples/legacy/food/food_review_article.md
diff --git a/tests/fixtures/test_samples/legacy/food/multi_recipe_card.md b/tests/test_data/test_samples/legacy/food/multi_recipe_card.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/food/multi_recipe_card.md
rename to tests/test_data/test_samples/legacy/food/multi_recipe_card.md
diff --git a/tests/fixtures/test_samples/legacy/food/recipe_standard_card.md b/tests/test_data/test_samples/legacy/food/recipe_standard_card.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/food/recipe_standard_card.md
rename to tests/test_data/test_samples/legacy/food/recipe_standard_card.md
diff --git a/tests/fixtures/test_samples/legacy/food/restaurant_menu.md b/tests/test_data/test_samples/legacy/food/restaurant_menu.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/food/restaurant_menu.md
rename to tests/test_data/test_samples/legacy/food/restaurant_menu.md
diff --git a/tests/fixtures/test_samples/legacy/history/battle_of_chibi.md b/tests/test_data/test_samples/legacy/history/battle_of_chibi.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/history/battle_of_chibi.md
rename to tests/test_data/test_samples/legacy/history/battle_of_chibi.md
diff --git a/tests/fixtures/test_samples/legacy/history/sushi_life_letters.md b/tests/test_data/test_samples/legacy/history/sushi_life_letters.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/history/sushi_life_letters.md
rename to tests/test_data/test_samples/legacy/history/sushi_life_letters.md
diff --git a/tests/fixtures/test_samples/legacy/literature/critique_zhenhuan.md b/tests/test_data/test_samples/legacy/literature/critique_zhenhuan.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/literature/critique_zhenhuan.md
rename to tests/test_data/test_samples/legacy/literature/critique_zhenhuan.md
diff --git a/tests/fixtures/test_samples/legacy/literature/novel_langya.md b/tests/test_data/test_samples/legacy/literature/novel_langya.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/literature/novel_langya.md
rename to tests/test_data/test_samples/legacy/literature/novel_langya.md
diff --git a/tests/fixtures/test_samples/legacy/literature/screenplay_zhenhuan.md b/tests/test_data/test_samples/legacy/literature/screenplay_zhenhuan.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/literature/screenplay_zhenhuan.md
rename to tests/test_data/test_samples/legacy/literature/screenplay_zhenhuan.md
diff --git a/tests/fixtures/test_samples/legacy/news/__init__.py b/tests/test_data/test_samples/legacy/news/__init__.py
similarity index 100%
rename from tests/fixtures/test_samples/legacy/news/__init__.py
rename to tests/test_data/test_samples/legacy/news/__init__.py
diff --git a/tests/fixtures/test_samples/legacy/news/breaking_news_brief.md b/tests/test_data/test_samples/legacy/news/breaking_news_brief.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/news/breaking_news_brief.md
rename to tests/test_data/test_samples/legacy/news/breaking_news_brief.md
diff --git a/tests/fixtures/test_samples/legacy/news/investigative_report.md b/tests/test_data/test_samples/legacy/news/investigative_report.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/news/investigative_report.md
rename to tests/test_data/test_samples/legacy/news/investigative_report.md
diff --git a/tests/fixtures/test_samples/legacy/news/live_event_updates.md b/tests/test_data/test_samples/legacy/news/live_event_updates.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/news/live_event_updates.md
rename to tests/test_data/test_samples/legacy/news/live_event_updates.md
diff --git a/tests/fixtures/test_samples/legacy/news/policy_analysis.md b/tests/test_data/test_samples/legacy/news/policy_analysis.md
similarity index 100%
rename from tests/fixtures/test_samples/legacy/news/policy_analysis.md
rename to tests/test_data/test_samples/legacy/news/policy_analysis.md
diff --git a/tests/fixtures/test_samples/zh/finance/annual_report_sample.md b/tests/test_data/test_samples/zh/finance/annual_report_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/annual_report_sample.md
rename to tests/test_data/test_samples/zh/finance/annual_report_sample.md
diff --git a/tests/fixtures/test_samples/zh/finance/earnings_call_transcript_sample.md b/tests/test_data/test_samples/zh/finance/earnings_call_transcript_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/earnings_call_transcript_sample.md
rename to tests/test_data/test_samples/zh/finance/earnings_call_transcript_sample.md
diff --git a/tests/fixtures/test_samples/zh/finance/equity_research_report_sample.md b/tests/test_data/test_samples/zh/finance/equity_research_report_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/equity_research_report_sample.md
rename to tests/test_data/test_samples/zh/finance/equity_research_report_sample.md
diff --git a/tests/fixtures/test_samples/zh/finance/financial_news_sample.md b/tests/test_data/test_samples/zh/finance/financial_news_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/financial_news_sample.md
rename to tests/test_data/test_samples/zh/finance/financial_news_sample.md
diff --git a/tests/fixtures/test_samples/zh/finance/ipo_prospectus_sample.md b/tests/test_data/test_samples/zh/finance/ipo_prospectus_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/ipo_prospectus_sample.md
rename to tests/test_data/test_samples/zh/finance/ipo_prospectus_sample.md
diff --git a/tests/fixtures/test_samples/zh/finance/supply_chain_analysis_sample.md b/tests/test_data/test_samples/zh/finance/supply_chain_analysis_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/finance/supply_chain_analysis_sample.md
rename to tests/test_data/test_samples/zh/finance/supply_chain_analysis_sample.md
diff --git a/tests/fixtures/test_samples/zh/general/arbitrary_tech_news.md b/tests/test_data/test_samples/zh/general/arbitrary_tech_news.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/general/arbitrary_tech_news.md
rename to tests/test_data/test_samples/zh/general/arbitrary_tech_news.md
diff --git a/tests/fixtures/test_samples/zh/general/biography_scientist.md b/tests/test_data/test_samples/zh/general/biography_scientist.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/general/biography_scientist.md
rename to tests/test_data/test_samples/zh/general/biography_scientist.md
diff --git a/tests/fixtures/test_samples/zh/general/encyclopedia_machine_learning.md b/tests/test_data/test_samples/zh/general/encyclopedia_machine_learning.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/general/encyclopedia_machine_learning.md
rename to tests/test_data/test_samples/zh/general/encyclopedia_machine_learning.md
diff --git a/tests/fixtures/test_samples/zh/general/regulation_company_policy.md b/tests/test_data/test_samples/zh/general/regulation_company_policy.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/general/regulation_company_policy.md
rename to tests/test_data/test_samples/zh/general/regulation_company_policy.md
diff --git a/tests/fixtures/test_samples/zh/industry/equipment_technical_manual.md b/tests/test_data/test_samples/zh/industry/equipment_technical_manual.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/industry/equipment_technical_manual.md
rename to tests/test_data/test_samples/zh/industry/equipment_technical_manual.md
diff --git a/tests/fixtures/test_samples/zh/industry/failure_analysis_report.md b/tests/test_data/test_samples/zh/industry/failure_analysis_report.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/industry/failure_analysis_report.md
rename to tests/test_data/test_samples/zh/industry/failure_analysis_report.md
diff --git a/tests/fixtures/test_samples/zh/industry/operation_maintenance_manual.md b/tests/test_data/test_samples/zh/industry/operation_maintenance_manual.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/industry/operation_maintenance_manual.md
rename to tests/test_data/test_samples/zh/industry/operation_maintenance_manual.md
diff --git a/tests/fixtures/test_samples/zh/industry/safety_management_handbook.md b/tests/test_data/test_samples/zh/industry/safety_management_handbook.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/industry/safety_management_handbook.md
rename to tests/test_data/test_samples/zh/industry/safety_management_handbook.md
diff --git a/tests/fixtures/test_samples/zh/legal/compliance_filing_sample.md b/tests/test_data/test_samples/zh/legal/compliance_filing_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/legal/compliance_filing_sample.md
rename to tests/test_data/test_samples/zh/legal/compliance_filing_sample.md
diff --git a/tests/fixtures/test_samples/zh/legal/court_judgment_sample.md b/tests/test_data/test_samples/zh/legal/court_judgment_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/legal/court_judgment_sample.md
rename to tests/test_data/test_samples/zh/legal/court_judgment_sample.md
diff --git a/tests/fixtures/test_samples/zh/legal/legal_treatise_sample.md b/tests/test_data/test_samples/zh/legal/legal_treatise_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/legal/legal_treatise_sample.md
rename to tests/test_data/test_samples/zh/legal/legal_treatise_sample.md
diff --git a/tests/fixtures/test_samples/zh/legal/msa_contract_sample.md b/tests/test_data/test_samples/zh/legal/msa_contract_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/legal/msa_contract_sample.md
rename to tests/test_data/test_samples/zh/legal/msa_contract_sample.md
diff --git a/tests/fixtures/test_samples/zh/medicine/clinical_guideline_sample.md b/tests/test_data/test_samples/zh/medicine/clinical_guideline_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/medicine/clinical_guideline_sample.md
rename to tests/test_data/test_samples/zh/medicine/clinical_guideline_sample.md
diff --git a/tests/fixtures/test_samples/zh/medicine/discharge_summary_sample.md b/tests/test_data/test_samples/zh/medicine/discharge_summary_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/medicine/discharge_summary_sample.md
rename to tests/test_data/test_samples/zh/medicine/discharge_summary_sample.md
diff --git a/tests/fixtures/test_samples/zh/medicine/package_insert_sample.md b/tests/test_data/test_samples/zh/medicine/package_insert_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/medicine/package_insert_sample.md
rename to tests/test_data/test_samples/zh/medicine/package_insert_sample.md
diff --git a/tests/fixtures/test_samples/zh/medicine/pathology_report_sample.md b/tests/test_data/test_samples/zh/medicine/pathology_report_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/medicine/pathology_report_sample.md
rename to tests/test_data/test_samples/zh/medicine/pathology_report_sample.md
diff --git a/tests/fixtures/test_samples/zh/medicine/textbook_sample.md b/tests/test_data/test_samples/zh/medicine/textbook_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/medicine/textbook_sample.md
rename to tests/test_data/test_samples/zh/medicine/textbook_sample.md
diff --git a/tests/fixtures/test_samples/zh/tcm/herb_property_single.md b/tests/test_data/test_samples/zh/tcm/herb_property_single.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/herb_property_single.md
rename to tests/test_data/test_samples/zh/tcm/herb_property_single.md
diff --git a/tests/fixtures/test_samples/zh/tcm/herbal_compendium_sample.md b/tests/test_data/test_samples/zh/tcm/herbal_compendium_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/herbal_compendium_sample.md
rename to tests/test_data/test_samples/zh/tcm/herbal_compendium_sample.md
diff --git a/tests/fixtures/test_samples/zh/tcm/medical_case_record_sample.md b/tests/test_data/test_samples/zh/tcm/medical_case_record_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/medical_case_record_sample.md
rename to tests/test_data/test_samples/zh/tcm/medical_case_record_sample.md
diff --git a/tests/fixtures/test_samples/zh/tcm/meridian_treatise_sample.md b/tests/test_data/test_samples/zh/tcm/meridian_treatise_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/meridian_treatise_sample.md
rename to tests/test_data/test_samples/zh/tcm/meridian_treatise_sample.md
diff --git a/tests/fixtures/test_samples/zh/tcm/prescription_formulary_sample.md b/tests/test_data/test_samples/zh/tcm/prescription_formulary_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/prescription_formulary_sample.md
rename to tests/test_data/test_samples/zh/tcm/prescription_formulary_sample.md
diff --git a/tests/fixtures/test_samples/zh/tcm/prescription_modification_sample.md b/tests/test_data/test_samples/zh/tcm/prescription_modification_sample.md
similarity index 100%
rename from tests/fixtures/test_samples/zh/tcm/prescription_modification_sample.md
rename to tests/test_data/test_samples/zh/tcm/prescription_modification_sample.md