Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
fix: 更新 LLM 模型为 gpt-4o-mini,优化性能和稳定性 feat: 添加电影模板的初始化文件,包含角色弧跟踪、电影 trivia 集和剧本场景图 refactor: 优化新闻事件图的字段描述和提示词格式,提高可读性
yifanfeng9750c22de1cb1e
diff --git a/examples/auto_graph_demo.py b/examples/auto_graph_demo.pyindex 45da129..e73ae31 100644--- a/examples/auto_graph_demo.py+++ b/examples/auto_graph_demo.py@@ -272,7 +272,7 @@ def run_demo():# 初始化 LLMprint("\n🔧 初始化 LLM 和嵌入模型...")- llm = ChatOpenAI(model="gpt-4o", temperature=0)+ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)embedder = OpenAIEmbeddings()# 创建 AutoGraphdiff --git a/hyperextract/templates/zh/movie/__init__.py b/hyperextract/templates/zh/movie/__init__.pyindex e69de29..4bc7ed1 100644--- a/hyperextract/templates/zh/movie/__init__.py+++ b/hyperextract/templates/zh/movie/__init__.py@@ -0,0 +1,9 @@+from .character_arc_tracker import CharacterArcTracker+from .cinematic_trivia_set import CinematicTriviaSet+from .script_scene_graph import ScriptSceneGraph++__all__ = [+ "CharacterArcTracker",+ "CinematicTriviaSet",+ "ScriptSceneGraph",+]diff --git a/hyperextract/templates/zh/news/breaking_event_graph.py b/hyperextract/templates/zh/news/breaking_event_graph.pyindex 0254198..ed99e4e 100644--- a/hyperextract/templates/zh/news/breaking_event_graph.py+++ b/hyperextract/templates/zh/news/breaking_event_graph.py@@ -8,20 +8,31 @@ from hyperextract.types import AutoGraph# 1. Schema 定义# ==============================================================================+class NewsEntity(BaseModel):"""新闻事件中的关键实体(人物、组织、国家、核心物件)。"""+name: str = Field(description="实体的全称或最常用名。")- category: str = Field(description="实体类别(如:政治人物、国际组织、政府机构、抗议团体)。")- role: str = Field(description="该实体在当前新闻事件中扮演的角色或立场(如:发起者、受害者、调停方)。")+ category: str = Field(+ description="实体类别(如:政治人物、国际组织、政府机构、抗议团体)。"+ )+ role: str = Field(+ description="该实体在当前新闻事件中扮演的角色或立场(如:发起者、受害者、调停方)。"+ )+class NewsAction(BaseModel):"""实体间的具体动作、行为或声明。"""+source: str = Field(description="动作的发起方。")target: str = Field(description="动作的对象或接收方。")- action_type: str = Field(description="动作类型(如:谴责、签署协议、发起进攻、发布声明)。")+ action_type: str = Field(+ description="动作类型(如:谴责、签署协议、发起进攻、发布声明)。"+ )impact: str = Field(description="该动作产生的直接影响、结果或背景动机。")evidence: str = Field(description="对应的原文核心表述片段。")+# ==============================================================================# 2. 提示词 (Prompts)# ==============================================================================@@ -34,13 +45,18 @@ _PROMPT = ("3. **影响评估**:捕捉动作背后的影响和核心动机。\n")-_NODE_PROMPT = "提取新闻中提及的所有关键人物、组织和国家。请注明其所属类别及在事件中的主要角色。"-_EDGE_PROMPT = "识别各方之间的具体行为与互动逻辑。请描述动作的性质、影响,并附带原文证据。"+_NODE_PROMPT = (+ "提取新闻中提及的所有关键人物、组织和国家。请注明其所属类别及在事件中的主要角色。"+)+_EDGE_PROMPT = (+ "识别各方之间的具体行为与互动逻辑。请描述动作的性质、影响,并附带原文证据。"+)# ==============================================================================# 3. 模板类# ==============================================================================+class BreakingEventGraph(AutoGraph[NewsEntity, NewsAction]):"""适用于:[突发新闻报道, 地缘政治简报, 新闻稿, 情报摘要]@@ -61,7 +77,7 @@ class BreakingEventGraph(AutoGraph[NewsEntity, NewsAction]):embedder: Embeddings,*,extraction_mode: str = "one_stage",- **kwargs: Any+ **kwargs: Any,):super().__init__(node_schema=NewsEntity,@@ -75,10 +91,16 @@ class BreakingEventGraph(AutoGraph[NewsEntity, NewsAction]):prompt_for_node_extraction=_NODE_PROMPT,prompt_for_edge_extraction=_EDGE_PROMPT,extraction_mode=extraction_mode,- **kwargs+ **kwargs,)def show(self, **kwargs):- def n_label(node: NewsEntity) -> str: return f"{node.name} ({node.role})"- def e_label(edge: NewsAction) -> str: return edge.action_type- super().show(node_label_extractor=n_label, edge_label_extractor=e_label, **kwargs)+ def n_label(node: NewsEntity) -> str:+ return f"{node.name} ({node.role})"++ def e_label(edge: NewsAction) -> str:+ return edge.action_type++ super().show(+ node_label_extractor=n_label, edge_label_extractor=e_label, **kwargs+ )