graphiti-core 0.7.8__tar.gz → 0.8.0__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.8 → graphiti_core-0.8.0}/PKG-INFO +1 -1
  2. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/edges.py +26 -0
  3. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/graphiti.py +4 -7
  4. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/helpers.py +1 -1
  5. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/nodes.py +1 -7
  6. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/node_operations.py +8 -6
  7. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/pyproject.toml +1 -1
  8. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/LICENSE +0 -0
  9. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/README.md +0 -0
  10. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/__init__.py +0 -0
  11. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/cross_encoder/__init__.py +0 -0
  12. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/cross_encoder/bge_reranker_client.py +0 -0
  13. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/cross_encoder/client.py +0 -0
  14. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/cross_encoder/openai_reranker_client.py +0 -0
  15. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/embedder/__init__.py +0 -0
  16. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/embedder/client.py +0 -0
  17. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/embedder/openai.py +0 -0
  18. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/embedder/voyage.py +0 -0
  19. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/errors.py +0 -0
  20. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/__init__.py +0 -0
  21. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/anthropic_client.py +0 -0
  22. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/client.py +0 -0
  23. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/config.py +0 -0
  24. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/errors.py +0 -0
  25. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/groq_client.py +0 -0
  26. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/openai_client.py +0 -0
  27. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/openai_generic_client.py +0 -0
  28. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/llm_client/utils.py +0 -0
  29. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/models/__init__.py +0 -0
  30. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/models/edges/__init__.py +0 -0
  31. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/models/edges/edge_db_queries.py +0 -0
  32. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/models/nodes/__init__.py +0 -0
  33. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/models/nodes/node_db_queries.py +0 -0
  34. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/__init__.py +0 -0
  35. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/dedupe_edges.py +0 -0
  36. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/dedupe_nodes.py +0 -0
  37. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/eval.py +0 -0
  38. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/extract_edge_dates.py +0 -0
  39. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/extract_edges.py +0 -0
  40. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/extract_nodes.py +0 -0
  41. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/invalidate_edges.py +0 -0
  42. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/lib.py +0 -0
  43. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/models.py +0 -0
  44. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/prompt_helpers.py +0 -0
  45. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/prompts/summarize_nodes.py +0 -0
  46. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/py.typed +0 -0
  47. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/__init__.py +0 -0
  48. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/search.py +0 -0
  49. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/search_config.py +0 -0
  50. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/search_config_recipes.py +0 -0
  51. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/search_filters.py +0 -0
  52. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/search/search_utils.py +0 -0
  53. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/__init__.py +0 -0
  54. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/bulk_utils.py +0 -0
  55. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/datetime_utils.py +0 -0
  56. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/__init__.py +0 -0
  57. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/community_operations.py +0 -0
  58. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/edge_operations.py +0 -0
  59. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/graph_data_operations.py +0 -0
  60. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/graphiti_core/utils/maintenance/temporal_operations.py +0 -0
  61. {graphiti_core-0.7.8 → graphiti_core-0.8.0}/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.8
3
+ Version: 0.8.0
4
4
  Summary: A temporal graph building library
5
5
  License: Apache-2.0
6
6
  Author: Paul Paliychuk
@@ -337,6 +337,32 @@ class EntityEdge(Edge):
337
337
  raise GroupsEdgesNotFoundError(group_ids)
338
338
  return edges
339
339
 
340
+ @classmethod
341
+ async def get_by_node_uuid(cls, driver: AsyncDriver, node_uuid: str):
342
+ query: LiteralString = """
343
+ MATCH (n:Entity {uuid: $node_uuid})-[e:RELATES_TO]-(m:Entity)
344
+ RETURN DISTINCT
345
+ e.uuid AS uuid,
346
+ n.uuid AS source_node_uuid,
347
+ m.uuid AS target_node_uuid,
348
+ e.created_at AS created_at,
349
+ e.name AS name,
350
+ e.group_id AS group_id,
351
+ e.fact AS fact,
352
+ e.fact_embedding AS fact_embedding,
353
+ e.episodes AS episodes,
354
+ e.expired_at AS expired_at,
355
+ e.valid_at AS valid_at,
356
+ e.invalid_at AS invalid_at
357
+ """
358
+ records, _, _ = await driver.execute_query(
359
+ query, node_uuid=node_uuid, database_=DEFAULT_DATABASE, routing_='r'
360
+ )
361
+
362
+ edges = [get_entity_edge_from_record(record) for record in records]
363
+
364
+ return edges
365
+
340
366
 
341
367
  class CommunityEdge(Edge):
342
368
  async def save(self, driver: AsyncDriver):
