graphiti-core 0.11.6rc5__py3-none-any.whl → 0.11.6rc7__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/helpers.py CHANGED
@@ -18,6 +18,7 @@ import asyncio
18
18
  import os
19
19
  from collections.abc import Coroutine
20
20
  from datetime import datetime
21
+ from typing import Any
21
22
 
22
23
  import numpy as np
23
24
  from dotenv import load_dotenv
@@ -91,11 +92,27 @@ def normalize_l2(embedding: list[float]):
91
92
 
92
93
 
93
94
  # Use this instead of asyncio.gather() to bound coroutines
94
- async def semaphore_gather(*coroutines: Coroutine, max_coroutines: int = SEMAPHORE_LIMIT):
95
+ async def semaphore_gather(
96
+ *coroutines: Coroutine,
97
+ max_coroutines: int = SEMAPHORE_LIMIT,
98
+ ):
95
99
  semaphore = asyncio.Semaphore(max_coroutines)
96
100
 
97
- async def _wrap_coroutine(coroutine):
101
+ async def _wrap(coro: Coroutine) -> Any:
98
102
  async with semaphore:
99
- return await coroutine
100
-
101
- return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))
103
+ return await coro
104
+
105
+ results = []
106
+ batch = []
107
+ for coroutine in coroutines:
108
+ batch.append(_wrap(coroutine))
109
+ # once we hit max_coroutines, gather and clear the batch
110
+ if len(batch) >= max_coroutines:
111
+ results.extend(await asyncio.gather(*batch))
112
+ batch.clear()
113
+
114
+ # gather any remaining coroutines in the final batch
115
+ if batch:
116
+ results.extend(await asyncio.gather(*batch))
117
+
118
+ return results
@@ -458,14 +458,10 @@ async def community_search(
458
458
  config.mmr_lambda,
459
459
  )
460
460
  elif config.reranker == CommunityReranker.cross_encoder:
461
- summary_to_uuid_map = {
462
- node.summary: node.uuid for result in search_results for node in result
463
- }
464
- reranked_summaries = await cross_encoder.rank(query, list(summary_to_uuid_map.keys()))
461
+ name_to_uuid_map = {node.name: node.uuid for result in search_results for node in result}
462
+ reranked_nodes = await cross_encoder.rank(query, list(name_to_uuid_map.keys()))
465
463
  reranked_uuids = [
466
- summary_to_uuid_map[fact]
467
- for fact, score in reranked_summaries
468
- if score >= reranker_min_score
464
+ name_to_uuid_map[name] for name, score in reranked_nodes if score >= reranker_min_score
469
465
  ]
470
466
 
471
467
  reranked_communities = [community_uuid_map[uuid] for uuid in reranked_uuids]
@@ -18,6 +18,7 @@ import logging
18
18
  from contextlib import suppress
19
19
  from time import time
20
20
  from typing import Any
21
+ from uuid import uuid4
21
22
 
22
23
  import pydantic
23
24
  from pydantic import BaseModel, Field
@@ -395,7 +396,8 @@ async def extract_attributes_from_node(
395
396
  Field(description=field_info.description),
396
397
  )
397
398
 
398
- entity_attributes_model = pydantic.create_model('EntityAttributes', **attributes_definitions)
399
+ unique_model_name = f'EntityAttributes_{uuid4().hex}'
400
+ entity_attributes_model = pydantic.create_model(unique_model_name, **attributes_definitions)
399
401
 
