graphiti-core 0.3.14__tar.gz → 0.3.16__tar.gz

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.

Files changed (53) hide show
  1. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/PKG-INFO +1 -1
  2. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/edges.py +13 -13
  3. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/helpers.py +3 -0
  4. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/nodes.py +13 -13
  5. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/search/search_utils.py +90 -70
  6. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/community_operations.py +5 -5
  7. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/graph_data_operations.py +1 -1
  8. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/pyproject.toml +1 -1
  9. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/LICENSE +0 -0
  10. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/README.md +0 -0
  11. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/__init__.py +0 -0
  12. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/embedder/__init__.py +0 -0
  13. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/embedder/client.py +0 -0
  14. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/embedder/openai.py +0 -0
  15. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/embedder/voyage.py +0 -0
  16. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/errors.py +0 -0
  17. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/graphiti.py +0 -0
  18. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/__init__.py +0 -0
  19. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/anthropic_client.py +0 -0
  20. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/client.py +0 -0
  21. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/config.py +0 -0
  22. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/errors.py +0 -0
  23. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/groq_client.py +0 -0
  24. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/openai_client.py +0 -0
  25. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/llm_client/utils.py +0 -0
  26. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/models/__init__.py +0 -0
  27. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/models/edges/__init__.py +0 -0
  28. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/models/edges/edge_db_queries.py +0 -0
  29. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/models/nodes/__init__.py +0 -0
  30. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/models/nodes/node_db_queries.py +0 -0
  31. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/__init__.py +0 -0
  32. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/dedupe_edges.py +0 -0
  33. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/dedupe_nodes.py +0 -0
  34. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/eval.py +0 -0
  35. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/extract_edge_dates.py +0 -0
  36. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/extract_edges.py +0 -0
  37. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/extract_nodes.py +0 -0
  38. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/invalidate_edges.py +0 -0
  39. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/lib.py +0 -0
  40. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/models.py +0 -0
  41. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/prompts/summarize_nodes.py +0 -0
  42. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/py.typed +0 -0
  43. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/search/__init__.py +0 -0
  44. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/search/search.py +0 -0
  45. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/search/search_config.py +0 -0
  46. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/search/search_config_recipes.py +0 -0
  47. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/__init__.py +0 -0
  48. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/bulk_utils.py +0 -0
  49. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/__init__.py +0 -0
  50. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/edge_operations.py +0 -0
  51. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/node_operations.py +0 -0
  52. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/temporal_operations.py +0 -0
  53. {graphiti_core-0.3.14 → graphiti_core-0.3.16}/graphiti_core/utils/maintenance/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: graphiti-core
3
- Version: 0.3.14
3
+ Version: 0.3.16
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -54,7 +54,7 @@ class Edge(BaseModel, ABC):
54
54
  DELETE e
55
55
  """,
56
56
  uuid=self.uuid,
57
- _database=DEFAULT_DATABASE,
57
+ database_=DEFAULT_DATABASE,
58
58
  )
59
59
 
60
60
  logger.debug(f'Deleted Edge: {self.uuid}')
@@ -82,7 +82,7 @@ class EpisodicEdge(Edge):
82
82
  uuid=self.uuid,
83
83
  group_id=self.group_id,
84
84
  created_at=self.created_at,
85
- _database=DEFAULT_DATABASE,
85
+ database_=DEFAULT_DATABASE,
86
86
  )
87
87
 
88
88
  logger.debug(f'Saved edge to neo4j: {self.uuid}')
@@ -102,7 +102,7 @@ class EpisodicEdge(Edge):
102
102
  e.created_at AS created_at
103
103
  """,
104
104
  uuid=uuid,
105
- _database=DEFAULT_DATABASE,
105
+ database_=DEFAULT_DATABASE,
106
106
  )
107
107
 
108
108
  edges = [get_episodic_edge_from_record(record) for record in records]
@@ -125,7 +125,7 @@ class EpisodicEdge(Edge):
125
125
  e.created_at AS created_at
126
126
  """,
127
127
  uuids=uuids,
128
- _database=DEFAULT_DATABASE,
128
+ database_=DEFAULT_DATABASE,
129
129
  )
130
130
 
131
131
  edges = [get_episodic_edge_from_record(record) for record in records]
@@ -148,7 +148,7 @@ class EpisodicEdge(Edge):
148
148
  e.created_at AS created_at
149
149
  """,
