graphiti-core 0.7.7__tar.gz → 0.7.8__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 (61) hide show
  1. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/PKG-INFO +1 -1
  2. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/graphiti.py +2 -2
  3. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/nodes.py +7 -1
  4. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/extract_nodes.py +11 -8
  5. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/summarize_nodes.py +2 -0
  6. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/node_operations.py +21 -10
  7. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/pyproject.toml +1 -1
  8. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/LICENSE +0 -0
  9. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/README.md +0 -0
  10. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/__init__.py +0 -0
  11. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/cross_encoder/__init__.py +0 -0
  12. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/cross_encoder/bge_reranker_client.py +0 -0
  13. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/cross_encoder/client.py +0 -0
  14. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/cross_encoder/openai_reranker_client.py +0 -0
  15. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/edges.py +0 -0
  16. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/embedder/__init__.py +0 -0
  17. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/embedder/client.py +0 -0
  18. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/embedder/openai.py +0 -0
  19. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/embedder/voyage.py +0 -0
  20. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/errors.py +0 -0
  21. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/helpers.py +0 -0
  22. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/__init__.py +0 -0
  23. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/anthropic_client.py +0 -0
  24. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/client.py +0 -0
  25. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/config.py +0 -0
  26. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/errors.py +0 -0
  27. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/groq_client.py +0 -0
  28. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/openai_client.py +0 -0
  29. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/openai_generic_client.py +0 -0
  30. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/llm_client/utils.py +0 -0
  31. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/models/__init__.py +0 -0
  32. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/models/edges/__init__.py +0 -0
  33. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/models/edges/edge_db_queries.py +0 -0
  34. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/models/nodes/__init__.py +0 -0
  35. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/models/nodes/node_db_queries.py +0 -0
  36. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/__init__.py +0 -0
  37. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/dedupe_edges.py +0 -0
  38. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/dedupe_nodes.py +0 -0
  39. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/eval.py +0 -0
  40. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/extract_edge_dates.py +0 -0
  41. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/extract_edges.py +0 -0
  42. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/invalidate_edges.py +0 -0
  43. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/lib.py +0 -0
  44. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/models.py +0 -0
  45. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/prompts/prompt_helpers.py +0 -0
  46. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/py.typed +0 -0
  47. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/__init__.py +0 -0
  48. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/search.py +0 -0
  49. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/search_config.py +0 -0
  50. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/search_config_recipes.py +0 -0
  51. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/search_filters.py +0 -0
  52. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/search/search_utils.py +0 -0
  53. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/__init__.py +0 -0
  54. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/bulk_utils.py +0 -0
  55. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/datetime_utils.py +0 -0
  56. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/__init__.py +0 -0
  57. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/community_operations.py +0 -0
  58. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/edge_operations.py +0 -0
  59. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/graph_data_operations.py +0 -0
  60. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/graphiti_core/utils/maintenance/temporal_operations.py +0 -0
  61. {graphiti_core-0.7.7 → graphiti_core-0.7.8}/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.7.7
3
+ Version: 0.7.8
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -29,7 +29,7 @@ from graphiti_core.edges import EntityEdge, EpisodicEdge
29
29
  from graphiti_core.embedder import EmbedderClient, OpenAIEmbedder
30
30
  from graphiti_core.helpers import DEFAULT_DATABASE, semaphore_gather
31
31
  from graphiti_core.llm_client import LLMClient, OpenAIClient
32
- from graphiti_core.nodes import CommunityNode, EntityNode, EpisodeType, EpisodicNode
32
+ from graphiti_core.nodes import CommunityNode, EntityNode, EntityType, EpisodeType, EpisodicNode
33
33
  from graphiti_core.search.search import SearchConfig, search
34
34
  from graphiti_core.search.search_config import DEFAULT_SEARCH_LIMIT, SearchResults