400
402
  summary_context: dict[str, Any] = {
401
403
  'node': node_context,
@@ -411,12 +413,10 @@ async def extract_attributes_from_node(
411
413
  )
412
414
 
413
415
  node.summary = llm_response.get('summary', node.summary)
414
- node.name = llm_response.get('name', node.name)
415
416
  node_attributes = {key: value for key, value in llm_response.items()}
416
417
 
417
418
  with suppress(KeyError):
418
419
  del node_attributes['summary']
419
- del node_attributes['name']
420
420
 
421
421
  node.attributes.update(node_attributes)
422
422
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: graphiti-core
3
- Version: 0.11.6rc5
3
+ Version: 0.11.6rc7
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -12,7 +12,7 @@ graphiti_core/embedder/voyage.py,sha256=gQhdcz2IYPSyOcDn3w8aHToVS3KQhyZrUBm4vqr3
12
12
  graphiti_core/errors.py,sha256=Nib1uQx2cO_VOizupmRjpFfmuRg-hFAVqTtZAuBehR8,2405
13
13
  graphiti_core/graphiti.py,sha256=niRU1sZ2hf3a8WUPQAEIOsg8ixR_r_NUau5famfe1uM,27090
14
14
  graphiti_core/graphiti_types.py,sha256=46ueysKPwUCpxkMePHdCJLspfTImoZN7JiRwpz7cqd0,1013
15
- graphiti_core/helpers.py,sha256=Rj_ayM7hphlyY4v0ln_9vjFtr76aTjLVenYny0Wntwo,3086
15
+ graphiti_core/helpers.py,sha256=iRN1gFMrYa07C5MyaQkefiD5t0itfNddczyLmLIxRs0,3465
16
16
  graphiti_core/llm_client/__init__.py,sha256=PA80TSMeX-sUXITXEAxMDEt3gtfZgcJrGJUcyds1mSo,207
17
17
  graphiti_core/llm_client/anthropic_client.py,sha256=392rtkH_I7yOJUlQvjoOnS8Lz14WBP8egQ3OfRH0nFs,12481
18
18
  graphiti_core/llm_client/client.py,sha256=v_w5TBbDJYYADCXSs2r287g5Ami2Urma-GGEbHSI_Jg,5826
@@ -43,7 +43,7 @@ graphiti_core/prompts/prompt_helpers.py,sha256=-9TABwIcIQUVHcNANx6wIZd-FT2DgYKyG
43
43
  graphiti_core/prompts/summarize_nodes.py,sha256=tbg-AgWlzgFBeImKkZ28h2SpmqfPPqvN2Ol1Q71VF9Y,4146
44
44
  graphiti_core/py.typed,sha256=vlmmzQOt7bmeQl9L3XJP4W6Ry0iiELepnOrinKz5KQg,79
45
45
  graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- graphiti_core/search/search.py,sha256=coBT4SItmkmvtYqF6WPwXLgAA_8dk34bGWEV_X4N5fE,16275
46
+ graphiti_core/search/search.py,sha256=0VTvRNncQIfavhOBYl4p1A9Ielzb3eieKvrhz7Ka_SE,16209
47
47
  graphiti_core/search/search_config.py,sha256=VvKg6AB_RPhoe56DBBXHRBXHThAVJ_OLFCyq_yKof-A,3765
48
48
  graphiti_core/search/search_config_recipes.py,sha256=4GquRphHhJlpXQhAZOySYnCzBWYoTwxlJj44eTOavZQ,7443
49
49
  graphiti_core/search/search_filters.py,sha256=JkP7NbM4Dor27dne5vAuxbJic12dIJDtWJxNqmVuRec,5884
@@ -56,11 +56,11 @@ graphiti_core/utils/maintenance/__init__.py,sha256=vW4H1KyapTl-OOz578uZABYcpND4w
56
56
  graphiti_core/utils/maintenance/community_operations.py,sha256=TF-4eHuvMe_jMqvWg3swxK80zLLtOR0t1pmUUQlNulM,10067
57
57
  graphiti_core/utils/maintenance/edge_operations.py,sha256=vjeCUt_WlKZ3SRIIgaF9pqc8Na6ajLOzUIo2pWo7NyU,14756
58
58
  graphiti_core/utils/maintenance/graph_data_operations.py,sha256=BIJKc8tbvU4IjWxLgeotw57b1eE3Iw8YtV74j6eo4RQ,7493
59
- graphiti_core/utils/maintenance/node_operations.py,sha256=VMiDrzXryUV7-_btDVw87K3OawYeC9-9UqNQbfC5Bbo,15316
59
+ graphiti_core/utils/maintenance/node_operations.py,sha256=-gHQH2_jaAg6XYH33tC5Pna1B4VcGHyPTpaK0NY3xow,15308
60
60
  graphiti_core/utils/maintenance/temporal_operations.py,sha256=mJkw9xLB4W2BsLfC5POr0r-PHWL9SIfNj_l_xu0B5ug,3410
61
61
  graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  graphiti_core/utils/ontology_utils/entity_types_utils.py,sha256=QJX5cG0GSSNF_Mm_yrldr69wjVAbN_MxLhOSznz85Hk,1279
63
- graphiti_core-0.11.6rc5.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
64
- graphiti_core-0.11.6rc5.dist-info/METADATA,sha256=kY1fU6Ac1kaQqz8p5CIJBxOujLnoaUB1NTKPZI97pfU,15301
65
- graphiti_core-0.11.6rc5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
66
- graphiti_core-0.11.6rc5.dist-info/RECORD,,
63
+ graphiti_core-0.11.6rc7.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
64
+ graphiti_core-0.11.6rc7.dist-info/METADATA,sha256=Cni7Rvx1hdKkfI7590--qjIR8YA3Ht4yN71H0sNqeSw,15301
65
+ graphiti_core-0.11.6rc7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
66
+ graphiti_core-0.11.6rc7.dist-info/RECORD,,