150
150
  group_ids=group_ids,
151
- _database=DEFAULT_DATABASE,
151
+ database_=DEFAULT_DATABASE,
152
152
  )
153
153
 
154
154
  edges = [get_episodic_edge_from_record(record) for record in records]
@@ -202,7 +202,7 @@ class EntityEdge(Edge):
202
202
  expired_at=self.expired_at,
203
203
  valid_at=self.valid_at,
204
204
  invalid_at=self.invalid_at,
205
- _database=DEFAULT_DATABASE,
205
+ database_=DEFAULT_DATABASE,
206
206
  )
207
207
 
208
208
  logger.debug(f'Saved edge to neo4j: {self.uuid}')
@@ -229,7 +229,7 @@ class EntityEdge(Edge):
229
229
  e.invalid_at AS invalid_at
230
230
  """,
231
231
  uuid=uuid,
232
- _database=DEFAULT_DATABASE,
232
+ database_=DEFAULT_DATABASE,
233
233
  )
234
234
 
235
235
  edges = [get_entity_edge_from_record(record) for record in records]
@@ -259,7 +259,7 @@ class EntityEdge(Edge):
259
259
  e.invalid_at AS invalid_at
260
260
  """,
261
261
  uuids=uuids,
262
- _database=DEFAULT_DATABASE,
262
+ database_=DEFAULT_DATABASE,
263
263
  )
264
264
 
265
265
  edges = [get_entity_edge_from_record(record) for record in records]
@@ -289,7 +289,7 @@ class EntityEdge(Edge):
289
289
  e.invalid_at AS invalid_at
290
290
  """,
291
291
  group_ids=group_ids,
292
- _database=DEFAULT_DATABASE,
292
+ database_=DEFAULT_DATABASE,
293
293
  )
294
294
 
295
295
  edges = [get_entity_edge_from_record(record) for record in records]
@@ -308,7 +308,7 @@ class CommunityEdge(Edge):
308
308
  uuid=self.uuid,
309
309
  group_id=self.group_id,
310
310
  created_at=self.created_at,
311
- _database=DEFAULT_DATABASE,
311
+ database_=DEFAULT_DATABASE,
312
312
  )
313
313
 
314
314
  logger.debug(f'Saved edge to neo4j: {self.uuid}')
@@ -328,7 +328,7 @@ class CommunityEdge(Edge):
328
328
  e.created_at AS created_at
329
329
  """,
330
330
  uuid=uuid,
331
- _database=DEFAULT_DATABASE,
331
+ database_=DEFAULT_DATABASE,
332
332
  )
333
333
 
334
334
  edges = [get_community_edge_from_record(record) for record in records]
@@ -349,7 +349,7 @@ class CommunityEdge(Edge):
349
349
  e.created_at AS created_at
350
350
  """,
351
351
  uuids=uuids,
352
- _database=DEFAULT_DATABASE,
352
+ database_=DEFAULT_DATABASE,
353
353
  )
354
354
 
355
355
  edges = [get_community_edge_from_record(record) for record in records]
@@ -370,7 +370,7 @@ class CommunityEdge(Edge):
370
370
  e.created_at AS created_at
371
371
  """,
372
372
  group_ids=group_ids,
373
- _database=DEFAULT_DATABASE,
373
+ database_=DEFAULT_DATABASE,
374
374
  )
375
375
 
376
376
  edges = [get_community_edge_from_record(record) for record in records]
@@ -18,8 +18,11 @@ import os
18
18
  from datetime import datetime
19
19
 
20
20
  import numpy as np
21
+ from dotenv import load_dotenv
21
22
  from neo4j import time as neo4j_time
22
23
 
24
+ load_dotenv()
25
+
23
26
  DEFAULT_DATABASE = os.getenv('DEFAULT_DATABASE', None)
24
27
 
25
28
 
@@ -90,7 +90,7 @@ class Node(BaseModel, ABC):
90
90
  DETACH DELETE n