35
35
  from graphiti_core.search.search_config_recipes import (
@@ -262,7 +262,7 @@ class Graphiti:
262
262
  group_id: str = '',
263
263
  uuid: str | None = None,
264
264
  update_communities: bool = False,
265
- entity_types: dict[str, BaseModel] | None = None,
265
+ entity_types: dict[str, EntityType] | None = None,
266
266
  ) -> AddEpisodeResults:
267
267
  """
268
268
  Process an episode and update the graph.
@@ -19,7 +19,7 @@ from abc import ABC, abstractmethod
19
19
  from datetime import datetime
20
20
  from enum import Enum
21
21
  from time import time
22
- from typing import Any
22
+ from typing import Any, ClassVar
23
23
  from uuid import uuid4
24
24
 
25
25
  from neo4j import AsyncDriver
@@ -39,6 +39,12 @@ from graphiti_core.utils.datetime_utils import utc_now
39
39
  logger = logging.getLogger(__name__)
40
40
 
41
41
 
42
+ class EntityType(BaseModel):
43
+ type_description: ClassVar[str] = Field(
44
+ default='', description='Description of what the entity type represents'
45
+ )
46
+
47
+
42
48
  class EpisodeType(Enum):
43
49
  """
44
50
  Enumeration of different types of episodes that can be processed.
@@ -30,14 +30,17 @@ class MissedEntities(BaseModel):
30
30
  missed_entities: list[str] = Field(..., description="Names of entities that weren't extracted")
31
31
 
32
32
 
