graphiti-core 0.9.5__py3-none-any.whl → 0.9.6__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.

@@ -26,7 +26,7 @@ from graphiti_core.search.search_utils import (
26
26
  MAX_SEARCH_DEPTH,
27
27
  )
28
28
 
29
- DEFAULT_SEARCH_LIMIT = 20
29
+ DEFAULT_SEARCH_LIMIT = 10
30
30
 
31
31
 
32
32
  class EdgeSearchMethod(Enum):
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  """
16
16
 
17
+ import json
18
+
17
19
  from graphiti_core.edges import EntityEdge
18
20
  from graphiti_core.search.search_config import SearchResults
19
21
 
@@ -25,23 +27,37 @@ def format_edge_date_range(edge: EntityEdge) -> str:
25
27
 
26
28
  def search_results_to_context_string(search_results: SearchResults) -> str:
27
29
  """Reformats a set of SearchResults into a single string to pass directly to an LLM as context"""
28
- context_string = """FACTS and ENTITIES represent relevant context to the current conversation.
29
- COMMUNITIES represent a cluster of closely related entities.
30
-
31
- # These are the most relevant facts and their valid date ranges
32
- # format: FACT (Date range: from - to)
33
- """
34
- context_string += '<FACTS>\n'
35
- for edge in search_results.edges:
36
- context_string += f'- {edge.fact} ({format_edge_date_range(edge)})\n'
37
- context_string += '</FACTS>\n'
38
- context_string += '<ENTITIES>\n'
39
- for node in search_results.nodes:
40
- context_string += f'- {node.name}: {node.summary}\n'
41
- context_string += '</ENTITIES>\n'
42
- context_string += '<COMMUNITIES>\n'
43
- for community in search_results.communities:
44
- context_string += f'- {community.name}: {community.summary}\n'
45
- context_string += '</COMMUNITIES>\n'
30
+ fact_json = [
31
+ {
32
+ 'fact': edge.fact,
33
+ 'valid_at': str(edge.valid_at),
34
+ 'invalid_at': str(edge.invalid_at or 'Present'),
35
+ }
36
+ for edge in search_results.edges
37
+ ]
38
+ entity_json = [
39
+ {'entity_name': node.name, 'summary': node.summary} for node in search_results.nodes
40
+ ]
41
+ community_json = [
42
+ {'community_name': community.name, 'summary': community.summary}
43
+ for community in search_results.communities
44
+ ]
45
+
46
+ context_string = f"""
47
+ FACTS and ENTITIES represent relevant context to the current conversation.
48
+ COMMUNITIES represent a cluster of closely related entities.
49
+
50
+ These are the most relevant facts and their valid and invalid dates. Facts are considered valid
51
+ between their valid_at and invalid_at dates. Facts with an invalid_at date of "Present" are considered valid.
52
+ <FACTS>
53
+ {json.dumps(fact_json, indent=12)}
54
+ </FACTS>
55
+ <ENTITIES>
56
+ {json.dumps(entity_json, indent=12)}
57
+ </ENTITIES>
58
+ <COMMUNITIES>
59
+ {json.dumps(community_json, indent=12)}
60
+ </COMMUNITIES>
61
+ """
46
62
 
47
63
  return context_string
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: graphiti-core
3
- Version: 0.9.5
3
+ Version: 0.9.6
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -43,10 +43,10 @@ graphiti_core/prompts/summarize_nodes.py,sha256=PeA1Taov5KBNNBKgrCPeF1tLg4_SMgT-
43
43
  graphiti_core/py.typed,sha256=vlmmzQOt7bmeQl9L3XJP4W6Ry0iiELepnOrinKz5KQg,79
44
44
  graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  graphiti_core/search/search.py,sha256=DX-tcIa0SiKI2HX-b_WdjGE74A8RLWQor4p90dJluUA,12643
46
- graphiti_core/search/search_config.py,sha256=Yn_p1cnMwtZAdIOga19iaCoS7FmA95-GLN7KmHd-7N0,3117
46
+ graphiti_core/search/search_config.py,sha256=UZN8jFA4pBlw2O5N1cuhVRBdTwMLR9N3Oyo6sQ4MDVw,3117
47
47
  graphiti_core/search/search_config_recipes.py,sha256=yUqiLnn9vFg39M8eVwjVKfBCL_ptGrfDMQ47m_Blb0g,6885
48
48
  graphiti_core/search/search_filters.py,sha256=JkP7NbM4Dor27dne5vAuxbJic12dIJDtWJxNqmVuRec,5884
49
- graphiti_core/search/search_helpers.py,sha256=Tt5rRUfblBlFqV7r8XuGZiT5P_wjlh01xS0feELZjXg,2173
49
+ graphiti_core/search/search_helpers.py,sha256=7hHmhAbuo88CkKFy-U6lRtObzw89hzJIV4rdF1bd134,2367
50
50
  graphiti_core/search/search_utils.py,sha256=4i5Uwp6iNz849njIf89jOgI2NDtSFHQ_grnZpLSNv0I,25771
51
51
  graphiti_core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  graphiti_core/utils/bulk_utils.py,sha256=P4LKO46Yle4tBdNcQ3hDHcSQFaR8UBLfoL-z1M2Wua0,14690
@@ -59,7 +59,7 @@ graphiti_core/utils/maintenance/node_operations.py,sha256=WhZQixx05dAFFQAd5KTXJ8
59
59
  graphiti_core/utils/maintenance/temporal_operations.py,sha256=RdNtubCyYhOVrvcOIq2WppHls1Q-BEjtsN8r38l-Rtc,3691
60
60
  graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
61
  graphiti_core/utils/ontology_utils/entity_types_utils.py,sha256=QJX5cG0GSSNF_Mm_yrldr69wjVAbN_MxLhOSznz85Hk,1279
62
- graphiti_core-0.9.5.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
63
- graphiti_core-0.9.5.dist-info/METADATA,sha256=ptj44vyxZwC9xQmIsnEeKGTpUniDD4fLz7gRKMAXqI4,14394
64
- graphiti_core-0.9.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
65
- graphiti_core-0.9.5.dist-info/RECORD,,
62
+ graphiti_core-0.9.6.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
63
+ graphiti_core-0.9.6.dist-info/METADATA,sha256=Op_DuEb-dSaqcyI5d1yIxwG7Belqdu1_cmb7kimVWs0,14394
64
+ graphiti_core-0.9.6.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
65
+ graphiti_core-0.9.6.dist-info/RECORD,,