graphiti-core 0.22.0rc1__py3-none-any.whl → 0.22.0rc2__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,47 +20,44 @@ from pydantic import BaseModel, Field
20
20
 
21
21
  from .models import Message, PromptFunction, PromptVersion
22
22
  from .prompt_helpers import to_prompt_json
23
+ from .snippets import summary_instructions
23
24
 
24
25
 
25
26
  class ExtractedEntity(BaseModel):
26
- name: str = Field(..., description="Name of the extracted entity")
27
+ name: str = Field(..., description='Name of the extracted entity')
27
28
  entity_type_id: int = Field(
28
- description="ID of the classified entity type. "
29
- "Must be one of the provided entity_type_id integers.",
29
+ description='ID of the classified entity type. '
30
+ 'Must be one of the provided entity_type_id integers.',
30
31
  )
31
32
 
32
33
 
33
34
  class ExtractedEntities(BaseModel):
34
- extracted_entities: list[ExtractedEntity] = Field(
35
- ..., description="List of extracted entities"
36
- )
35
+ extracted_entities: list[ExtractedEntity] = Field(..., description='List of extracted entities')
37
36
 
38
37
 
39
38
  class MissedEntities(BaseModel):
40
- missed_entities: list[str] = Field(
41
- ..., description="Names of entities that weren't extracted"
42
- )
39
+ missed_entities: list[str] = Field(..., description="Names of entities that weren't extracted")
43
40
 
44
41
 
45
42
  class EntityClassificationTriple(BaseModel):
46
- uuid: str = Field(description="UUID of the entity")
47
- name: str = Field(description="Name of the entity")
43
+ uuid: str = Field(description='UUID of the entity')
44
+ name: str = Field(description='Name of the entity')
48
45
  entity_type: str | None = Field(
49
46
  default=None,
50
- description="Type of the entity. Must be one of the provided types or None",
47
+ description='Type of the entity. Must be one of the provided types or None',
51
48
  )
52
49
 
53
50
 
54
51
  class EntityClassification(BaseModel):
55
52
  entity_classifications: list[EntityClassificationTriple] = Field(
56
- ..., description="List of entities classification triples."
53
+ ..., description='List of entities classification triples.'
57
54
  )
58
55
 
59
56
 
60
57
  class EntitySummary(BaseModel):
61
58
  summary: str = Field(
62
59
  ...,
63
- description="Summary containing the important information about the entity. Under 8 sentences.",
60
+ description='Summary containing the important information about the entity. Under 250 characters.',
64
61
  )
65
62
 
66
63
 
@@ -128,8 +125,8 @@ reference entities. Only extract distinct entities from the CURRENT MESSAGE. Don
128
125
  {context['custom_prompt']}
129
126
  """
130
127
  return [
131
- Message(role="system", content=sys_prompt),
132
- Message(role="user", content=user_prompt),
128
+ Message(role='system', content=sys_prompt),
129
+ Message(role='user', content=user_prompt),
133
130
  ]
134
131
 
135
132
 
@@ -161,8 +158,8 @@ Guidelines:
161
158
  3. Do NOT extract any properties that contain dates
162
159
  """
163
160
  return [
164
- Message(role="system", content=sys_prompt),
165
- Message(role="user", content=user_prompt),
161
+ Message(role='system', content=sys_prompt),
162
+ Message(role='user', content=user_prompt),
166
163
  ]
167
164
 
168
165
 
@@ -192,8 +189,8 @@ Guidelines:
192
189
  4. Be as explicit as possible in your node names, using full names and avoiding abbreviations.
193
190
  """
194
191
  return [
195
- Message(role="system", content=sys_prompt),
196
- Message(role="user", content=user_prompt),
192
+ Message(role='system', content=sys_prompt),
193
+ Message(role='user', content=user_prompt),
197
194
  ]
198
195
 
199
196
 
@@ -216,8 +213,8 @@ Given the above previous messages, current message, and list of extracted entiti
216
213
  extracted.
217
214
  """
218
215
  return [
219
- Message(role="system", content=sys_prompt),
220
- Message(role="user", content=user_prompt),
216
+ Message(role='system', content=sys_prompt),
217
+ Message(role='user', content=user_prompt),
221
218
  ]
222
219
 
223
220
 
@@ -248,19 +245,19 @@ def classify_nodes(context: dict[str, Any]) -> list[Message]:
248
245
  3. If none of the provided entity types accurately classify an extracted node, the type should be set to None