91
91
  """,
92
92
  uuid=self.uuid,
93
- _database=DEFAULT_DATABASE,
93
+ database_=DEFAULT_DATABASE,
94
94
  )
95
95
 
96
96
  logger.debug(f'Deleted Node: {self.uuid}')
@@ -136,7 +136,7 @@ class EpisodicNode(Node):
136
136
  created_at=self.created_at,
137
137
  valid_at=self.valid_at,
138
138
  source=self.source.value,
139
- _database=DEFAULT_DATABASE,
139
+ database_=DEFAULT_DATABASE,
140
140
  )
141
141
 
142
142
  logger.debug(f'Saved Node to neo4j: {self.uuid}')
@@ -158,7 +158,7 @@ class EpisodicNode(Node):
158
158
  e.source AS source
159
159
  """,
160
160
  uuid=uuid,
161
- _database=DEFAULT_DATABASE,
161
+ database_=DEFAULT_DATABASE,
162
162
  )
163
163
 
164
164
  episodes = [get_episodic_node_from_record(record) for record in records]
@@ -184,7 +184,7 @@ class EpisodicNode(Node):
184
184
  e.source AS source
185
185
  """,
186
186
  uuids=uuids,
187
- _database=DEFAULT_DATABASE,
187
+ database_=DEFAULT_DATABASE,
188
188
  )
189
189
 
190
190
  episodes = [get_episodic_node_from_record(record) for record in records]
@@ -207,7 +207,7 @@ class EpisodicNode(Node):
207
207
  e.source AS source
208
208
  """,
209
209
  group_ids=group_ids,
210
- _database=DEFAULT_DATABASE,
210
+ database_=DEFAULT_DATABASE,
211
211
  )
212
212
 
213
213
  episodes = [get_episodic_node_from_record(record) for record in records]
@@ -237,7 +237,7 @@ class EntityNode(Node):
237
237
  summary=self.summary,
238
238
  name_embedding=self.name_embedding,
239
239
  created_at=self.created_at,
240
- _database=DEFAULT_DATABASE,
240
+ database_=DEFAULT_DATABASE,
241
241
  )
242
242
 
243
243
  logger.debug(f'Saved Node to neo4j: {self.uuid}')
@@ -258,7 +258,7 @@ class EntityNode(Node):
258
258
  n.summary AS summary
259
259
  """,
260
260
  uuid=uuid,
261
- _database=DEFAULT_DATABASE,
261
+ database_=DEFAULT_DATABASE,
262
262
  )
263
263
 
264
264
  nodes = [get_entity_node_from_record(record) for record in records]
@@ -282,7 +282,7 @@ class EntityNode(Node):
282
282
  n.summary AS summary
283
283
  """,
284
284
  uuids=uuids,
285
- _database=DEFAULT_DATABASE,
285
+ database_=DEFAULT_DATABASE,
286
286
  )
287
287
 
288
288
  nodes = [get_entity_node_from_record(record) for record in records]
@@ -303,7 +303,7 @@ class EntityNode(Node):
303
303
  n.summary AS summary
304
304
  """,
305
305
  group_ids=group_ids,
306
- _database=DEFAULT_DATABASE,
306
+ database_=DEFAULT_DATABASE,
307
307
  )
308
308
 
309
309
  nodes = [get_entity_node_from_record(record) for record in records]
@@ -324,7 +324,7 @@ class CommunityNode(Node):
324
324
  summary=self.summary,
325
325
  name_embedding=self.name_embedding,
326
326
  created_at=self.created_at,
327
- _database=DEFAULT_DATABASE,
327
+ database_=DEFAULT_DATABASE,
328
328
  )
329
329
 
330
330
  logger.debug(f'Saved Node to neo4j: {self.uuid}')
@@ -354,7 +354,7 @@ class CommunityNode(Node):
354
354
  n.summary AS summary
355
355
  """,
356
356
  uuid=uuid,
357
- _database=DEFAULT_DATABASE,
357
+ database_=DEFAULT_DATABASE,
358
358
  )
359
359
 
360
360
  nodes = [get_community_node_from_record(record) for record in records]
@@ -378,7 +378,7 @@ class CommunityNode(Node):
378
378
  n.summary AS summary
379
379
  """,
380
380
  uuids=uuids,
381
- _database=DEFAULT_DATABASE,
381
+ database_=DEFAULT_DATABASE,
382
382
  )
383
383
 
384
384
  communities = [get_community_node_from_record(record) for record in records]
@@ -399,7 +399,7 @@ class CommunityNode(Node):
399
399
  n.summary AS summary
400
400
  """,
401
401
  group_ids=group_ids,
402
- _database=DEFAULT_DATABASE,
402
+ database_=DEFAULT_DATABASE,
403
403
  )
