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

@@ -20,9 +20,9 @@ from datetime import datetime
20
20
  from time import time
21
21
  from typing import List
22
22
 
23
- from graphiti_core.edges import EntityEdge, EpisodicEdge
23
+ from graphiti_core.edges import CommunityEdge, EntityEdge, EpisodicEdge
24
24
  from graphiti_core.llm_client import LLMClient
25
- from graphiti_core.nodes import EntityNode, EpisodicNode
25
+ from graphiti_core.nodes import CommunityNode, EntityNode, EpisodicNode
26
26
  from graphiti_core.prompts import prompt_library
27
27
  from graphiti_core.utils.maintenance.temporal_operations import (
28
28
  extract_edge_dates,
@@ -50,6 +50,24 @@ def build_episodic_edges(
50
50
  return edges
51
51
 
52
52
 
53
+ def build_community_edges(
54
+ entity_nodes: List[EntityNode],
55
+ community_node: CommunityNode,
56
+ created_at: datetime,
57
+ ) -> List[CommunityEdge]:
58
+ edges: List[CommunityEdge] = [
59
+ CommunityEdge(
60
+ source_node_uuid=community_node.uuid,
61
+ target_node_uuid=node.uuid,
62
+ created_at=created_at,
63
+ group_id=community_node.group_id,
64
+ )
65
+ for node in entity_nodes
66
+ ]
67
+
68
+ return edges
69
+
70
+
53
71
  async def extract_edges(
54
72
  llm_client: LLMClient,
55
73
  episode: EpisodicNode,
@@ -32,8 +32,10 @@ async def build_indices_and_constraints(driver: AsyncDriver):
32
32
  range_indices: list[LiteralString] = [
33
33
  'CREATE INDEX entity_uuid IF NOT EXISTS FOR (n:Entity) ON (n.uuid)',
34
34
  'CREATE INDEX episode_uuid IF NOT EXISTS FOR (n:Episodic) ON (n.uuid)',
35
+ 'CREATE INDEX community_uuid IF NOT EXISTS FOR (n:Community) ON (n.uuid)',
35
36
  'CREATE INDEX relation_uuid IF NOT EXISTS FOR ()-[e:RELATES_TO]-() ON (e.uuid)',
36
37
  'CREATE INDEX mention_uuid IF NOT EXISTS FOR ()-[e:MENTIONS]-() ON (e.uuid)',
38
+ 'CREATE INDEX has_member_uuid IF NOT EXISTS FOR ()-[e:HAS_MEMBER]-() ON (e.uuid)',
37
39
  'CREATE INDEX entity_group_id IF NOT EXISTS FOR (n:Entity) ON (n.group_id)',
38
40
  'CREATE INDEX episode_group_id IF NOT EXISTS FOR (n:Episodic) ON (n.group_id)',
39
41
  'CREATE INDEX relation_group_id IF NOT EXISTS FOR ()-[e:RELATES_TO]-() ON (e.group_id)',
@@ -51,6 +53,7 @@ async def build_indices_and_constraints(driver: AsyncDriver):
51
53
 
52
54
  fulltext_indices: list[LiteralString] = [
53
55
  'CREATE FULLTEXT INDEX name_and_summary IF NOT EXISTS FOR (n:Entity) ON EACH [n.name, n.summary]',
56
+ 'CREATE FULLTEXT INDEX community_name IF NOT EXISTS FOR (n:Community) ON EACH [n.name]',
54
57
  'CREATE FULLTEXT INDEX name_and_fact IF NOT EXISTS FOR ()-[e:RELATES_TO]-() ON EACH [e.name, e.fact]',
55
58
  ]
56
59
 
@@ -71,6 +74,14 @@ async def build_indices_and_constraints(driver: AsyncDriver):
71
74
  `vector.similarity_function`: 'cosine'
72
75
  }}
73
76
  """,
77
+ """
78
+ CREATE VECTOR INDEX community_name_embedding IF NOT EXISTS
79
+ FOR (n:Community) ON (n.name_embedding)
80
+ OPTIONS {indexConfig: {
81
+ `vector.dimensions`: 1024,
82
+ `vector.similarity_function`: 'cosine'
83
+ }}
84
+ """,
74
85
  ]
75
86
  index_queries: list[LiteralString] = range_indices + fulltext_indices + vector_indices
76
87
 
@@ -48,6 +48,29 @@ async def extract_message_nodes(
48
48
  return extracted_node_data
49
49
 
50
50
 
51
+ async def extract_text_nodes(
52
+ llm_client: LLMClient, episode: EpisodicNode, previous_episodes: list[EpisodicNode]
53
+ ) -> list[dict[str, Any]]:
54
+ # Prepare context for LLM
55
+ context = {
56
+ 'episode_content': episode.content,
57
+ 'episode_timestamp': episode.valid_at.isoformat(),
58
+ 'previous_episodes': [
59
+ {
60
+ 'content': ep.content,
61
+ 'timestamp': ep.valid_at.isoformat(),
62
+ }
63
+ for ep in previous_episodes
64
+ ],
65
+ }
66
+
67
+ llm_response = await llm_client.generate_response(
68
+ prompt_library.extract_nodes.extract_text(context)
69
+ )
70
+ extracted_node_data = llm_response.get('extracted_nodes', [])
71
+ return extracted_node_data
72
+
73
+
51
74
  async def extract_json_nodes(
52
75
  llm_client: LLMClient,
53
76
  episode: EpisodicNode,
@@ -73,8 +96,10 @@ async def extract_nodes(
73
96
  ) -> list[EntityNode]:
74
97
  start = time()
75
98
  extracted_node_data: list[dict[str, Any]] = []
76
- if episode.source in [EpisodeType.message, EpisodeType.text]:
99
+ if episode.source == EpisodeType.message:
77
100
  extracted_node_data = await extract_message_nodes(llm_client, episode, previous_episodes)
101
+ elif episode.source == EpisodeType.text:
102
+ extracted_node_data = await extract_text_nodes(llm_client, episode, previous_episodes)
78
103
  elif episode.source == EpisodeType.json:
79
104
  extracted_node_data = await extract_json_nodes(llm_client, episode)
80
105
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: graphiti-core
3
- Version: 0.2.3
3
+ Version: 0.3.1
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Requires-Dist: diskcache (>=5.6.3,<6.0.0)
15
15
  Requires-Dist: neo4j (>=5.23.0,<6.0.0)
16
- Requires-Dist: numpy (>=2.1.1,<3.0.0)
16
+ Requires-Dist: numpy (>=1.0.0)
17
17
  Requires-Dist: openai (>=1.38.0,<2.0.0)
18
18
  Requires-Dist: pydantic (>=2.8.2,<3.0.0)
19
19
  Requires-Dist: tenacity (<9.0.0)
@@ -170,6 +170,12 @@ await graphiti.search('Who was the California Attorney General?', center_node_uu
170
170
  graphiti.close()
171
171
  ```
172
172
 
173
+ ## Graph Service
174
+
175
+ The `server` directory contains an API service for interacting with the Graphiti API. It is built using FastAPI.
176
+
177
+ Please see the [server README](./server/README.md) for more information.
178
+
173
179
  ## Documentation
174
180
 
175
181
  - [Guides and API documentation](https://help.getzep.com/graphiti).
@@ -0,0 +1,43 @@
1
+ graphiti_core/__init__.py,sha256=e5SWFkRiaUwfprYIeIgVIh7JDedNiloZvd3roU-0aDY,55
2
+ graphiti_core/edges.py,sha256=bKzlrIrzofggRckgL3RA3MKLTgCKwkPVMB-tVA6Vd_A,9130
3
+ graphiti_core/errors.py,sha256=BOwL0VVnoUuMjK3EUYKvqefsbsYhRhcKcVWXaX9hanw,1259
4
+ graphiti_core/graphiti.py,sha256=ViKKrF84VENTIR6WFtGpZ3FCZqC9B9__lKVsiXPCjV8,24563
5
+ graphiti_core/helpers.py,sha256=qQqZJBkc_z5f3x5axPfCKK_QHLRybvWNFb57WXNENfQ,769
6
+ graphiti_core/llm_client/__init__.py,sha256=PA80TSMeX-sUXITXEAxMDEt3gtfZgcJrGJUcyds1mSo,207
7
+ graphiti_core/llm_client/anthropic_client.py,sha256=3zsOkewLFxBhKe90OkmpfkvrcwykgGwRoqII05Jno_Q,2410
8
+ graphiti_core/llm_client/client.py,sha256=7-gEhOKxjdkllV_xS2Ikn-a4QzK9NE63CANnZgdn3VY,3438
9
+ graphiti_core/llm_client/config.py,sha256=d1oZ9tt7QBQlbph7v-0HjItb6otK9_-IwF8kkRYL2rc,2359
10
+ graphiti_core/llm_client/errors.py,sha256=-qlWwv1X-UjfsFIiNl-7yJIYvPwi7z8srVRfX4-s6uk,814
11
+ graphiti_core/llm_client/groq_client.py,sha256=clQvQ9-zCRoqK9NGMx9Icyl4lUXmM70lZgVquXikxBo,2334
12
+ graphiti_core/llm_client/openai_client.py,sha256=VqzWdSrHuNfF2l1aRDua00NHhtP9UR7VNtLcu8h9vLc,2343
13
+ graphiti_core/llm_client/utils.py,sha256=0KT4XxTVw3c0__HLDj3F8kNR4K_qY0hT0TH-pQZ_IZw,1126
14
+ graphiti_core/nodes.py,sha256=b3R06tFdmKriTwe7evXa7K8uwjuW33mOApXiW404aKU,12150
15
+ graphiti_core/prompts/__init__.py,sha256=EA-x9xUki9l8wnu2l8ek_oNf75-do5tq5hVq7Zbv8Kw,101
16
+ graphiti_core/prompts/dedupe_edges.py,sha256=DUNHdIudj50FAjkla4nc68tSFSD2yjmYHBw-Bb7ph20,6529
17
+ graphiti_core/prompts/dedupe_nodes.py,sha256=BZ9S-PB9SSGjc5Oo8ivdgA6rZx3OGOFhKtwrBlQ0bm0,7269
18
+ graphiti_core/prompts/extract_edge_dates.py,sha256=oOCR8mC_3gI1bumrmIjUbkNO-WTuLTXXAalPDYnDXeM,3655
19
+ graphiti_core/prompts/extract_edges.py,sha256=AQ8xYbAv_RKXAT6WMwXs1_GvUdLtM_lhLNbt3SkOAmk,5348
20
+ graphiti_core/prompts/extract_nodes.py,sha256=VIr0Nh0mSiodI3iGOQFszh7DOni4mufOKJDuGkMysl8,6889
21
+ graphiti_core/prompts/invalidate_edges.py,sha256=8SHt3iPTdmqk8A52LxgdMtI39w4USKqVDMOS2i6lRQ4,4342
22
+ graphiti_core/prompts/lib.py,sha256=lIgVAxu4U4R9gnJVPkqxT4hcAXfErHECtM_Uceh55VA,3857
23
+ graphiti_core/prompts/models.py,sha256=cvx_Bv5RMFUD_5IUawYrbpOKLPHogai7_bm7YXrSz84,867
24
+ graphiti_core/prompts/summarize_nodes.py,sha256=FLuZpGTABgcxuIDkx_IKH115nHEw0rIaFhcGlWveAMc,2357
25
+ graphiti_core/py.typed,sha256=vlmmzQOt7bmeQl9L3XJP4W6Ry0iiELepnOrinKz5KQg,79
26
+ graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ graphiti_core/search/search.py,sha256=BtyZBhwAt_IbU8dqm-DeRAIovkFDTdFly5IBGxs4yy8,8101
28
+ graphiti_core/search/search_config.py,sha256=nOLU_k2p_sM0-JBYci8rWhc-mERv8uWkDn0GOYqZjL8,2081
29
+ graphiti_core/search/search_config_recipes.py,sha256=CJIhYjXPgSm20cY9IkXQxArCgwLvjz-4xB7mr4NylWg,2857
30
+ graphiti_core/search/search_utils.py,sha256=vFxLMt0CB_1Avn32d1PFsJPtJ26MCEdoq-BSBx2uCGQ,22802
31
+ graphiti_core/utils/__init__.py,sha256=cJAcMnBZdHBQmWrZdU1PQ1YmaL75bhVUkyVpIPuOyns,260
32
+ graphiti_core/utils/bulk_utils.py,sha256=JtoYTZPCigPa3n2E43Oe7QhFZRTA_QKNGy1jVgklHag,12614
33
+ graphiti_core/utils/maintenance/__init__.py,sha256=4b9sfxqyFZMLwxxS2lnQ6_wBr3xrJRIqfAWOidK8EK0,388
34
+ graphiti_core/utils/maintenance/community_operations.py,sha256=vbMKY_BfgsrsL-strsK-853MJSXhLeLsSVSWS79OaYo,4931
35
+ graphiti_core/utils/maintenance/edge_operations.py,sha256=nXsCwB4YEbXWyNQaII31QNbCrABB7lguuZ3i1M0fTas,11333
36
+ graphiti_core/utils/maintenance/graph_data_operations.py,sha256=d27efEVLvQTmoKE7Hq21wAWSmfqkKzw7jMbVo1zKggE,6489
37
+ graphiti_core/utils/maintenance/node_operations.py,sha256=WXJFU1AprYjmHSq6rZhTIX4JFHtF5W9LbzA2Tfksp5Q,8838
38
+ graphiti_core/utils/maintenance/temporal_operations.py,sha256=BzfGDm96w4HcUEsaWTHUBt5S8dNmDQL1eX6AuBL-XFM,8135
39
+ graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ graphiti_core-0.3.1.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
41
+ graphiti_core-0.3.1.dist-info/METADATA,sha256=0bMJQF6SqZMJvyvnTmiW-WdmhfssBGkMMhO9VG5RVzk,9323
42
+ graphiti_core-0.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
43
+ graphiti_core-0.3.1.dist-info/RECORD,,
@@ -1,36 +0,0 @@
1
- graphiti_core/__init__.py,sha256=e5SWFkRiaUwfprYIeIgVIh7JDedNiloZvd3roU-0aDY,55
2
- graphiti_core/edges.py,sha256=oy_tK9YWE7_g4aQMGutymVdreiC-SsWP6ZtayEYGCFQ,7700
3
- graphiti_core/graphiti.py,sha256=tUEtyBb8hQXTn_eMmVSsFVBV7AKWE22SPQihCMZtcZU,23647
4
- graphiti_core/helpers.py,sha256=EAeC3RrcecjiTGN2vxergN5RHTy2_jhFXA5PQVT3toU,200
5
- graphiti_core/llm_client/__init__.py,sha256=f4OSk82jJ70wZ2HOuQu6-RQWkkf7HIB0FCT6xOuxZkQ,154
6
- graphiti_core/llm_client/anthropic_client.py,sha256=C8lOLm7in_eNfOP7s8gjMM0Y99-TzKWlGaPuVGceX68,2180
7
- graphiti_core/llm_client/client.py,sha256=ysBf3zDOVbgBgwHbHB478TCVnOBjIwTELNsBovUh35g,3135
8
- graphiti_core/llm_client/config.py,sha256=d1oZ9tt7QBQlbph7v-0HjItb6otK9_-IwF8kkRYL2rc,2359
9
- graphiti_core/llm_client/groq_client.py,sha256=qscr5-190wBTUCBL31EAjQTLytK9AF75-y9GsVRvGJU,2206
10
- graphiti_core/llm_client/openai_client.py,sha256=Bkrp_mKzAxK6kgPzv1UtVUgr1ZvvJhE2H39hgAwWrsI,2211
11
- graphiti_core/llm_client/utils.py,sha256=H8-Kwa5SyvIYDNIas8O4bHJ6jsOL49li44VoDEMyauY,555
12
- graphiti_core/nodes.py,sha256=RZnIKyu9ZzWVlbodae3Rkzlg00fQIqp5o3iGB4Ffm-M,8140
13
- graphiti_core/prompts/__init__.py,sha256=EA-x9xUki9l8wnu2l8ek_oNf75-do5tq5hVq7Zbv8Kw,101
14
- graphiti_core/prompts/dedupe_edges.py,sha256=DUNHdIudj50FAjkla4nc68tSFSD2yjmYHBw-Bb7ph20,6529
15
- graphiti_core/prompts/dedupe_nodes.py,sha256=BZ9S-PB9SSGjc5Oo8ivdgA6rZx3OGOFhKtwrBlQ0bm0,7269
16
- graphiti_core/prompts/extract_edge_dates.py,sha256=G-Gnsyt8pYx9lFJEwlIsTdADF3ESDe26WSsrAGmvlYk,3086
17
- graphiti_core/prompts/extract_edges.py,sha256=AQ8xYbAv_RKXAT6WMwXs1_GvUdLtM_lhLNbt3SkOAmk,5348
18
- graphiti_core/prompts/extract_nodes.py,sha256=isYly1Yq9tpD-Dlj2JNvKMdsJUqjWMSO16ZFinFxWic,5304
19
- graphiti_core/prompts/invalidate_edges.py,sha256=8SHt3iPTdmqk8A52LxgdMtI39w4USKqVDMOS2i6lRQ4,4342
20
- graphiti_core/prompts/lib.py,sha256=RR8f8DQfioUK5bJonMzn02pKLxJlaENv1VocpvRJ488,3532
21
- graphiti_core/prompts/models.py,sha256=cvx_Bv5RMFUD_5IUawYrbpOKLPHogai7_bm7YXrSz84,867
22
- graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- graphiti_core/search/search.py,sha256=cr1-syRlRdijnLtbuQYWy_2G1CtAeIaz6BQ2kl_6FrY,4535
24
- graphiti_core/search/search_utils.py,sha256=YeJ-M67HXPQySruwZmau3jvilFlcwf8OwfuflnSdf1Q,19355
25
- graphiti_core/utils/__init__.py,sha256=cJAcMnBZdHBQmWrZdU1PQ1YmaL75bhVUkyVpIPuOyns,260
26
- graphiti_core/utils/bulk_utils.py,sha256=JtoYTZPCigPa3n2E43Oe7QhFZRTA_QKNGy1jVgklHag,12614
27
- graphiti_core/utils/maintenance/__init__.py,sha256=4b9sfxqyFZMLwxxS2lnQ6_wBr3xrJRIqfAWOidK8EK0,388
28
- graphiti_core/utils/maintenance/edge_operations.py,sha256=Xq60YlOGQKzD5qN6eahUMOiLQJiBaDNOeIiGkS8EdB0,10855
29
- graphiti_core/utils/maintenance/graph_data_operations.py,sha256=-A4fPYtXIjoBBX6IDPoaU9pDcSjZGeRbRPj23W1C-l4,5951
30
- graphiti_core/utils/maintenance/node_operations.py,sha256=ecBOp_reQynENFN0M69IzRPgEuBYOuPpDBwFZq5e-I4,7995
31
- graphiti_core/utils/maintenance/temporal_operations.py,sha256=BzfGDm96w4HcUEsaWTHUBt5S8dNmDQL1eX6AuBL-XFM,8135
32
- graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- graphiti_core-0.2.3.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
34
- graphiti_core-0.2.3.dist-info/METADATA,sha256=o81BUoLGtzm0AhnO9MBW8yeG1_UPFN6m-0PmnFOJKis,9124
35
- graphiti_core-0.2.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- graphiti_core-0.2.3.dist-info/RECORD,,