33
- class EntityClassification(BaseModel):
34
- entities: list[str] = Field(
35
- ...,
36
- description='List of entities',
33
+ class EntityClassificationTriple(BaseModel):
34
+ uuid: str = Field(description='UUID of the entity')
35
+ name: str = Field(description='Name of the entity')
36
+ entity_type: str | None = Field(
37
+ default=None, description='Type of the entity. Must be one of the provided types or None'
37
38
  )
38
- entity_classifications: list[str | None] = Field(
39
- ...,
40
- description='List of entities classifications. The index of the classification should match the index of the entity it corresponds to.',
39
+
40
+
41
+ class EntityClassification(BaseModel):
42
+ entity_classifications: list[EntityClassificationTriple] = Field(
43
+ ..., description='List of entities classification triples.'
41
44
  )
42
45
 
43
46
 
@@ -180,7 +183,7 @@ def classify_nodes(context: dict[str, Any]) -> list[Message]:
180
183
  {context['entity_types']}
181
184
  </ENTITY TYPES>
182
185
 
183
- Given the above conversation, extracted entities, and provided entity types, classify the extracted entities.
186
+ Given the above conversation, extracted entities, and provided entity types and their descriptions, classify the extracted entities.
184
187
 
185
188
  Guidelines:
186
189
  1. Each entity must have exactly one type
@@ -85,6 +85,8 @@ def summarize_context(context: dict[str, Any]) -> list[Message]:
85
85
  provided ENTITY. Summaries must be under 500 words.
86
86
 
87
87
  In addition, extract any values for the provided entity properties based on their descriptions.
88
+ If the value of the entity property cannot be found in the current context, set the value of the property to None.
89
+ Do not hallucinate entity property values if they cannot be found in the current context.
88
90
 
89
91
  <ENTITY>
90
92
  {context['node_name']}
@@ -18,14 +18,17 @@ import logging
18
18
  from time import time
19
19
 
20
20
  import pydantic
21
- from pydantic import BaseModel
22
21
 
23
22
  from graphiti_core.helpers import MAX_REFLEXION_ITERATIONS, semaphore_gather
24
23
  from graphiti_core.llm_client import LLMClient
25
- from graphiti_core.nodes import EntityNode, EpisodeType, EpisodicNode
24
+ from graphiti_core.nodes import EntityNode, EntityType, EpisodeType, EpisodicNode
26
25
  from graphiti_core.prompts import prompt_library
27
26
  from graphiti_core.prompts.dedupe_nodes import NodeDuplicate
28
- from graphiti_core.prompts.extract_nodes import EntityClassification, ExtractedNodes, MissedEntities
27
+ from graphiti_core.prompts.extract_nodes import (
28
+ EntityClassification,
29
+ ExtractedNodes,
30
+ MissedEntities,
31
+ )
29
32
  from graphiti_core.prompts.summarize_nodes import Summary
30
33
  from graphiti_core.utils.datetime_utils import utc_now
31
34
 
@@ -117,7 +120,7 @@ async def extract_nodes(
117
120
  llm_client: LLMClient,
118
121
  episode: EpisodicNode,
119
122
  previous_episodes: list[EpisodicNode],
120
- entity_types: dict[str, BaseModel] | None = None,
123
+ entity_types: dict[str, EntityType] | None = None,
121
124
  ) -> list[EntityNode]:
122
125
  start = time()
123
126
  extracted_node_names: list[str] = []
@@ -152,7 +155,11 @@ async def extract_nodes(
152
155
  'episode_content': episode.content,
153
156
  'previous_episodes': [ep.content for ep in previous_episodes],
154
157
  'extracted_entities': extracted_node_names,
155
- 'entity_types': entity_types.keys() if entity_types is not None else [],
158
+ 'entity_types': {
159
+ type_name: values.type_description for type_name, values in entity_types.items()
160
+ }
161
+ if entity_types is not None
162
+ else {},
156
163
  }
157
164
 
158
165
  node_classifications: dict[str, str | None] = {}
@@ -163,9 +170,13 @@ async def extract_nodes(
163
170
  prompt_library.extract_nodes.classify_nodes(node_classification_context),
164
171
  response_model=EntityClassification,
165
172
  )
166
- entities = llm_response.get('entities', [])
167
173
  entity_classifications = llm_response.get('entity_classifications', [])
168
- node_classifications.update(dict(zip(entities, entity_classifications)))
174
+ node_classifications.update(
175
+ {
176
+ entity_classification.get('name'): entity_classification.get('entity_type')
177
+ for entity_classification in entity_classifications
178
+ }
179
+ )
169
180
  # catch classification errors and continue if we can't classify
170
181
  except Exception as e:
171
182
  logger.exception(e)
@@ -251,7 +262,7 @@ async def resolve_extracted_nodes(
251
262
  existing_nodes_lists: list[list[EntityNode]],
252
263
  episode: EpisodicNode | None = None,
253
264
  previous_episodes: list[EpisodicNode] | None = None,
254
- entity_types: dict[str, BaseModel] | None = None,
265
+ entity_types: dict[str, EntityType] | None = None,
255
266
  ) -> tuple[list[EntityNode], dict[str, str]]:
256
267
  uuid_map: dict[str, str] = {}
257
268
  resolved_nodes: list[EntityNode] = []
@@ -284,7 +295,7 @@ async def resolve_extracted_node(
284
295
  existing_nodes: list[EntityNode],
285
296
  episode: EpisodicNode | None = None,
286
297
  previous_episodes: list[EpisodicNode] | None = None,
287
- entity_types: dict[str, BaseModel] | None = None,
298
+ entity_types: dict[str, EntityType] | None = None,
288
299
  ) -> tuple[EntityNode, dict[str, str]]:
289
300
  start = time()
290
301
 
@@ -319,7 +330,7 @@ async def resolve_extracted_node(
319
330
  'attributes': [],
320
331
  }
321
332
 
322
- entity_type_classes: tuple[BaseModel, ...] = tuple()
333
+ entity_type_classes: tuple[EntityType, ...] = tuple()
323
334
  if entity_types is not None: # type: ignore
324
335
  entity_type_classes = entity_type_classes + tuple(
325
336
  filter(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "graphiti-core"
3
- version = "0.7.7"
3
+ version = "0.7.8"
4
4
  description = "A temporal graph building library"
5
5
  authors = [
6
6
  "Paul Paliychuk <paul@getzep.com>",
File without changes
File without changes