@@ -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, EntityType, EpisodeType, EpisodicNode
32
+ from graphiti_core.nodes import CommunityNode, EntityNode, 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 (
@@ -39,7 +39,6 @@ from graphiti_core.search.search_config_recipes import (
39
39
  from graphiti_core.search.search_filters import SearchFilters
40
40
  from graphiti_core.search.search_utils import (
41
41
  RELEVANT_SCHEMA_LIMIT,
42
- get_communities_by_nodes,
43
42
  get_mentioned_nodes,
44
43
  get_relevant_edges,
45
44
  get_relevant_nodes,
@@ -262,7 +261,7 @@ class Graphiti:
262
261
  group_id: str = '',
263
262
  uuid: str | None = None,
264
263
  update_communities: bool = False,
265
- entity_types: dict[str, EntityType] | None = None,
264
+ entity_types: dict[str, BaseModel] | None = None,
266
265
  ) -> AddEpisodeResults:
267
266
  """
268
267
  Process an episode and update the graph.
@@ -708,7 +707,7 @@ class Graphiti:
708
707
  bfs_origin_node_uuids,
709
708
  )
710
709
 
711
- async def get_episode_mentions(self, episode_uuids: list[str]) -> SearchResults:
710
+ async def get_nodes_and_edges_by_episode(self, episode_uuids: list[str]) -> SearchResults:
712
711
  episodes = await EpisodicNode.get_by_uuids(self.driver, episode_uuids)
713
712
 
714
713
  edges_list = await semaphore_gather(
@@ -719,9 +718,7 @@ class Graphiti:
719
718
 
720
719
  nodes = await get_mentioned_nodes(self.driver, episodes)
721
720
 
722
- communities = await get_communities_by_nodes(self.driver, nodes)
723
-
724
- return SearchResults(edges=edges, nodes=nodes, communities=communities)
721
+ return SearchResults(edges=edges, nodes=nodes, communities=[])
725
722
 
726
723
  async def add_triplet(self, source_node: EntityNode, edge: EntityEdge, target_node: EntityNode):
727
724
  if source_node.name_embedding is None:
@@ -28,7 +28,7 @@ load_dotenv()
28
28
  DEFAULT_DATABASE = os.getenv('DEFAULT_DATABASE', None)
29
29
  USE_PARALLEL_RUNTIME = bool(os.getenv('USE_PARALLEL_RUNTIME', False))
30
30
  SEMAPHORE_LIMIT = int(os.getenv('SEMAPHORE_LIMIT', 20))
31
- MAX_REFLEXION_ITERATIONS = 2
31
+ MAX_REFLEXION_ITERATIONS = int(os.getenv('MAX_REFLEXION_ITERATIONS', 2))
32
32
  DEFAULT_PAGE_LIMIT = 20
33
33
 
34
34
 
@@ -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, ClassVar
22
+ from typing import Any
23
23
  from uuid import uuid4
24
24
 
25
25
  from neo4j import AsyncDriver
@@ -39,12 +39,6 @@ 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
-
48
42
  class EpisodeType(Enum):
49
43
  """
50
44
  Enumeration of different types of episodes that can be processed.
@@ -18,10 +18,11 @@ import logging
18
18
  from time import time
19
19
 
20
20
  import pydantic
21
+ from pydantic import BaseModel
21
22
 
22
23
  from graphiti_core.helpers import MAX_REFLEXION_ITERATIONS, semaphore_gather
23
24
  from graphiti_core.llm_client import LLMClient
24
- from graphiti_core.nodes import EntityNode, EntityType, EpisodeType, EpisodicNode
25
+ from graphiti_core.nodes import EntityNode, EpisodeType, EpisodicNode
25
26
  from graphiti_core.prompts import prompt_library
26
27
  from graphiti_core.prompts.dedupe_nodes import NodeDuplicate
27
28
  from graphiti_core.prompts.extract_nodes import (
@@ -120,7 +121,7 @@ async def extract_nodes(
120
121
  llm_client: LLMClient,
121
122
  episode: EpisodicNode,
122
123
  previous_episodes: list[EpisodicNode],
123
- entity_types: dict[str, EntityType] | None = None,
124
+ entity_types: dict[str, BaseModel] | None = None,
124
125
  ) -> list[EntityNode]:
125
126
  start = time()
126
127
  extracted_node_names: list[str] = []
@@ -156,7 +157,8 @@ async def extract_nodes(
156
157
  'previous_episodes': [ep.content for ep in previous_episodes],
157
158
  'extracted_entities': extracted_node_names,
158
159
  'entity_types': {
159
- type_name: values.type_description for type_name, values in entity_types.items()
160
+ type_name: values.model_json_schema().get('description')
161
+ for type_name, values in entity_types.items()
160
162
  }
161
163
  if entity_types is not None
162
164
  else {},
@@ -262,7 +264,7 @@ async def resolve_extracted_nodes(
262
264
  existing_nodes_lists: list[list[EntityNode]],
263
265
  episode: EpisodicNode | None = None,
264
266
  previous_episodes: list[EpisodicNode] | None = None,
265
- entity_types: dict[str, EntityType] | None = None,
267
+ entity_types: dict[str, BaseModel] | None = None,
266
268
  ) -> tuple[list[EntityNode], dict[str, str]]:
267
269
  uuid_map: dict[str, str] = {}
268
270
  resolved_nodes: list[EntityNode] = []
@@ -295,7 +297,7 @@ async def resolve_extracted_node(
295
297
  existing_nodes: list[EntityNode],
296
298
  episode: EpisodicNode | None = None,
297
299
  previous_episodes: list[EpisodicNode] | None = None,
298
- entity_types: dict[str, EntityType] | None = None,
300
+ entity_types: dict[str, BaseModel] | None = None,
299
301
  ) -> tuple[EntityNode, dict[str, str]]:
300
302
  start = time()
301
303
 
@@ -330,7 +332,7 @@ async def resolve_extracted_node(
330
332
  'attributes': [],
331
333
  }
332
334
 
333
- entity_type_classes: tuple[EntityType, ...] = tuple()
335
+ entity_type_classes: tuple[BaseModel, ...] = tuple()
334
336
  if entity_types is not None: # type: ignore
335
337
  entity_type_classes = entity_type_classes + tuple(
336
338
  filter(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "graphiti-core"
3
- version = "0.7.8"
3
+ version = "0.8.0"
4
4
  description = "A temporal graph building library"
5
5
  authors = [
6
6
  "Paul Paliychuk <paul@getzep.com>",
File without changes
File without changes