404
404
 
405
405
  communities = [get_community_node_from_record(record) for record in records]
@@ -79,20 +79,21 @@ async def get_mentioned_nodes(
79
79
  driver: AsyncDriver, episodes: list[EpisodicNode]
80
80
  ) -> list[EntityNode]:
81
81
  episode_uuids = [episode.uuid for episode in episodes]
82
- records, _, _ = await driver.execute_query(
83
- """
84
- MATCH (episode:Episodic)-[:MENTIONS]->(n:Entity) WHERE episode.uuid IN $uuids
85
- RETURN DISTINCT
86
- n.uuid As uuid,
87
- n.group_id AS group_id,
88
- n.name AS name,
89
- n.name_embedding AS name_embedding
90
- n.created_at AS created_at,
91
- n.summary AS summary
92
- """,
93
- uuids=episode_uuids,
94
- _database=DEFAULT_DATABASE,
95
- )
82
+ async with driver.session(database=DEFAULT_DATABASE) as session:
83
+ result = await session.run(
84
+ """
85
+ MATCH (episode:Episodic)-[:MENTIONS]->(n:Entity) WHERE episode.uuid IN $uuids
86
+ RETURN DISTINCT
87
+ n.uuid As uuid,
88
+ n.group_id AS group_id,
89
+ n.name AS name,
90
+ n.name_embedding AS name_embedding,
91
+ n.created_at AS created_at,
92
+ n.summary AS summary
93
+ """,
94
+ {'uuids': episode_uuids},
95
+ )
96
+ records = [record async for record in result]
96
97
 
97
98
  nodes = [get_entity_node_from_record(record) for record in records]
98
99
 
@@ -103,8 +104,9 @@ async def get_communities_by_nodes(
103
104
  driver: AsyncDriver, nodes: list[EntityNode]
104
105
  ) -> list[CommunityNode]:
105
106
  node_uuids = [node.uuid for node in nodes]