249
246
  """
250
247
  return [
251
- Message(role="system", content=sys_prompt),
252
- Message(role="user", content=user_prompt),
248
+ Message(role='system', content=sys_prompt),
249
+ Message(role='user', content=user_prompt),
253
250
  ]
254
251
 
255
252
 
256
253
  def extract_attributes(context: dict[str, Any]) -> list[Message]:
257
254
  return [
258
255
  Message(
259
- role="system",
260
- content="You are a helpful assistant that extracts entity properties from the provided text.",
256
+ role='system',
257
+ content='You are a helpful assistant that extracts entity properties from the provided text.',
261
258
  ),
262
259
  Message(
263
- role="user",
260
+ role='user',
264
261
  content=f"""
265
262
 
266
263
  <MESSAGES>
@@ -286,11 +283,11 @@ def extract_attributes(context: dict[str, Any]) -> list[Message]:
286
283
  def extract_summary(context: dict[str, Any]) -> list[Message]:
287
284
  return [
288
285
  Message(
289
- role="system",
290
- content="You are a helpful assistant that extracts entity summaries from the provided text.",
286
+ role='system',
287
+ content='You are a helpful assistant that extracts entity summaries from the provided text.',
291
288
  ),
292
289
  Message(
293
- role="user",
290
+ role='user',
294
291
  content=f"""
295
292
 
296
293
  <MESSAGES>
@@ -301,11 +298,7 @@ def extract_summary(context: dict[str, Any]) -> list[Message]:
301
298
  Given the above MESSAGES and the following ENTITY, update the summary that combines relevant information about the entity
302
299
  from the messages and relevant information from the existing summary.
303
300
 
304
- Guidelines:
305
- 1. Do not hallucinate entity summary information if they cannot be found in the current context.
306
- 2. Only use the provided MESSAGES and ENTITY to set attribute values.
307
- 3. The summary attribute represents a summary of the ENTITY, and should be updated with new information about the Entity from the MESSAGES.
308
- 4. Keep the summary concise and to the point. SUMMARIES MUST BE LESS THAN 8 SENTENCES.
301
+ {summary_instructions}
309
302
 
310
303
  <ENTITY>
311
304
  {context['node']}
@@ -316,11 +309,11 @@ def extract_summary(context: dict[str, Any]) -> list[Message]:
316
309
 
317
310
 
318
311
  versions: Versions = {
319
- "extract_message": extract_message,
320
- "extract_json": extract_json,
321
- "extract_text": extract_text,
322
- "reflexion": reflexion,
323
- "extract_summary": extract_summary,
324
- "classify_nodes": classify_nodes,
325
- "extract_attributes": extract_attributes,
312
+ 'extract_message': extract_message,
313
+ 'extract_json': extract_json,
314
+ 'extract_text': extract_text,
315
+ 'reflexion': reflexion,
316
+ 'extract_summary': extract_summary,
317
+ 'classify_nodes': classify_nodes,
318
+ 'extract_attributes': extract_attributes,
326
319
  }
@@ -1,3 +1,19 @@
1
+ """
2
+ Copyright 2024, Zep Software, Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
1
17
  import json
2
18
  from typing import Any
3
19
 
@@ -0,0 +1,29 @@
1
+ """
2
+ Copyright 2024, Zep Software, Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ summary_instructions = """Guidelines:
18
+ 1. Output only factual content. Never explain what you're doing, why, or mention limitations/constraints.
19
+ 2. Only use the provided messages, entity, and entity context to set attribute values.
20
+ 3. Keep the summary concise and to the point. STATE FACTS DIRECTLY IN UNDER 250 CHARACTERS.
21
+
22
+ Example summaries:
23
+ BAD: "This is the only activity in the context. The user listened to this song. No other details were provided to include in this summary."
24
+ GOOD: "User played 'Blue Monday' by New Order (electronic genre) on 2024-12-03 at 14:22 UTC."
25
+ BAD: "Based on the messages provided, the user attended a meeting. This summary focuses on that event as it was the main topic discussed."
26
+ GOOD: "User attended Q3 planning meeting with sales team on March 15."
27
+ BAD: "The context shows John ordered pizza. Due to length constraints, other details are omitted from this summary."
28
+ GOOD: "John ordered pepperoni pizza from Mario's at 7:30 PM, delivered to office."
29
+ """
@@ -20,19 +20,18 @@ from pydantic import BaseModel, Field
20
20
 
21
21
  from .models import Message, PromptFunction, PromptVersion
22
22
  from .prompt_helpers import to_prompt_json
23
+ from .snippets import summary_instructions
23
24
 
24
25
 
25
26
  class Summary(BaseModel):
26
27
  summary: str = Field(
27
28
  ...,
28
- description="Summary containing the important information about the entity. Under 8 sentences",
29
+ description='Summary containing the important information about the entity. Under 250 characters',
29
30
  )
30
31
 
31
32
 
32
33
  class SummaryDescription(BaseModel):
33
- description: str = Field(
34
- ..., description="One sentence description of the provided summary"
35
- )
34
+ description: str = Field(..., description='One sentence description of the provided summary')
36
35
 
37
36
 
38
37
  class Prompt(Protocol):
@@ -50,15 +49,15 @@ class Versions(TypedDict):
50
49
  def summarize_pair(context: dict[str, Any]) -> list[Message]:
51
50
  return [
52
51
  Message(
53
- role="system",
54
- content="You are a helpful assistant that combines summaries.",
52
+ role='system',
53
+ content='You are a helpful assistant that combines summaries.',
55
54
  ),
56
55
  Message(
57
- role="user",
56
+ role='user',
58
57
  content=f"""
59
58
  Synthesize the information from the following two summaries into a single succinct summary.
60
59
 
61
- IMPORTANT: Keep the summary concise and to the point. SUMMARIES MUST BE LESS THAN 8 SENTENCES.
60
+ IMPORTANT: Keep the summary concise and to the point. SUMMARIES MUST BE LESS THAN 250 CHARACTERS.
62
61
 
63
62
  Summaries:
64
63
  {to_prompt_json(context['node_summaries'], indent=2)}
@@ -70,29 +69,25 @@ def summarize_pair(context: dict[str, Any]) -> list[Message]:
70
69
  def summarize_context(context: dict[str, Any]) -> list[Message]:
71
70
  return [
72
71
  Message(
73
- role="system",
74
- content="You are a helpful assistant that generates a summary and attributes from provided text.",
72
+ role='system',
73
+ content='You are a helpful assistant that generates a summary and attributes from provided text.',
75
74
  ),
76
75
  Message(
77
- role="user",
76
+ role='user',
78
77
  content=f"""
79
-
80
- <MESSAGES>
81
- {to_prompt_json(context['previous_episodes'], indent=2)}
82
- {to_prompt_json(context['episode_content'], indent=2)}
83
- </MESSAGES>
84
-
85
- Given the above MESSAGES and the following ENTITY name, create a summary for the ENTITY. Your summary must only use
78
+ Given the MESSAGES and the ENTITY name, create a summary for the ENTITY. Your summary must only use
86
79
  information from the provided MESSAGES. Your summary should also only contain information relevant to the
87
80
  provided ENTITY.
88
81
 
89
82
  In addition, extract any values for the provided entity properties based on their descriptions.
90
83
  If the value of the entity property cannot be found in the current context, set the value of the property to the Python value None.
91
84
 
92
- Guidelines:
93
- 1. Do not hallucinate entity property values if they cannot be found in the current context.
94
- 2. Only use the provided messages, entity, and entity context to set attribute values.
95
- 3. Keep the summary concise and to the point. SUMMARIES MUST BE LESS THAN 8 SENTENCES.
85
+ {summary_instructions}
86
+
87
+ <MESSAGES>
88
+ {to_prompt_json(context['previous_episodes'], indent=2)}
89
+ {to_prompt_json(context['episode_content'], indent=2)}
90
+ </MESSAGES>
96
91
 
97
92
  <ENTITY>
98
93
  {context['node_name']}
@@ -113,14 +108,14 @@ def summarize_context(context: dict[str, Any]) -> list[Message]:
113
108
  def summary_description(context: dict[str, Any]) -> list[Message]:
114
109
  return [
115
110
  Message(
116
- role="system",
117
- content="You are a helpful assistant that describes provided contents in a single sentence.",
111
+ role='system',
112
+ content='You are a helpful assistant that describes provided contents in a single sentence.',
118
113
  ),
119
114
  Message(
120
- role="user",
115
+ role='user',
121
116
  content=f"""
122
117
  Create a short one sentence description of the summary that explains what kind of information is summarized.
123
- Summaries must be under 8 sentences.
118
+ Summaries must be under 250 characters.
124
119
 
125
120
  Summary:
126
121
  {to_prompt_json(context['summary'], indent=2)}
@@ -130,7 +125,7 @@ def summary_description(context: dict[str, Any]) -> list[Message]:
130
125
 
131
126
 
132
127
  versions: Versions = {
133
- "summarize_pair": summarize_pair,
134
- "summarize_context": summarize_context,
135
- "summary_description": summary_description,
128
+ 'summarize_pair': summarize_pair,
129
+ 'summarize_context': summarize_context,
130
+ 'summary_description': summary_description,
136
131
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphiti-core
3
- Version: 0.22.0rc1
3
+ Version: 0.22.0rc2
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
@@ -48,12 +48,13 @@ graphiti_core/prompts/dedupe_nodes.py,sha256=YNNo19Cq8koLVoLCafpjYJOy5nmRZ-tEWhv
48
48
  graphiti_core/prompts/eval.py,sha256=GWFkfZoPfY8U7mV8Ngd_5a2S2fHS7KjajChntxv1UEY,5360
49
49
  graphiti_core/prompts/extract_edge_dates.py,sha256=3Drs3CmvP0gJN5BidWSxrNvLet3HPoTybU3BUIAoc0Y,4218
50
50
  graphiti_core/prompts/extract_edges.py,sha256=-yOIvCPwxIAXeqYpNCzouE6i3WfdsexzRXFmcXpQpAg,7113
51
- graphiti_core/prompts/extract_nodes.py,sha256=jMD-XRi4U3kjp9smHtA_kvnMBGWBfpBoKc45IoTIZs0,11360
51
+ graphiti_core/prompts/extract_nodes.py,sha256=fJ23-HC5RszLp_OAakh1VhsVacy4ef1kIchx9jLtaSk,10962
52
52
  graphiti_core/prompts/invalidate_edges.py,sha256=yfpcs_pyctnoM77ULPZXEtKW0oHr1MeLsJzC5yrE-o4,3547
53
53
  graphiti_core/prompts/lib.py,sha256=DCyHePM4_q-CptTpEXGO_dBv9k7xDtclEaB1dGu7EcI,4092
54
54
  graphiti_core/prompts/models.py,sha256=NgxdbPHJpBEcpbXovKyScgpBc73Q-GIW-CBDlBtDjto,894
55
- graphiti_core/prompts/prompt_helpers.py,sha256=dpWbB8IYAqAZoU5qBx896jozKiQJTng4dGzWewZ_s4c,814
56
- graphiti_core/prompts/summarize_nodes.py,sha256=7WnjRgYo1Z9bfnUWaUUXbiaLqygGLpemvB5inhhq44Y,4340
55
+ graphiti_core/prompts/prompt_helpers.py,sha256=56KmMCe3ByTGhzTEJJLmFsSt4OKB_Fpz4rhRNgIEUMw,1383
56
+ graphiti_core/prompts/snippets.py,sha256=E63cWzyYFjEIgVXmtfN1P6vkMgW65ECG34gfgcgBY4k,1649
57
+ graphiti_core/prompts/summarize_nodes.py,sha256=FTKzwm9dw3W7xQvmQ4D9k7Auor-fktZoT9ByhGCQqh8,4061
57
58
  graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
59
  graphiti_core/search/search.py,sha256=2kj7fybSFv6Fnf_cfEUhJhrpfzNtmkPPZ0hV3BQCDqg,18387
59
60
  graphiti_core/search/search_config.py,sha256=v_rUHsu1yo5OuPfEm21lSuXexQs-o8qYwSSemW2QWhU,4165
@@ -75,7 +76,7 @@ graphiti_core/utils/maintenance/node_operations.py,sha256=ARng4x_pCpfA3g4bM0BncO
75
76
  graphiti_core/utils/maintenance/temporal_operations.py,sha256=wq1I4kqeIoswit6sPohug91FEwrGaVnJ06g1vkJjSLY,3442
76
77
  graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
78
  graphiti_core/utils/ontology_utils/entity_types_utils.py,sha256=4eVgxLWY6Q8k9cRJ5pW59IYF--U4nXZsZIGOVb_yHfQ,1285
78
- graphiti_core-0.22.0rc1.dist-info/METADATA,sha256=NlIXn-TmrQ-_u-6CI6I7sEC7ioBKvQIKEl0oyqRq4YM,27084
79
- graphiti_core-0.22.0rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
80
- graphiti_core-0.22.0rc1.dist-info/licenses/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
81
- graphiti_core-0.22.0rc1.dist-info/RECORD,,
79
+ graphiti_core-0.22.0rc2.dist-info/METADATA,sha256=madNpEiuiTmAVjJFGmY4sju6zHB3Ujr4pSJd8dNTdDk,27084
80
+ graphiti_core-0.22.0rc2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
81
+ graphiti_core-0.22.0rc2.dist-info/licenses/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
82
+ graphiti_core-0.22.0rc2.dist-info/RECORD,,