graphiti-core 0.8.6__py3-none-any.whl → 0.8.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of graphiti-core might be problematic. Click here for more details.

graphiti_core/errors.py CHANGED
@@ -65,3 +65,11 @@ class SearchRerankerError(GraphitiError):
65
65
  def __init__(self, text: str):
66
66
  self.message = text
67
67
  super().__init__(self.message)
68
+
69
+
70
+ class EntityTypeValidationError(GraphitiError):
71
+ """Raised when an entity type uses protected attribute names."""
72
+
73
+ def __init__(self, entity_type: str, entity_type_attribute: str):
74
+ self.message = f'{entity_type_attribute} cannot be used as an attribute for {entity_type} as it is a protected attribute name.'
75
+ super().__init__(self.message)
graphiti_core/graphiti.py CHANGED
@@ -76,6 +76,7 @@ from graphiti_core.utils.maintenance.node_operations import (
76
76
  resolve_extracted_nodes,
77
77
  )
78
78
  from graphiti_core.utils.maintenance.temporal_operations import get_edge_contradictions
79
+ from graphiti_core.utils.ontology_utils.entity_types_utils import validate_entity_types
79
80
 
80
81
  logger = logging.getLogger(__name__)
81
82
 
@@ -262,6 +263,7 @@ class Graphiti:
262
263
  uuid: str | None = None,
263
264
  update_communities: bool = False,
264
265
  entity_types: dict[str, BaseModel] | None = None,
266
+ previous_episode_uuids: list[str] | None = None,
265
267
  ) -> AddEpisodeResults:
266
268
  """
267
269
  Process an episode and update the graph.
@@ -287,6 +289,9 @@ class Graphiti:
287
289
  Optional uuid of the episode.
288
290
  update_communities : bool
289
291
  Optional. Whether to update communities with new node information
292
+ previous_episode_uuids : list[str] | None
293
+ Optional. list of episode uuids to use as the previous episodes. If this is not provided,
294
+ the most recent episodes by created_at date will be used.
290
295
 
291
296
  Returns
292
297
  -------
@@ -315,8 +320,14 @@ class Graphiti:
315
320
  entity_edges: list[EntityEdge] = []
316
321
  now = utc_now()
317
322
 
318
- previous_episodes = await self.retrieve_episodes(
319
- reference_time, last_n=RELEVANT_SCHEMA_LIMIT, group_ids=[group_id]
323
+ validate_entity_types(entity_types)
324
+
325
+ previous_episodes = (
326
+ await self.retrieve_episodes(
327
+ reference_time, last_n=RELEVANT_SCHEMA_LIMIT, group_ids=[group_id]
328
+ )
329
+ if previous_episode_uuids is None
330
+ else await EpisodicNode.get_by_uuids(self.driver, previous_episode_uuids)
320
331
  )
321
332
 
322
333
  episode = (
@@ -0,0 +1,37 @@
1
+ """
2
+ Copyright 2024, Zep Software, Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ from pydantic import BaseModel
18
+
19
+ from graphiti_core.errors import EntityTypeValidationError
20
+ from graphiti_core.nodes import EntityNode
21
+
22
+
23
+ def validate_entity_types(
24
+ entity_types: dict[str, BaseModel] | None,
25
+ ) -> bool:
26
+ if entity_types is None:
27
+ return True
28
+
29
+ entity_node_field_names = EntityNode.model_fields.keys()
30
+
31
+ for entity_type_name, entity_type_model in entity_types.items():
32
+ entity_type_field_names = entity_type_model.model_fields.keys()
33
+ for entity_type_field_name in entity_type_field_names:
34
+ if entity_type_field_name in entity_node_field_names:
35
+ raise EntityTypeValidationError(entity_type_name, entity_type_field_name)
36
+
37
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: graphiti-core
3
- Version: 0.8.6
3
+ Version: 0.8.8
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -8,8 +8,8 @@ graphiti_core/embedder/__init__.py,sha256=eWd-0sPxflnYXLoWNT9sxwCIFun5JNO9Fk4E-Z
8
8
  graphiti_core/embedder/client.py,sha256=HKIlpPLnzFT81jurPkry6z8F8nxfZVfejdcfxHVUSFU,995
9
9
  graphiti_core/embedder/openai.py,sha256=23BnPA10eiaa1HkxHKYSj75-0PymczPK2FNNIz8Txbc,1910
10
10
  graphiti_core/embedder/voyage.py,sha256=7kqrLG75J3Q6cdA2Nlx1JSYtpk2141ckdl3OtDDw0vU,1882
11
- graphiti_core/errors.py,sha256=cSOXXkydihNd6OHXzkwJvciRmR7EoFMq57AzUYVg0gc,2040
12
- graphiti_core/graphiti.py,sha256=DP2hd1aXIYh-nXVfxugHvw7Tbax50w83IKMZf9Z5BeI,29128
11
+ graphiti_core/errors.py,sha256=Nib1uQx2cO_VOizupmRjpFfmuRg-hFAVqTtZAuBehR8,2405
12
+ graphiti_core/graphiti.py,sha256=KaDlOIhaAPskmVbR-hQf5XHt98gY3zGGa6BjcNc5xSg,29725
13
13
  graphiti_core/helpers.py,sha256=7BQzUBFmoBDA2OIDdFtoN4W-vXOhPRIsF0uDb7PsNi0,2913
14
14
  graphiti_core/llm_client/__init__.py,sha256=PA80TSMeX-sUXITXEAxMDEt3gtfZgcJrGJUcyds1mSo,207
15
15
  graphiti_core/llm_client/anthropic_client.py,sha256=dTM8rKhk9TZAU4O-0jFMivOwJvWM-gHpp5gLmuJHiGQ,2723
@@ -55,7 +55,8 @@ graphiti_core/utils/maintenance/graph_data_operations.py,sha256=UJlIAawswJ7eO70o
55
55
  graphiti_core/utils/maintenance/node_operations.py,sha256=yo5Qt7i5WN3J3rB_9RJ0TJ1ZG1cGFWUKGrktMDwmXyE,15521
56
56
  graphiti_core/utils/maintenance/temporal_operations.py,sha256=RdNtubCyYhOVrvcOIq2WppHls1Q-BEjtsN8r38l-Rtc,3691
57
57
  graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- graphiti_core-0.8.6.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
59
- graphiti_core-0.8.6.dist-info/METADATA,sha256=zYMw2oBa7JD7S1oADmCY015HvYfLJP-BQebND1Il2GQ,14351
60
- graphiti_core-0.8.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
61
- graphiti_core-0.8.6.dist-info/RECORD,,
58
+ graphiti_core/utils/ontology_utils/entity_types_utils.py,sha256=QJX5cG0GSSNF_Mm_yrldr69wjVAbN_MxLhOSznz85Hk,1279
59
+ graphiti_core-0.8.8.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
60
+ graphiti_core-0.8.8.dist-info/METADATA,sha256=q-Vnd7mLYOooY2-ZveX_Klw_ofinQGxGcc-Td8-P2Hk,14351
61
+ graphiti_core-0.8.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
62
+ graphiti_core-0.8.8.dist-info/RECORD,,