Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
fix: use function_calling for structured output on non-OpenAI providers (#52)
dex0shubham3728ae62af10
diff --git a/hyperextract/methods/typical/atom.py b/hyperextract/methods/typical/atom.pyindex 1611683..82cb2b3 100644--- a/hyperextract/methods/typical/atom.py+++ b/hyperextract/methods/typical/atom.py@@ -433,7 +433,7 @@ class Atom(AutoGraph[NodeSchema, EdgeSchema]):Atom_FACTOID_EXTRACTION_PROMPT)fact_chain = fact_prompt_template | self.llm_client.with_structured_output(- AtomicFactSchema+ AtomicFactSchema, method="function_calling")# 3. Batch Extract Factsdiff --git a/hyperextract/types/base.py b/hyperextract/types/base.pyindex db8e2c8..44f2762 100644--- a/hyperextract/types/base.py+++ b/hyperextract/types/base.py@@ -76,7 +76,9 @@ class BaseAutoType(ABC, Generic[T]):self.prompt_template = ChatPromptTemplate.from_template(self.prompt)self.data_extractor = (self.prompt_template- | self.llm_client.with_structured_output(self._data_schema)+ | self.llm_client.with_structured_output(+ self._data_schema, method="function_calling"+ ))# Initialize text splitter for chunking long documentsdiff --git a/hyperextract/types/graph.py b/hyperextract/types/graph.pyindex a3bdd16..a36821b 100644--- a/hyperextract/types/graph.py+++ b/hyperextract/types/graph.py@@ -316,13 +316,17 @@ class AutoGraph(self.prompt_template = ChatPromptTemplate.from_template(self.node_prompt)self.node_extractor = (self.prompt_template- | self.llm_client.with_structured_output(self.node_list_schema)+ | self.llm_client.with_structured_output(+ self.node_list_schema, method="function_calling"+ ))self.edge_prompt_template = ChatPromptTemplate.from_template(self.edge_prompt)self.edge_extractor = (self.edge_prompt_template- | self.llm_client.with_structured_output(self.edge_list_schema)+ | self.llm_client.with_structured_output(+ self.edge_list_schema, method="function_calling"+ ))def _default_prompt(self) -> str:diff --git a/hyperextract/types/hypergraph.py b/hyperextract/types/hypergraph.pyindex 382a50d..a4eb10f 100644--- a/hyperextract/types/hypergraph.py+++ b/hyperextract/types/hypergraph.py@@ -321,13 +321,17 @@ class AutoHypergraph(self.prompt_template = ChatPromptTemplate.from_template(self.node_prompt)self.node_extractor = (self.prompt_template- | self.llm_client.with_structured_output(self.node_list_schema)+ | self.llm_client.with_structured_output(+ self.node_list_schema, method="function_calling"+ ))self.edge_prompt_template = ChatPromptTemplate.from_template(self.edge_prompt)self.edge_extractor = (self.edge_prompt_template- | self.llm_client.with_structured_output(self.edge_list_schema)+ | self.llm_client.with_structured_output(+ self.edge_list_schema, method="function_calling"+ ))# ==================== Prompts ====================