graphiti-core 0.18.6__py3-none-any.whl → 0.18.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.

@@ -84,7 +84,7 @@ class OpenAIRerankerClient(CrossEncoderClient):
84
84
  responses = await semaphore_gather(
85
85
  *[
86
86
  self.client.chat.completions.create(
87
- model=DEFAULT_MODEL,
87
+ model=self.config.model or DEFAULT_MODEL,
88
88
  messages=openai_messages,
89
89
  temperature=0,
90
90
  max_tokens=1,
graphiti_core/edges.py CHANGED
@@ -64,6 +64,21 @@ class Edge(BaseModel, ABC):
64
64
 
65
65
  return result
66
66
 
67
+ @classmethod
68
+ async def delete_by_uuids(cls, driver: GraphDriver, uuids: list[str]):
69
+ result = await driver.execute_query(
70
+ """
71
+ MATCH (n)-[e:MENTIONS|RELATES_TO|HAS_MEMBER]->(m)
72
+ WHERE e.uuid IN $uuids
73
+ DELETE e
74
+ """,
75
+ uuids=uuids,
76
+ )
77
+
78
+ logger.debug(f'Deleted Edges: {uuids}')
79
+
80
+ return result
81
+
67
82
  def __hash__(self):
68
83
  return hash(self.uuid)
69
84
 
graphiti_core/graphiti.py CHANGED
@@ -28,6 +28,7 @@ from graphiti_core.driver.driver import GraphDriver
28
28
  from graphiti_core.driver.neo4j_driver import Neo4jDriver
29
29
  from graphiti_core.edges import (
30
30
  CommunityEdge,
31
+ Edge,
31
32
  EntityEdge,
32
33
  EpisodicEdge,
33
34
  create_entity_edge_embeddings,
@@ -46,6 +47,7 @@ from graphiti_core.nodes import (
46
47
  EntityNode,
47
48
  EpisodeType,
48
49
  EpisodicNode,
50
+ Node,
49
51
  create_entity_node_embeddings,
50
52
  )
51
53
  from graphiti_core.search.search import SearchConfig, search
@@ -1066,12 +1068,7 @@ class Graphiti:
1066
1068
  if record['episode_count'] == 1:
1067
1069
  nodes_to_delete.append(node)
1068
1070
 
1069
- await semaphore_gather(
1070
- *[node.delete(self.driver) for node in nodes_to_delete],
1071
- max_coroutines=self.max_coroutines,
1072
- )
1073
- await semaphore_gather(
1074
- *[edge.delete(self.driver) for edge in edges_to_delete],
1075
- max_coroutines=self.max_coroutines,
1076
- )
1071
+ await Node.delete_by_uuids(self.driver, [node.uuid for node in nodes_to_delete])
1072
+
1073
+ await Edge.delete_by_uuids(self.driver, [edge.uuid for edge in edges_to_delete])
1077
1074
  await episode.delete(self.driver)
@@ -111,7 +111,7 @@ def get_community_node_save_query(provider: GraphProvider) -> str:
111
111
  if provider == GraphProvider.FALKORDB:
112
112
  return """
113
113
  MERGE (n:Community {uuid: $uuid})
114
- SET n = {uuid: $uuid, name: $name, group_id: $group_id, summary: $summary, created_at: $created_at, name_embedding: $name_embedding}
114
+ SET n = {uuid: $uuid, name: $name, group_id: $group_id, summary: $summary, created_at: $created_at, name_embedding: vecf32($name_embedding)}
115
115
  RETURN n.uuid AS uuid
116
116
  """
117
117
 
graphiti_core/nodes.py CHANGED
@@ -142,6 +142,33 @@ class Node(BaseModel, ABC):
142
142
  batch_size=batch_size,
143
143
  )
144
144
 
145
+ @classmethod
146
+ async def delete_by_uuids(cls, driver: GraphDriver, uuids: list[str], batch_size: int = 100):
147
+ if driver.provider == GraphProvider.FALKORDB:
148
+ for label in ['Entity', 'Episodic', 'Community']:
149
+ await driver.execute_query(
150
+ f"""
151
+ MATCH (n:{label})
152
+ WHERE n.uuid IN $uuids
153
+ DETACH DELETE n
154
+ """,
155
+ uuids=uuids,
156
+ )
157
+ else:
158
+ async with driver.session() as session:
159
+ await session.run(
160
+ """
161
+ MATCH (n:Entity|Episodic|Community)
162
+ WHERE n.uuid IN $uuids
163
+ CALL {
164
+ WITH n
165
+ DETACH DELETE n
166
+ } IN TRANSACTIONS OF $batch_size ROWS
167
+ """,
168
+ uuids=uuids,
169
+ batch_size=batch_size,
170
+ )
171
+
145
172
  @classmethod
146
173
  async def get_by_uuid(cls, driver: GraphDriver, uuid: str): ...
147
174
 
@@ -108,7 +108,7 @@ def nodes(context: dict[str, Any]) -> list[Message]:
108
108
  Message(
109
109
  role='system',
110
110
  content='You are a helpful assistant that determines whether or not ENTITIES extracted from a conversation are duplicates'
111
- 'of existing entities.',
111
+ ' of existing entities.',
112
112
  ),
113
113
  Message(
114
114
  role='user',
@@ -177,31 +177,42 @@ async def edge_search(
177
177
  ) -> tuple[list[EntityEdge], list[float]]:
178
178
  if config is None:
179
179
  return [], []
180
- search_results: list[list[EntityEdge]] = list(
181
- await semaphore_gather(
182
- *[
183
- edge_fulltext_search(driver, query, search_filter, group_ids, 2 * limit),
184
- edge_similarity_search(
185
- driver,
186
- query_vector,
187
- None,
188
- None,
189
- search_filter,
190
- group_ids,
191
- 2 * limit,
192
- config.sim_min_score,
193
- ),
194
- edge_bfs_search(
195
- driver,
196
- bfs_origin_node_uuids,
197
- config.bfs_max_depth,
198
- search_filter,
199
- group_ids,
200
- 2 * limit,
201
- ),
202
- ]
180
+
181
+ # Build search tasks based on configured search methods
182
+ search_tasks = []
183
+ if EdgeSearchMethod.bm25 in config.search_methods:
184
+ search_tasks.append(
185
+ edge_fulltext_search(driver, query, search_filter, group_ids, 2 * limit)
203
186
  )
204
- )
187
+ if EdgeSearchMethod.cosine_similarity in config.search_methods:
188
+ search_tasks.append(
189
+ edge_similarity_search(
190
+ driver,
191
+ query_vector,
192
+ None,
193
+ None,
194
+ search_filter,
195
+ group_ids,
196
+ 2 * limit,
197
+ config.sim_min_score,
198
+ )
199
+ )
200
+ if EdgeSearchMethod.bfs in config.search_methods:
201
+ search_tasks.append(
202
+ edge_bfs_search(
203
+ driver,
204
+ bfs_origin_node_uuids,
205
+ config.bfs_max_depth,
206
+ search_filter,
207
+ group_ids,
208
+ 2 * limit,
209
+ )
210
+ )
211
+
212
+ # Execute only the configured search methods
213
+ search_results: list[list[EntityEdge]] = []
214
+ if search_tasks:
215
+ search_results = list(await semaphore_gather(*search_tasks))
205
216
 
206
217
  if EdgeSearchMethod.bfs in config.search_methods and bfs_origin_node_uuids is None:
207
218
  source_node_uuids = [edge.source_node_uuid for result in search_results for edge in result]
@@ -289,24 +300,35 @@ async def node_search(
289
300
  ) -> tuple[list[EntityNode], list[float]]:
290
301
  if config is None:
291
302
  return [], []
292
- search_results: list[list[EntityNode]] = list(
293
- await semaphore_gather(
294
- *[
295
- node_fulltext_search(driver, query, search_filter, group_ids, 2 * limit),
296
- node_similarity_search(
297
- driver, query_vector, search_filter, group_ids, 2 * limit, config.sim_min_score
298
- ),
299
- node_bfs_search(
300
- driver,
301
- bfs_origin_node_uuids,
302
- search_filter,
303
- config.bfs_max_depth,
304
- group_ids,
305
- 2 * limit,
306
- ),
307
- ]
303
+
304
+ # Build search tasks based on configured search methods
305
+ search_tasks = []
306
+ if NodeSearchMethod.bm25 in config.search_methods:
307
+ search_tasks.append(
308
+ node_fulltext_search(driver, query, search_filter, group_ids, 2 * limit)
308
309
  )
309
- )
310
+ if NodeSearchMethod.cosine_similarity in config.search_methods:
311
+ search_tasks.append(
312
+ node_similarity_search(
313
+ driver, query_vector, search_filter, group_ids, 2 * limit, config.sim_min_score
314
+ )
315
+ )
316
+ if NodeSearchMethod.bfs in config.search_methods:
317
+ search_tasks.append(
318
+ node_bfs_search(
319
+ driver,
320
+ bfs_origin_node_uuids,
321
+ search_filter,
322
+ config.bfs_max_depth,
323
+ group_ids,
324
+ 2 * limit,
325
+ )
326
+ )
327
+
328
+ # Execute only the configured search methods
329
+ search_results: list[list[EntityNode]] = []
330
+ if search_tasks:
331
+ search_results = list(await semaphore_gather(*search_tasks))
310
332
 
311
333
  if NodeSearchMethod.bfs in config.search_methods and bfs_origin_node_uuids is None:
312
334
  origin_node_uuids = [node.uuid for result in search_results for node in result]
@@ -33,7 +33,8 @@ async def get_community_clusters(
33
33
  if group_ids is None:
34
34
  group_id_values, _, _ = await driver.execute_query(
35
35
  """
36
- MATCH (n:Entity WHERE n.group_id IS NOT NULL)
36
+ MATCH (n:Entity)
37
+ WHERE n.group_id IS NOT NULL
37
38
  RETURN
38
39
  collect(DISTINCT n.group_id) AS group_ids
39
40
  """,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphiti-core
3
- Version: 0.18.6
3
+ Version: 0.18.8
4
4
  Summary: A temporal graph building library
5
5
  Project-URL: Homepage, https://help.getzep.com/graphiti/graphiti/overview
6
6
  Project-URL: Repository, https://github.com/getzep/graphiti
@@ -1,17 +1,17 @@
1
1
  graphiti_core/__init__.py,sha256=e5SWFkRiaUwfprYIeIgVIh7JDedNiloZvd3roU-0aDY,55
2
- graphiti_core/edges.py,sha256=KpgCzHlNgEcTTbUE62RAXKKi2YbG_fIwilE_W1TARYI,14864
2
+ graphiti_core/edges.py,sha256=NWBOXRka7r_JMmtUF_6xUCMKyVDlEzRSOdGlz_aYucU,15260
3
3
  graphiti_core/errors.py,sha256=cH_v9TPgEPeQE6GFOHIg5TvejpUCBddGarMY2Whxbwc,2707
4
4
  graphiti_core/graph_queries.py,sha256=gXQvspJHpM5LRJ5HBJgr0Zw-AhHkqweCoq06wfyZ_bc,5407
5
- graphiti_core/graphiti.py,sha256=KH1AN9eIHR-BToZO1HjYpIdz2e7qKaB6DzBM_mZVJkU,40953
5
+ graphiti_core/graphiti.py,sha256=R6VrGfPcvgPhaZZsfxb_EXM6bSYLWW5iALggfwkU2oA,40834
6
6
  graphiti_core/graphiti_types.py,sha256=C_p2XwScQlCzo7ets097TrSLs9ATxPZQ4WCsxDS7QHc,1066
7
7
  graphiti_core/helpers.py,sha256=oKcOQE_bvsdhBpPr1Ia2tylBq1svj3X1oBMSR7qdo00,5331
8
- graphiti_core/nodes.py,sha256=7K5fiEG8iTgB0rqk_IcC9K--5ycTwmvSvWEwZU1E_zU,18123
8
+ graphiti_core/nodes.py,sha256=aGCAoKWYPEr0wiC6UoxpIs7GxA4MXxugHCZtdfV3iwk,19128
9
9
  graphiti_core/py.typed,sha256=vlmmzQOt7bmeQl9L3XJP4W6Ry0iiELepnOrinKz5KQg,79
10
10
  graphiti_core/cross_encoder/__init__.py,sha256=hry59vz21x-AtGZ0MJ7ugw0HTwJkXiddpp_Yqnwsen0,723
11
11
  graphiti_core/cross_encoder/bge_reranker_client.py,sha256=y3TfFxZh0Yvj6HUShmfUm6MC7OPXwWUlv1Qe5HF3S3I,1797
12
12
  graphiti_core/cross_encoder/client.py,sha256=KLsbfWKOEaAV3adFe3XZlAeb-gje9_sVKCVZTaJP3ac,1441
13
13
  graphiti_core/cross_encoder/gemini_reranker_client.py,sha256=hmITG5YIib52nrKvINwRi4xTfAO1U4jCCaEVIwImHw0,6208
14
- graphiti_core/cross_encoder/openai_reranker_client.py,sha256=hoaGyu9nCNMJyP8si0Bha5Q9CFszfiHQmLgE9IsX7sY,4653
14
+ graphiti_core/cross_encoder/openai_reranker_client.py,sha256=WHMl6Q6gEslR2EzjwpFSZt2Kh6bnu8alkLvzmi0MDtg,4674
15
15
  graphiti_core/driver/__init__.py,sha256=kCWimqQU19airu5gKwCmZtZuXkDfaQfKSUhMDoL-rTA,626
16
16
  graphiti_core/driver/driver.py,sha256=XFJzkyZKiqhwwW6G9enB2ouWxNB53PU58nhSCW_LOIc,2331
17
17
  graphiti_core/driver/falkordb_driver.py,sha256=YLNuPvPBM7Pgr3Pv9gDuTVDGeDgHvEg8xD58uDYNweM,6766
@@ -38,10 +38,10 @@ graphiti_core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
38
38
  graphiti_core/models/edges/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  graphiti_core/models/edges/edge_db_queries.py,sha256=OBFqT9m6JDmGwpqe5TkcaCT2KxUGdW8h4yIsoacB5Mw,4661
40
40
  graphiti_core/models/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- graphiti_core/models/nodes/node_db_queries.py,sha256=ADPkZzS4tq5i-8zvkocoiuOiDi64d5F2ChEY_JwLOwQ,4378
41
+ graphiti_core/models/nodes/node_db_queries.py,sha256=XIaBTBR0UPw765cCcyu0oM1Q5Yv2gSud972xKpIibzA,4386
42
42
  graphiti_core/prompts/__init__.py,sha256=EA-x9xUki9l8wnu2l8ek_oNf75-do5tq5hVq7Zbv8Kw,101
43
43
  graphiti_core/prompts/dedupe_edges.py,sha256=WRXQi7JQZdIfKDICWyU7Wbs5WyD_KBblLBSeKdbLyuk,5914
44
- graphiti_core/prompts/dedupe_nodes.py,sha256=rI6SlYO84jVAGtFfarFWXR3_YWlsqXaq-6jmaq5Xy-w,8234
44
+ graphiti_core/prompts/dedupe_nodes.py,sha256=eYDk0axHEKLjZS2tKlT4Zy1fW9EJkn6EnrJLSN0fvAY,8235
45
45
  graphiti_core/prompts/eval.py,sha256=ijwxbE87G678imdhfPvRujepQMq_JZ3XHX4vOAcVnVI,5507
46
46
  graphiti_core/prompts/extract_edge_dates.py,sha256=3Drs3CmvP0gJN5BidWSxrNvLet3HPoTybU3BUIAoc0Y,4218
47
47
  graphiti_core/prompts/extract_edges.py,sha256=SbTB3dnvZ4vDy9aXMR-A3_RWUSk6CspaD7wwa_eXoys,6812
@@ -52,7 +52,7 @@ graphiti_core/prompts/models.py,sha256=NgxdbPHJpBEcpbXovKyScgpBc73Q-GIW-CBDlBtDj
52
52
  graphiti_core/prompts/prompt_helpers.py,sha256=gMDDNqBpxcnTO9psJQm7QU7M6OQgRumFq4oGYiycrfM,795
53
53
  graphiti_core/prompts/summarize_nodes.py,sha256=tn6LPEv_nNFLjKuT_FB_st7TAIYOEUOg9QR5YG7PpMA,4437
54
54
  graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- graphiti_core/search/search.py,sha256=u-kTmSu3VlRHYlQhuYsbwDQ-AKKCp3BZ9JZNRv3ttVY,16720
55
+ graphiti_core/search/search.py,sha256=TnBtwqL0dWADBZqQT_ymlJm2qA2Llj-0SwS8vS6nH-0,17464
56
56
  graphiti_core/search/search_config.py,sha256=v_rUHsu1yo5OuPfEm21lSuXexQs-o8qYwSSemW2QWhU,4165
57
57
  graphiti_core/search/search_config_recipes.py,sha256=4GquRphHhJlpXQhAZOySYnCzBWYoTwxlJj44eTOavZQ,7443
58
58
  graphiti_core/search/search_filters.py,sha256=BkkVpweN5U_ld5n2GyQrljwGw4QwbFphE7FT0jpTys8,7772
@@ -64,14 +64,14 @@ graphiti_core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
64
64
  graphiti_core/utils/bulk_utils.py,sha256=xIn2UMwEw1MOcpaV0QLY59fyacTH0J7kvQtuF2rJfgk,15168
65
65
  graphiti_core/utils/datetime_utils.py,sha256=Ti-2tnrDFRzBsbfblzsHybsM3jaDLP4-VT2t0VhpIzU,1357
66
66
  graphiti_core/utils/maintenance/__init__.py,sha256=vW4H1KyapTl-OOz578uZABYcpND4wPx3Vt6aAPaXh78,301
67
- graphiti_core/utils/maintenance/community_operations.py,sha256=wnMUwS_qieP2ErHdTUuBn3ti6vJO_jjLnWSwjYyS78M,10484
67
+ graphiti_core/utils/maintenance/community_operations.py,sha256=gHqsRtX19LVH88B70GNTGnnq5Ic5kcm0Gu24wKP3-yQ,10492
68
68
  graphiti_core/utils/maintenance/edge_operations.py,sha256=RHMUquo-BSkwvtWZBMZHzNZ-WtgCOuwz6cGLxD8Q46g,18773
69
69
  graphiti_core/utils/maintenance/graph_data_operations.py,sha256=joNZxL_OIFdXHBGkwtB57ar7nGmbq4Z8ItgqFWL45kw,4530
70
70
  graphiti_core/utils/maintenance/node_operations.py,sha256=SU-u69HrVJNvDsYC6kylcq78WUuYBiqUWHJdADNKcR4,13475
71
71
  graphiti_core/utils/maintenance/temporal_operations.py,sha256=IIaVtShpVkOYe6haxz3a1x3v54-MzaEXG8VsxFUNeoY,3582
72
72
  graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  graphiti_core/utils/ontology_utils/entity_types_utils.py,sha256=4eVgxLWY6Q8k9cRJ5pW59IYF--U4nXZsZIGOVb_yHfQ,1285
74
- graphiti_core-0.18.6.dist-info/METADATA,sha256=XISf2wyyjlDnlXhjH1cll9JjmTOoYuVKoIh1NGbDPMc,24613
75
- graphiti_core-0.18.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
- graphiti_core-0.18.6.dist-info/licenses/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
77
- graphiti_core-0.18.6.dist-info/RECORD,,
74
+ graphiti_core-0.18.8.dist-info/METADATA,sha256=ob__yXgSiHLeiccQn-nLA5TlsdTQKMYkrrZk3eHfcV0,24613
75
+ graphiti_core-0.18.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
76
+ graphiti_core-0.18.8.dist-info/licenses/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
77
+ graphiti_core-0.18.8.dist-info/RECORD,,