Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
fix: 更新视图函数,使用 view_nodes 替代 view_graph,并优化搜索和聊天回调返回值
yifanfeng9796d197627296
diff --git a/examples/auto_set_demo.py b/examples/auto_set_demo.pyindex fa41a35..9fe65a3 100644--- a/examples/auto_set_demo.py+++ b/examples/auto_set_demo.py@@ -282,8 +282,8 @@ def main():monster_codex.show(item_label_extractor=lambda x: x.name,- top_k_for_search=5,- top_k_for_chat=5+ top_k_for_search=3,+ top_k_for_chat=3)diff --git a/hyperextract/types/list.py b/hyperextract/types/list.pyindex bf778ec..6a70a9e 100644--- a/hyperextract/types/list.py+++ b/hyperextract/types/list.py@@ -18,7 +18,7 @@ from langchain_core.documents import Documentfrom langchain_core.embeddings import Embeddingsfrom langchain_core.language_models.chat_models import BaseChatModelfrom langchain_community.vectorstores import FAISS-from ontosight import view_graph+from ontosight import view_nodesfrom .base import BaseAutoTypefrom hyperextract.utils.logging import logger@@ -336,13 +336,13 @@ class AutoList(BaseAutoType[AutoListSchema[ItemSchema]], Generic[ItemSchema]):def search_callback(query: str) -> None:related_items = self.search(query, top_k=top_k_for_search)- return related_items, []+ return related_itemsdef chat_callback(question: str) -> None:response = self.chat(question, top_k=top_k_for_chat)content = response.contentretrieved_items = response.additional_kwargs.get("retrieved_items", [])- return content, (retrieved_items, [])+ return content, retrieved_itemselse:logger.info("Visualizing list without search and chat capabilities (no indices detected)."@@ -355,17 +355,17 @@ class AutoList(BaseAutoType[AutoListSchema[ItemSchema]], Generic[ItemSchema]):def item_id_extractor(item: ItemSchema) -> str:return md5(str(item.model_dump()).encode()).hexdigest()[:8]- view_graph(+ view_nodes(node_list=self.items,- edge_list=[],node_schema=self.item_schema,- edge_schema=None,node_id_extractor=item_id_extractor,- node_ids_in_edge_extractor=None,node_label_extractor=item_label_extractor,- edge_label_extractor=None,on_search=search_callback,on_chat=chat_callback,+ context={+ "title": f"{self.item_schema.__name__} List",+ "description": f"Visualizing {len(self.items)} items in AutoList"+ })# ==================== Pythonic Sequence Operations ====================diff --git a/hyperextract/types/set.py b/hyperextract/types/set.pyindex 12bac58..c9fcd35 100644--- a/hyperextract/types/set.py+++ b/hyperextract/types/set.py@@ -21,7 +21,7 @@ from langchain_core.embeddings import Embeddingsfrom langchain_core.language_models.chat_models import BaseChatModelfrom ontomem import OMemfrom ontomem.merger import MergeStrategy, create_merger, BaseMerger-from ontosight import view_graph+from ontosight import view_nodesfrom .base import BaseAutoTypefrom hyperextract.utils.logging import logger@@ -384,13 +384,13 @@ class AutoSet(BaseAutoType[AutoSetSchema[ItemSchema]], Generic[ItemSchema]):def search_callback(query: str) -> None:related_items = self.search(query, top_k=top_k_for_search)- return related_items, []+ return related_itemsdef chat_callback(question: str) -> None:response = self.chat(question, top_k=top_k_for_chat)content = response.contentretrieved_items = response.additional_kwargs.get("retrieved_items", [])- return content, (retrieved_items, [])+ return content, retrieved_itemselse:logger.info("Visualizing set without search and chat capabilities (no indices detected)."@@ -398,17 +398,17 @@ class AutoSet(BaseAutoType[AutoSetSchema[ItemSchema]], Generic[ItemSchema]):search_callback = Nonechat_callback = None- view_graph(+ view_nodes(node_list=self.items,- edge_list=[],node_schema=self.item_schema,- edge_schema=None,node_id_extractor=self.key_extractor,- node_ids_in_edge_extractor=None,node_label_extractor=item_label_extractor,- edge_label_extractor=None,on_search=search_callback,on_chat=chat_callback,+ context={+ "title": f"{self.item_schema.__name__} Set",+ "description": f"Visualizing {len(self.items)} unique items in AutoSet"+ })# ==================== Set Interface Methods ====================