graphiti-core 0.10.3__tar.gz → 0.10.5__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.
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/PKG-INFO +13 -5
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/README.md +12 -4
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/graphiti.py +1 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/anthropic_client.py +4 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/client.py +4 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/gemini_client.py +4 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/openai_client.py +4 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/openai_generic_client.py +4 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/nodes.py +22 -31
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/extract_edge_dates.py +1 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search_utils.py +21 -41
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/bulk_utils.py +2 -2
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/community_operations.py +5 -3
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/graph_data_operations.py +18 -10
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/node_operations.py +4 -2
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/pyproject.toml +1 -1
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/LICENSE +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/bge_reranker_client.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/client.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/openai_reranker_client.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/edges.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/embedder/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/embedder/client.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/embedder/gemini.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/embedder/openai.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/embedder/voyage.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/errors.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/helpers.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/config.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/errors.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/groq_client.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/utils.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/models/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/models/edges/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/models/edges/edge_db_queries.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/models/nodes/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/models/nodes/node_db_queries.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/dedupe_edges.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/dedupe_nodes.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/eval.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/extract_edges.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/extract_nodes.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/invalidate_edges.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/lib.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/models.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/prompt_helpers.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/prompts/summarize_nodes.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/py.typed +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search_config.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search_config_recipes.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search_filters.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/search/search_helpers.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/datetime_utils.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/__init__.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/edge_operations.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/temporal_operations.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/utils.py +0 -0
- {graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/ontology_utils/entity_types_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: graphiti-core
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.5
|
|
4
4
|
Summary: A temporal graph building library
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Paul Paliychuk
|
|
@@ -40,14 +40,22 @@ Description-Content-Type: text/markdown
|
|
|
40
40
|
Graphiti
|
|
41
41
|
</h1>
|
|
42
42
|
<h2 align="center"> Build Real-Time Knowledge Graphs for AI Agents</h2>
|
|
43
|
-
<
|
|
43
|
+
<div align="center">
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
[](https://github.com/getzep/Graphiti/actions/workflows/lint.yml)
|
|
45
|
+
|
|
46
|
+
[](https://github.com/getzep/Graphiti/actions/workflows/lint.yml)
|
|
47
47
|
[](https://github.com/getzep/Graphiti/actions/workflows/unit_tests.yml)
|
|
48
48
|
[](https://github.com/getzep/Graphiti/actions/workflows/typecheck.yml)
|
|
49
|
-
[](https://codespaces.new/getzep/Graphiti)
|
|
50
49
|
|
|
50
|
+
[](https://discord.com/invite/W8Kw6bsgXQ)
|
|
51
|
+
[](https://arxiv.org/abs/2501.13956)
|
|
52
|
+
[](https://github.com/getzep/graphiti/releases)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
<div align="center">
|
|
56
|
+
|
|
57
|
+
<a href="https://trendshift.io/repositories/12986" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12986" alt="getzep%2Fgraphiti | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
58
|
+
</div>
|
|
51
59
|
:star: _Help us reach more developers and grow the Graphiti community. Star this repo!_
|
|
52
60
|
<br />
|
|
53
61
|
|
|
@@ -8,14 +8,22 @@
|
|
|
8
8
|
Graphiti
|
|
9
9
|
</h1>
|
|
10
10
|
<h2 align="center"> Build Real-Time Knowledge Graphs for AI Agents</h2>
|
|
11
|
-
<
|
|
11
|
+
<div align="center">
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
[](https://github.com/getzep/Graphiti/actions/workflows/lint.yml)
|
|
13
|
+
|
|
14
|
+
[](https://github.com/getzep/Graphiti/actions/workflows/lint.yml)
|
|
15
15
|
[](https://github.com/getzep/Graphiti/actions/workflows/unit_tests.yml)
|
|
16
16
|
[](https://github.com/getzep/Graphiti/actions/workflows/typecheck.yml)
|
|
17
|
-
[](https://codespaces.new/getzep/Graphiti)
|
|
18
17
|
|
|
18
|
+
[](https://discord.com/invite/W8Kw6bsgXQ)
|
|
19
|
+
[](https://arxiv.org/abs/2501.13956)
|
|
20
|
+
[](https://github.com/getzep/graphiti/releases)
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
<a href="https://trendshift.io/repositories/12986" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12986" alt="getzep%2Fgraphiti | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
26
|
+
</div>
|
|
19
27
|
:star: _Help us reach more developers and grow the Graphiti community. Star this repo!_
|
|
20
28
|
<br />
|
|
21
29
|
|
|
@@ -797,7 +797,7 @@ class Graphiti:
|
|
|
797
797
|
# We should only delete edges created by the episode
|
|
798
798
|
edges_to_delete: list[EntityEdge] = []
|
|
799
799
|
for edge in edges:
|
|
800
|
-
if edge.episodes[0] == episode.uuid:
|
|
800
|
+
if edge.episodes and edge.episodes[0] == episode.uuid:
|
|
801
801
|
edges_to_delete.append(edge)
|
|
802
802
|
|
|
803
803
|
# Find nodes mentioned by the episode
|
|
@@ -262,7 +262,7 @@ class AnthropicClient(LLMClient):
|
|
|
262
262
|
self,
|
|
263
263
|
messages: list[Message],
|
|
264
264
|
response_model: type[BaseModel] | None = None,
|
|
265
|
-
max_tokens: int =
|
|
265
|
+
max_tokens: int | None = None,
|
|
266
266
|
) -> dict[str, typing.Any]:
|
|
267
267
|
"""
|
|
268
268
|
Generate a response from the LLM.
|
|
@@ -280,6 +280,9 @@ class AnthropicClient(LLMClient):
|
|
|
280
280
|
RefusalError: If the LLM refuses to respond.
|
|
281
281
|
Exception: If an error occurs during the generation process.
|
|
282
282
|
"""
|
|
283
|
+
if max_tokens is None:
|
|
284
|
+
max_tokens = self.max_tokens
|
|
285
|
+
|
|
283
286
|
retry_count = 0
|
|
284
287
|
max_retries = 2
|
|
285
288
|
last_error: Exception | None = None
|
|
@@ -127,8 +127,11 @@ class LLMClient(ABC):
|
|
|
127
127
|
self,
|
|
128
128
|
messages: list[Message],
|
|
129
129
|
response_model: type[BaseModel] | None = None,
|
|
130
|
-
max_tokens: int =
|
|
130
|
+
max_tokens: int | None = None,
|
|
131
131
|
) -> dict[str, typing.Any]:
|
|
132
|
+
if max_tokens is None:
|
|
133
|
+
max_tokens = self.max_tokens
|
|
134
|
+
|
|
132
135
|
if response_model is not None:
|
|
133
136
|
serialized_model = json.dumps(response_model.model_json_schema())
|
|
134
137
|
messages[
|
|
@@ -166,7 +166,7 @@ class GeminiClient(LLMClient):
|
|
|
166
166
|
self,
|
|
167
167
|
messages: list[Message],
|
|
168
168
|
response_model: type[BaseModel] | None = None,
|
|
169
|
-
max_tokens: int =
|
|
169
|
+
max_tokens: int | None = None,
|
|
170
170
|
) -> dict[str, typing.Any]:
|
|
171
171
|
"""
|
|
172
172
|
Generate a response from the Gemini language model.
|
|
@@ -180,6 +180,9 @@ class GeminiClient(LLMClient):
|
|
|
180
180
|
Returns:
|
|
181
181
|
dict[str, typing.Any]: The response from the language model.
|
|
182
182
|
"""
|
|
183
|
+
if max_tokens is None:
|
|
184
|
+
max_tokens = self.max_tokens
|
|
185
|
+
|
|
183
186
|
# Call the internal _generate_response method
|
|
184
187
|
return await self._generate_response(
|
|
185
188
|
messages=messages, response_model=response_model, max_tokens=max_tokens
|
|
@@ -131,8 +131,11 @@ class OpenAIClient(LLMClient):
|
|
|
131
131
|
self,
|
|
132
132
|
messages: list[Message],
|
|
133
133
|
response_model: type[BaseModel] | None = None,
|
|
134
|
-
max_tokens: int =
|
|
134
|
+
max_tokens: int | None = None,
|
|
135
135
|
) -> dict[str, typing.Any]:
|
|
136
|
+
if max_tokens is None:
|
|
137
|
+
max_tokens = self.max_tokens
|
|
138
|
+
|
|
136
139
|
retry_count = 0
|
|
137
140
|
last_error = None
|
|
138
141
|
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/llm_client/openai_generic_client.py
RENAMED
|
@@ -117,8 +117,11 @@ class OpenAIGenericClient(LLMClient):
|
|
|
117
117
|
self,
|
|
118
118
|
messages: list[Message],
|
|
119
119
|
response_model: type[BaseModel] | None = None,
|
|
120
|
-
max_tokens: int =
|
|
120
|
+
max_tokens: int | None = None,
|
|
121
121
|
) -> dict[str, typing.Any]:
|
|
122
|
+
if max_tokens is None:
|
|
123
|
+
max_tokens = self.max_tokens
|
|
124
|
+
|
|
122
125
|
retry_count = 0
|
|
123
126
|
last_error = None
|
|
124
127
|
|
|
@@ -38,6 +38,18 @@ from graphiti_core.utils.datetime_utils import utc_now
|
|
|
38
38
|
|
|
39
39
|
logger = logging.getLogger(__name__)
|
|
40
40
|
|
|
41
|
+
ENTITY_NODE_RETURN: LiteralString = """
|
|
42
|
+
RETURN
|
|
43
|
+
n.uuid As uuid,
|
|
44
|
+
n.name AS name,
|
|
45
|
+
n.name_embedding AS name_embedding,
|
|
46
|
+
n.group_id AS group_id,
|
|
47
|
+
n.created_at AS created_at,
|
|
48
|
+
n.summary AS summary,
|
|
49
|
+
labels(n) AS labels,
|
|
50
|
+
properties(n) AS attributes
|
|
51
|
+
"""
|
|
52
|
+
|
|
41
53
|
|
|
42
54
|
class EpisodeType(Enum):
|
|
43
55
|
"""
|
|
@@ -318,19 +330,14 @@ class EntityNode(Node):
|
|
|
318
330
|
|
|
319
331
|
@classmethod
|
|
320
332
|
async def get_by_uuid(cls, driver: AsyncDriver, uuid: str):
|
|
321
|
-
|
|
333
|
+
query = (
|
|
322
334
|
"""
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
n.created_at AS created_at,
|
|
330
|
-
n.summary AS summary,
|
|
331
|
-
labels(n) AS labels,
|
|
332
|
-
properties(n) AS attributes
|
|
333
|
-
""",
|
|
335
|
+
MATCH (n:Entity {uuid: $uuid})
|
|
336
|
+
"""
|
|
337
|
+
+ ENTITY_NODE_RETURN
|
|
338
|
+
)
|
|
339
|
+
records, _, _ = await driver.execute_query(
|
|
340
|
+
query,
|
|
334
341
|
uuid=uuid,
|
|
335
342
|
database_=DEFAULT_DATABASE,
|
|
336
343
|
routing_='r',
|
|
@@ -348,16 +355,8 @@ class EntityNode(Node):
|
|
|
348
355
|
records, _, _ = await driver.execute_query(
|
|
349
356
|
"""
|
|
350
357
|
MATCH (n:Entity) WHERE n.uuid IN $uuids
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
n.name AS name,
|
|
354
|
-
n.name_embedding AS name_embedding,
|
|
355
|
-
n.group_id AS group_id,
|
|
356
|
-
n.created_at AS created_at,
|
|
357
|
-
n.summary AS summary,
|
|
358
|
-
labels(n) AS labels,
|
|
359
|
-
properties(n) AS attributes
|
|
360
|
-
""",
|
|
358
|
+
"""
|
|
359
|
+
+ ENTITY_NODE_RETURN,
|
|
361
360
|
uuids=uuids,
|
|
362
361
|
database_=DEFAULT_DATABASE,
|
|
363
362
|
routing_='r',
|
|
@@ -383,16 +382,8 @@ class EntityNode(Node):
|
|
|
383
382
|
MATCH (n:Entity) WHERE n.group_id IN $group_ids
|
|
384
383
|
"""
|
|
385
384
|
+ cursor_query
|
|
385
|
+
+ ENTITY_NODE_RETURN
|
|
386
386
|
+ """
|
|
387
|
-
RETURN
|
|
388
|
-
n.uuid As uuid,
|
|
389
|
-
n.name AS name,
|
|
390
|
-
n.name_embedding AS name_embedding,
|
|
391
|
-
n.group_id AS group_id,
|
|
392
|
-
n.created_at AS created_at,
|
|
393
|
-
n.summary AS summary,
|
|
394
|
-
labels(n) AS labels,
|
|
395
|
-
properties(n) AS attributes
|
|
396
387
|
ORDER BY n.uuid DESC
|
|
397
388
|
"""
|
|
398
389
|
+ limit_query,
|
|
@@ -82,6 +82,7 @@ def v1(context: dict[str, Any]) -> list[Message]:
|
|
|
82
82
|
7. If only a date is mentioned without a specific time, use 00:00:00 (midnight) for that date.
|
|
83
83
|
8. If only year is mentioned, use January 1st of that year at 00:00:00.
|
|
84
84
|
9. Always include the time zone offset (use Z for UTC if no specific time zone is mentioned).
|
|
85
|
+
10. A fact discussing that something is no longer true should have a valid_at according to when the negated fact became true.
|
|
85
86
|
""",
|
|
86
87
|
),
|
|
87
88
|
]
|
|
@@ -32,6 +32,7 @@ from graphiti_core.helpers import (
|
|
|
32
32
|
semaphore_gather,
|
|
33
33
|
)
|
|
34
34
|
from graphiti_core.nodes import (
|
|
35
|
+
ENTITY_NODE_RETURN,
|
|
35
36
|
CommunityNode,
|
|
36
37
|
EntityNode,
|
|
37
38
|
EpisodicNode,
|
|
@@ -230,8 +231,8 @@ async def edge_similarity_search(
|
|
|
230
231
|
|
|
231
232
|
query: LiteralString = (
|
|
232
233
|
"""
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
MATCH (n:Entity)-[r:RELATES_TO]->(m:Entity)
|
|
235
|
+
"""
|
|
235
236
|
+ group_filter_query
|
|
236
237
|
+ filter_query
|
|
237
238
|
+ """\nWITH DISTINCT r, vector.similarity.cosine(r.fact_embedding, $search_vector) AS score
|
|
@@ -341,27 +342,21 @@ async def node_fulltext_search(
|
|
|
341
342
|
|
|
342
343
|
filter_query, filter_params = node_search_filter_query_constructor(search_filter)
|
|
343
344
|
|
|
344
|
-
|
|
345
|
-
"""
|
|
346
|
-
CALL db.index.fulltext.queryNodes("node_name_and_summary", $query, {limit: $limit})
|
|
347
|
-
YIELD node AS node, score
|
|
348
|
-
MATCH (n:Entity)
|
|
349
|
-
WHERE n.uuid = node.uuid
|
|
345
|
+
query = (
|
|
350
346
|
"""
|
|
347
|
+
CALL db.index.fulltext.queryNodes("node_name_and_summary", $query, {limit: $limit})
|
|
348
|
+
YIELD node AS n, score
|
|
349
|
+
WHERE n:Entity
|
|
350
|
+
"""
|
|
351
351
|
+ filter_query
|
|
352
|
+
+ ENTITY_NODE_RETURN
|
|
352
353
|
+ """
|
|
353
|
-
RETURN
|
|
354
|
-
n.uuid AS uuid,
|
|
355
|
-
n.group_id AS group_id,
|
|
356
|
-
n.name AS name,
|
|
357
|
-
n.name_embedding AS name_embedding,
|
|
358
|
-
n.created_at AS created_at,
|
|
359
|
-
n.summary AS summary,
|
|
360
|
-
labels(n) AS labels,
|
|
361
|
-
properties(n) AS attributes
|
|
362
354
|
ORDER BY score DESC
|
|
363
|
-
|
|
364
|
-
|
|
355
|
+
"""
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
records, _, _ = await driver.execute_query(
|
|
359
|
+
query,
|
|
365
360
|
filter_params,
|
|
366
361
|
query=fuzzy_query,
|
|
367
362
|
group_ids=group_ids,
|
|
@@ -406,19 +401,12 @@ async def node_similarity_search(
|
|
|
406
401
|
+ filter_query
|
|
407
402
|
+ """
|
|
408
403
|
WITH n, vector.similarity.cosine(n.name_embedding, $search_vector) AS score
|
|
409
|
-
WHERE score > $min_score
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
n.created_at AS created_at,
|
|
416
|
-
n.summary AS summary,
|
|
417
|
-
labels(n) AS labels,
|
|
418
|
-
properties(n) AS attributes
|
|
419
|
-
ORDER BY score DESC
|
|
420
|
-
LIMIT $limit
|
|
421
|
-
""",
|
|
404
|
+
WHERE score > $min_score"""
|
|
405
|
+
+ ENTITY_NODE_RETURN
|
|
406
|
+
+ """
|
|
407
|
+
ORDER BY score DESC
|
|
408
|
+
LIMIT $limit
|
|
409
|
+
""",
|
|
422
410
|
query_params,
|
|
423
411
|
search_vector=search_vector,
|
|
424
412
|
group_ids=group_ids,
|
|
@@ -452,16 +440,8 @@ async def node_bfs_search(
|
|
|
452
440
|
WHERE n.group_id = origin.group_id
|
|
453
441
|
"""
|
|
454
442
|
+ filter_query
|
|
443
|
+
+ ENTITY_NODE_RETURN
|
|
455
444
|
+ """
|
|
456
|
-
RETURN DISTINCT
|
|
457
|
-
n.uuid As uuid,
|
|
458
|
-
n.group_id AS group_id,
|
|
459
|
-
n.name AS name,
|
|
460
|
-
n.name_embedding AS name_embedding,
|
|
461
|
-
n.created_at AS created_at,
|
|
462
|
-
n.summary AS summary,
|
|
463
|
-
labels(n) AS labels,
|
|
464
|
-
properties(n) AS attributes
|
|
465
445
|
LIMIT $limit
|
|
466
446
|
""",
|
|
467
447
|
filter_params,
|
|
@@ -26,7 +26,7 @@ from pydantic import BaseModel
|
|
|
26
26
|
from typing_extensions import Any
|
|
27
27
|
|
|
28
28
|
from graphiti_core.edges import Edge, EntityEdge, EpisodicEdge
|
|
29
|
-
from graphiti_core.helpers import semaphore_gather
|
|
29
|
+
from graphiti_core.helpers import DEFAULT_DATABASE, semaphore_gather
|
|
30
30
|
from graphiti_core.llm_client import LLMClient
|
|
31
31
|
from graphiti_core.models.edges.edge_db_queries import (
|
|
32
32
|
ENTITY_EDGE_SAVE_BULK,
|
|
@@ -95,7 +95,7 @@ async def add_nodes_and_edges_bulk(
|
|
|
95
95
|
entity_nodes: list[EntityNode],
|
|
96
96
|
entity_edges: list[EntityEdge],
|
|
97
97
|
):
|
|
98
|
-
async with driver.session() as session:
|
|
98
|
+
async with driver.session(database=DEFAULT_DATABASE) as session:
|
|
99
99
|
await session.execute_write(
|
|
100
100
|
add_nodes_and_edges_bulk_tx, episodic_nodes, episodic_edges, entity_nodes, entity_edges
|
|
101
101
|
)
|
|
@@ -101,9 +101,11 @@ def label_propagation(projection: dict[str, list[Neighbor]]) -> list[list[str]]:
|
|
|
101
101
|
]
|
|
102
102
|
|
|
103
103
|
community_lst.sort(reverse=True)
|
|
104
|
-
community_candidate = community_lst[0]
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
candidate_rank, community_candidate = community_lst[0] if community_lst else (0, -1)
|
|
105
|
+
if community_candidate != -1 and candidate_rank > 1:
|
|
106
|
+
new_community = community_candidate
|
|
107
|
+
else:
|
|
108
|
+
new_community = max(community_candidate, curr_community)
|
|
107
109
|
|
|
108
110
|
new_community_map[uuid] = new_community
|
|
109
111
|
|
|
@@ -42,7 +42,7 @@ async def build_indices_and_constraints(driver: AsyncDriver, delete_existing: bo
|
|
|
42
42
|
driver.execute_query(
|
|
43
43
|
"""DROP INDEX $name""",
|
|
44
44
|
name=name,
|
|
45
|
-
|
|
45
|
+
database_=DEFAULT_DATABASE,
|
|
46
46
|
)
|
|
47
47
|
for name in index_names
|
|
48
48
|
]
|
|
@@ -72,7 +72,7 @@ async def build_indices_and_constraints(driver: AsyncDriver, delete_existing: bo
|
|
|
72
72
|
|
|
73
73
|
fulltext_indices: list[LiteralString] = [
|
|
74
74
|
"""CREATE FULLTEXT INDEX episode_content IF NOT EXISTS
|
|
75
|
-
FOR (e:Episodic) ON EACH [e.content, e.source, e.group_id]""",
|
|
75
|
+
FOR (e:Episodic) ON EACH [e.content, e.source, e.source_description, e.group_id]""",
|
|
76
76
|
"""CREATE FULLTEXT INDEX node_name_and_summary IF NOT EXISTS
|
|
77
77
|
FOR (n:Entity) ON EACH [n.name, n.summary, n.group_id]""",
|
|
78
78
|
"""CREATE FULLTEXT INDEX community_name IF NOT EXISTS
|
|
@@ -87,7 +87,7 @@ async def build_indices_and_constraints(driver: AsyncDriver, delete_existing: bo
|
|
|
87
87
|
*[
|
|
88
88
|
driver.execute_query(
|
|
89
89
|
query,
|
|
90
|
-
|
|
90
|
+
database_=DEFAULT_DATABASE,
|
|
91
91
|
)
|
|
92
92
|
for query in index_queries
|
|
93
93
|
]
|
|
@@ -95,7 +95,7 @@ async def build_indices_and_constraints(driver: AsyncDriver, delete_existing: bo
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
async def clear_data(driver: AsyncDriver, group_ids: list[str] | None = None):
|
|
98
|
-
async with driver.session() as session:
|
|
98
|
+
async with driver.session(database=DEFAULT_DATABASE) as session:
|
|
99
99
|
|
|
100
100
|
async def delete_all(tx):
|
|
101
101
|
await tx.run('MATCH (n) DETACH DELETE n')
|
|
@@ -132,10 +132,14 @@ async def retrieve_episodes(
|
|
|
132
132
|
Returns:
|
|
133
133
|
list[EpisodicNode]: A list of EpisodicNode objects representing the retrieved episodes.
|
|
134
134
|
"""
|
|
135
|
-
|
|
135
|
+
group_id_filter: LiteralString = 'AND e.group_id IN $group_ids' if group_ids and len(group_ids) > 0 else ''
|
|
136
|
+
|
|
137
|
+
query: LiteralString = (
|
|
136
138
|
"""
|
|
137
|
-
MATCH (e:Episodic) WHERE e.valid_at <= $reference_time
|
|
138
|
-
|
|
139
|
+
MATCH (e:Episodic) WHERE e.valid_at <= $reference_time
|
|
140
|
+
"""
|
|
141
|
+
+ group_id_filter
|
|
142
|
+
+ """
|
|
139
143
|
RETURN e.content AS content,
|
|
140
144
|
e.created_at AS created_at,
|
|
141
145
|
e.valid_at AS valid_at,
|
|
@@ -144,13 +148,17 @@ async def retrieve_episodes(
|
|
|
144
148
|
e.name AS name,
|
|
145
149
|
e.source_description AS source_description,
|
|
146
150
|
e.source AS source
|
|
147
|
-
ORDER BY e.
|
|
151
|
+
ORDER BY e.valid_at DESC
|
|
148
152
|
LIMIT $num_episodes
|
|
149
|
-
"""
|
|
153
|
+
"""
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
result = await driver.execute_query(
|
|
157
|
+
query,
|
|
150
158
|
reference_time=reference_time,
|
|
151
159
|
num_episodes=last_n,
|
|
152
160
|
group_ids=group_ids,
|
|
153
|
-
|
|
161
|
+
database_=DEFAULT_DATABASE,
|
|
154
162
|
)
|
|
155
163
|
episodes = [
|
|
156
164
|
EpisodicNode(
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/node_operations.py
RENAMED
|
@@ -306,7 +306,7 @@ async def resolve_extracted_node(
|
|
|
306
306
|
|
|
307
307
|
# Prepare context for LLM
|
|
308
308
|
existing_nodes_context = [
|
|
309
|
-
{'uuid': node.uuid, 'name': node.name, '
|
|
309
|
+
{**{'uuid': node.uuid, 'name': node.name, 'summary': node.summary}, **node.attributes}
|
|
310
310
|
for node in existing_nodes
|
|
311
311
|
]
|
|
312
312
|
|
|
@@ -408,6 +408,7 @@ async def resolve_extracted_node(
|
|
|
408
408
|
if new_attributes.get(attribute_name) is None:
|
|
409
409
|
new_attributes[attribute_name] = attribute_value
|
|
410
410
|
node.attributes = new_attributes
|
|
411
|
+
node.labels = list(set(existing_node.labels + extracted_node.labels))
|
|
411
412
|
|
|
412
413
|
uuid_map[extracted_node.uuid] = existing_node.uuid
|
|
413
414
|
|
|
@@ -432,7 +433,8 @@ async def dedupe_node_list(
|
|
|
432
433
|
|
|
433
434
|
# Prepare context for LLM
|
|
434
435
|
nodes_context = [
|
|
435
|
-
{'uuid': node.uuid, 'name': node.name, 'summary': node.summary}
|
|
436
|
+
{'uuid': node.uuid, 'name': node.name, 'summary': node.summary}.update(node.attributes)
|
|
437
|
+
for node in nodes
|
|
436
438
|
]
|
|
437
439
|
|
|
438
440
|
context = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "graphiti-core"
|
|
3
3
|
description = "A temporal graph building library"
|
|
4
|
-
version = "0.10.
|
|
4
|
+
version = "0.10.5"
|
|
5
5
|
authors = [
|
|
6
6
|
{ "name" = "Paul Paliychuk", "email" = "paul@getzep.com" },
|
|
7
7
|
{ "name" = "Preston Rasmussen", "email" = "preston@getzep.com" },
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/bge_reranker_client.py
RENAMED
|
File without changes
|
|
File without changes
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/cross_encoder/openai_reranker_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/edge_operations.py
RENAMED
|
File without changes
|
{graphiti_core-0.10.3 → graphiti_core-0.10.5}/graphiti_core/utils/maintenance/temporal_operations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|