106
- records, _, _ = await driver.execute_query(
107
- """
107
+ async with driver.session(database=DEFAULT_DATABASE) as session:
108
+ result = await session.run(
109
+ """
108
110
  MATCH (c:Community)-[:HAS_MEMBER]->(n:Entity) WHERE n.uuid IN $uuids
109
111
  RETURN DISTINCT
110
112
  c.uuid As uuid,
@@ -114,9 +116,9 @@ async def get_communities_by_nodes(
114
116
  c.created_at AS created_at,
115
117
  c.summary AS summary
116
118
  """,
117
- uuids=node_uuids,
118
- _database=DEFAULT_DATABASE,
119
- )
119
+ {'uuids': node_uuids},
120
+ )
121
+ records = [record async for record in result]
120
122
 
121
123
  communities = [get_community_node_from_record(record) for record in records]
122
124
 
@@ -156,15 +158,18 @@ async def edge_fulltext_search(
156
158
  ORDER BY score DESC LIMIT $limit
157
159
  """)
158
160
 
159
- records, _, _ = await driver.execute_query(
160
- cypher_query,
161
- query=fuzzy_query,
162
- source_uuid=source_node_uuid,
163
- target_uuid=target_node_uuid,
164
- group_ids=group_ids,
165
- limit=limit,
166
- _database=DEFAULT_DATABASE,
167
- )
161
+ async with driver.session(database=DEFAULT_DATABASE) as session:
162
+ result = await session.run(
163
+ cypher_query,
164
+ {
165
+ 'query': fuzzy_query,
166
+ 'source_uuid': source_node_uuid,
167
+ 'target_uuid': target_node_uuid,
168
+ 'group_ids': group_ids,
169
+ 'limit': limit,
170
+ },
171
+ )
172
+ records = [record async for record in result]
168
173
 
169
174
  edges = [get_entity_edge_from_record(record) for record in records]
170
175
 
@@ -206,16 +211,19 @@ async def edge_similarity_search(
206
211
  LIMIT $limit
207
212
  """)
208
213
 
209
- records, _, _ = await driver.execute_query(
210
- query,
211
- search_vector=search_vector,
212
- source_uuid=source_node_uuid,
213
- target_uuid=target_node_uuid,
214
- group_ids=group_ids,
215
- limit=limit,
216
- min_score=min_score,
217
- _database=DEFAULT_DATABASE,
218
- )
214
+ async with driver.session(database=DEFAULT_DATABASE) as session:
215
+ result = await session.run(
216
+ query,
217
+ {
218
+ 'search_vector': search_vector,
219
+ 'source_uuid': source_node_uuid,
220
+ 'target_uuid': target_node_uuid,
221
+ 'group_ids': group_ids,
222
+ 'limit': limit,
223
+ 'min_score': min_score,
224
+ },
225
+ )
226
+ records = [record async for record in result]
219
227
 
220
228
  edges = [get_entity_edge_from_record(record) for record in records]
221
229
 
@@ -233,8 +241,9 @@ async def node_fulltext_search(
233
241
  if fuzzy_query == '':
234
242
  return []
235
243
 
236
- records, _, _ = await driver.execute_query(
237
- """
244
+ async with driver.session(database=DEFAULT_DATABASE) as session:
245
+ result = await session.run(
246
+ """
238
247
  CALL db.index.fulltext.queryNodes("node_name_and_summary", $query)
239
248
  YIELD node AS n, score
240
249
  RETURN
@@ -247,11 +256,13 @@ async def node_fulltext_search(
247
256
  ORDER BY score DESC
248
257
  LIMIT $limit
249
258
  """,
250
- query=fuzzy_query,
251
- group_ids=group_ids,
252
- limit=limit,
253
- _database=DEFAULT_DATABASE,
254
- )
259
+ {
260
+ 'query': fuzzy_query,
261
+ 'group_ids': group_ids,
262
+ 'limit': limit,
263
+ },
264
+ )
265
+ records = [record async for record in result]
255
266
  nodes = [get_entity_node_from_record(record) for record in records]
256
267
 
257
268
  return nodes
@@ -265,8 +276,9 @@ async def node_similarity_search(
265
276
  min_score: float = DEFAULT_MIN_SCORE,
266
277
  ) -> list[EntityNode]:
267
278
  # vector similarity search over entity names
268
- records, _, _ = await driver.execute_query(
269
- """
279
+ async with driver.session(database=DEFAULT_DATABASE) as session:
280
+ result = await session.run(
281
+ """
270
282
  CYPHER runtime = parallel parallelRuntimeSupport=all
271
283
  MATCH (n:Entity)
272
284
  WHERE $group_ids IS NULL OR n.group_id IN $group_ids
@@ -282,12 +294,14 @@ async def node_similarity_search(
282
294
  ORDER BY score DESC
283
295
  LIMIT $limit
284
296
  """,
285
- search_vector=search_vector,
286
- group_ids=group_ids,
287
- limit=limit,
288
- min_score=min_score,
289
- _database=DEFAULT_DATABASE,
290
- )
297
+ {
298
+ 'search_vector': search_vector,
299
+ 'group_ids': group_ids,
300
+ 'limit': limit,
301
+ 'min_score': min_score,
302
+ },
303
+ )
304
+ records = [record async for record in result]
291
305
  nodes = [get_entity_node_from_record(record) for record in records]
292
306
 
293
307
  return nodes
@@ -304,8 +318,9 @@ async def community_fulltext_search(
304
318
  if fuzzy_query == '':
305
319
  return []
306
320
 
307
- records, _, _ = await driver.execute_query(
308
- """
321
+ async with driver.session(database=DEFAULT_DATABASE) as session:
322
+ result = await session.run(
323
+ """
309
324
  CALL db.index.fulltext.queryNodes("community_name", $query)
310
325
  YIELD node AS comm, score
311
326
  RETURN
@@ -318,11 +333,13 @@ async def community_fulltext_search(
318
333
  ORDER BY score DESC
319
334
  LIMIT $limit
320
335
  """,
321
- query=fuzzy_query,
322
- group_ids=group_ids,
323
- limit=limit,
324
- _database=DEFAULT_DATABASE,
325
- )
336
+ {
337
+ 'query': fuzzy_query,
338
+ 'group_ids': group_ids,
339
+ 'limit': limit,
340
+ },
341
+ )
342
+ records = [record async for record in result]
326
343
  communities = [get_community_node_from_record(record) for record in records]
327
344
 
328
345
  return communities
@@ -336,8 +353,9 @@ async def community_similarity_search(
336
353
  min_score=DEFAULT_MIN_SCORE,
337
354
  ) -> list[CommunityNode]:
338
355
  # vector similarity search over entity names
339
- records, _, _ = await driver.execute_query(
340
- """
356
+ async with driver.session(database=DEFAULT_DATABASE) as session:
357
+ result = await session.run(
358
+ """
341
359
  CYPHER runtime = parallel parallelRuntimeSupport=all
342
360
  MATCH (comm:Community)
343
361
  WHERE ($group_ids IS NULL OR comm.group_id IN $group_ids)
@@ -353,12 +371,14 @@ async def community_similarity_search(
353
371
  ORDER BY score DESC
354
372
  LIMIT $limit
355
373
  """,
356
- search_vector=search_vector,
357
- group_ids=group_ids,
358
- limit=limit,
359
- min_score=min_score,
360
- _database=DEFAULT_DATABASE,
361
- )
374
+ {
375
+ 'search_vector': search_vector,
376
+ 'group_ids': group_ids,
377
+ 'limit': limit,
378
+ 'min_score': min_score,
379
+ },
380
+ )
381
+ records = [record async for record in result]
362
382
  communities = [get_community_node_from_record(record) for record in records]
363
383
 
364
384
  return communities
@@ -549,7 +569,7 @@ async def node_distance_reranker(
549
569
  query,
550
570
  node_uuid=uuid,
551
571
  center_uuid=center_node_uuid,
552
- _database=DEFAULT_DATABASE,
572
+ database_=DEFAULT_DATABASE,
553
573
  )
554
574
  for uuid in filtered_uuids
555
575
  ]
@@ -586,7 +606,7 @@ async def episode_mentions_reranker(driver: AsyncDriver, node_uuids: list[list[s
586
606
  driver.execute_query(
587
607
  query,
588
608
  node_uuid=uuid,
589
- _database=DEFAULT_DATABASE,
609
+ database_=DEFAULT_DATABASE,
590
610
  )
591
611
  for uuid in sorted_uuids
592
612
  ]
@@ -40,7 +40,7 @@ async def get_community_clusters(
40
40
  RETURN
41
41
  collect(DISTINCT n.group_id) AS group_ids
42
42
  """,
43
- _database=DEFAULT_DATABASE,
43
+ database_=DEFAULT_DATABASE,
44
44
  )
45
45
 
46
46
  group_ids = group_id_values[0]['group_ids']
@@ -59,7 +59,7 @@ async def get_community_clusters(
59
59
  """,
60
60
  uuid=node.uuid,
61
61
  group_id=group_id,
62
- _database=DEFAULT_DATABASE,
62
+ database_=DEFAULT_DATABASE,
63
63
  )
64
64
 
65
65
  projection[node.uuid] = [
@@ -223,7 +223,7 @@ async def remove_communities(driver: AsyncDriver):
223
223
  MATCH (c:Community)
224
224
  DETACH DELETE c
225
225
  """,
226
- _database=DEFAULT_DATABASE,
226
+ database_=DEFAULT_DATABASE,
227
227
  )
228
228
 
229
229
 
@@ -243,7 +243,7 @@ async def determine_entity_community(
243
243
  c.summary AS summary
244
244
  """,
245
245
  entity_uuid=entity.uuid,
246
- _database=DEFAULT_DATABASE,
246
+ database_=DEFAULT_DATABASE,
247
247
  )
248
248
 
249
249
  if len(records) > 0:
@@ -262,7 +262,7 @@ async def determine_entity_community(
262
262
  c.summary AS summary
263
263
  """,
264
264
  entity_uuid=entity.uuid,
265
- _database=DEFAULT_DATABASE,
265
+ database_=DEFAULT_DATABASE,
266
266
  )
267
267
 
268
268
  communities: list[CommunityNode] = [
@@ -35,7 +35,7 @@ async def build_indices_and_constraints(driver: AsyncDriver, delete_existing: bo
35
35
  """
36
36
  SHOW INDEXES YIELD name
37
37
  """,
38
- _database=DEFAULT_DATABASE,
38
+ database_=DEFAULT_DATABASE,
39
39
  )
40
40
  index_names = [record['name'] for record in records]
41
41
  await asyncio.gather(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "graphiti-core"
3
- version = "0.3.14"
3
+ version = "0.3.16"
4
4
  description = "A temporal graph building library"
5
5
  authors = [
6
6
  "Paul Paliychuk <paul@getzep.com>",
File without changes
File without changes