Skip to content

Commit 5cbdf94

Browse files
authored
Merge pull request #179 from FalkorDB/fix-ontology-imports
Revert "add delay to avoid rate limits" & Fix curricular import
2 parents 95b0186 + b7187c4 commit 5cbdf94

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

graphrag_sdk/kg.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import warnings
3-
import time
43
from falkordb import FalkorDB
54
from typing import Optional, Union
65
from graphrag_sdk.ontology import Ontology
@@ -203,16 +202,15 @@ def list_sources(self) -> list[AbstractSource]:
203202
return [s.source for s in self.sources]
204203

205204
def process_sources(
206-
self, sources: list[AbstractSource], instructions: Optional[str] = None, hide_progress: Optional[bool] = False, delay: Optional[float] = 0
205+
self, sources: list[AbstractSource], instructions: Optional[str] = None, hide_progress: Optional[bool] = False
207206
) -> None:
208207
"""
209208
Add entities and relations found in sources into the knowledge-graph
210209
211210
Args:
212-
sources (list[AbstractSource]): list of sources to extract knowledge from
211+
sources (list[AbstractSource]): list of sources to extract knowledge from
213212
instructions (Optional[str]): Instructions for processing.
214213
hide_progress (Optional[bool]): hide progress bar
215-
delay (float): seconds to delay each iteration through sources to avoid rate limits
216214
"""
217215

218216
if self.ontology is None:
@@ -221,11 +219,6 @@ def process_sources(
221219
# Create graph with sources
222220
self._create_graph_with_sources(sources, instructions, hide_progress)
223221

224-
# Add processed sources
225-
for src in sources:
226-
self.sources.add(src)
227-
time.sleep(delay)
228-
229222

230223
def _create_graph_with_sources(
231224
self, sources: Optional[list[AbstractSource]] = None, instructions: Optional[str] = None, hide_progress: Optional[bool] = False

graphrag_sdk/ontology.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import json
22
import logging
3-
import graphrag_sdk
43
from falkordb import Graph
54
from .entity import Entity
65
from .relation import Relation
76
from typing import Optional, Union
87
from graphrag_sdk.source import AbstractSource
98
from graphrag_sdk.models import GenerativeModel
10-
from graphrag_sdk.steps.create_ontology_step import CreateOntologyStep
119
from .attribute import Attribute, AttributeType
1210

1311
logger = logging.getLogger(__name__)
@@ -72,7 +70,10 @@ def from_sources(
7270
Returns:
7371
The created Ontology object.
7472
"""
75-
step = graphrag_sdk.CreateOntologyStep(
73+
# Import here to avoid circular import
74+
from graphrag_sdk.steps.create_ontology_step import CreateOntologyStep
75+
76+
step = CreateOntologyStep(
7677
sources=sources,
7778
ontology=Ontology(),
7879
model=model,

graphrag_sdk/steps/create_ontology_step.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from threading import Lock
66
from typing import Optional
77
from graphrag_sdk.steps.Step import Step
8-
from graphrag_sdk.document import Document
98
from graphrag_sdk.ontology import Ontology
109
from graphrag_sdk.helpers import extract_json
1110
from ratelimit import limits, sleep_and_retry

0 commit comments

Comments
 (0)