graphiti-core 0.3.17__py3-none-any.whl → 0.3.19__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.
- graphiti_core/edges.py +1 -1
- graphiti_core/embedder/client.py +1 -1
- graphiti_core/embedder/openai.py +4 -2
- graphiti_core/embedder/voyage.py +13 -2
- graphiti_core/llm_client/utils.py +1 -1
- graphiti_core/nodes.py +2 -2
- graphiti_core/search/search.py +16 -6
- graphiti_core/search/search_utils.py +6 -1
- {graphiti_core-0.3.17.dist-info → graphiti_core-0.3.19.dist-info}/METADATA +2 -2
- {graphiti_core-0.3.17.dist-info → graphiti_core-0.3.19.dist-info}/RECORD +12 -12
- {graphiti_core-0.3.17.dist-info → graphiti_core-0.3.19.dist-info}/LICENSE +0 -0
- {graphiti_core-0.3.17.dist-info → graphiti_core-0.3.19.dist-info}/WHEEL +0 -0
graphiti_core/edges.py
CHANGED
|
@@ -180,7 +180,7 @@ class EntityEdge(Edge):
|
|
|
180
180
|
start = time()
|
|
181
181
|
|
|
182
182
|
text = self.fact.replace('\n', ' ')
|
|
183
|
-
self.fact_embedding = await embedder.create(
|
|
183
|
+
self.fact_embedding = await embedder.create(input_data=[text])
|
|
184
184
|
|
|
185
185
|
end = time()
|
|
186
186
|
logger.debug(f'embedded {text} in {end - start} ms')
|
graphiti_core/embedder/client.py
CHANGED
|
@@ -29,6 +29,6 @@ class EmbedderConfig(BaseModel):
|
|
|
29
29
|
class EmbedderClient(ABC):
|
|
30
30
|
@abstractmethod
|
|
31
31
|
async def create(
|
|
32
|
-
self,
|
|
32
|
+
self, input_data: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
|
|
33
33
|
) -> list[float]:
|
|
34
34
|
pass
|
graphiti_core/embedder/openai.py
CHANGED
|
@@ -42,7 +42,9 @@ class OpenAIEmbedder(EmbedderClient):
|
|
|
42
42
|
self.client = AsyncOpenAI(api_key=config.api_key, base_url=config.base_url)
|
|
43
43
|
|
|
44
44
|
async def create(
|
|
45
|
-
self,
|
|
45
|
+
self, input_data: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
|
|
46
46
|
) -> list[float]:
|
|
47
|
-
result = await self.client.embeddings.create(
|
|
47
|
+
result = await self.client.embeddings.create(
|
|
48
|
+
input=input_data, model=self.config.embedding_model
|
|
49
|
+
)
|
|
48
50
|
return result.data[0].embedding[: self.config.embedding_dim]
|
graphiti_core/embedder/voyage.py
CHANGED
|
@@ -41,7 +41,18 @@ class VoyageAIEmbedder(EmbedderClient):
|
|
|
41
41
|
self.client = voyageai.AsyncClient(api_key=config.api_key)
|
|
42
42
|
|
|
43
43
|
async def create(
|
|
44
|
-
self,
|
|
44
|
+
self, input_data: str | List[str] | Iterable[int] | Iterable[Iterable[int]]
|
|
45
45
|
) -> list[float]:
|
|
46
|
-
|
|
46
|
+
if isinstance(input_data, str):
|
|
47
|
+
input_list = [input_data]
|
|
48
|
+
elif isinstance(input_data, List):
|
|
49
|
+
input_list = [str(i) for i in input_data if i]
|
|
50
|
+
else:
|
|
51
|
+
input_list = [str(i) for i in input_data if i is not None]
|
|
52
|
+
|
|
53
|
+
input_list = [i for i in input_list if i]
|
|
54
|
+
if len(input_list) == 0:
|
|
55
|
+
return []
|
|
56
|
+
|
|
57
|
+
result = await self.client.embed(input_list, model=self.config.embedding_model)
|
|
47
58
|
return result.embeddings[0][: self.config.embedding_dim]
|
|
@@ -26,7 +26,7 @@ async def generate_embedding(embedder: EmbedderClient, text: str):
|
|
|
26
26
|
start = time()
|
|
27
27
|
|
|
28
28
|
text = text.replace('\n', ' ')
|
|
29
|
-
embedding = await embedder.create(
|
|
29
|
+
embedding = await embedder.create(input_data=[text])
|
|
30
30
|
|
|
31
31
|
end = time()
|
|
32
32
|
logger.debug(f'embedded text of length {len(text)} in {end - start} ms')
|
graphiti_core/nodes.py
CHANGED
|
@@ -222,7 +222,7 @@ class EntityNode(Node):
|
|
|
222
222
|
async def generate_name_embedding(self, embedder: EmbedderClient):
|
|
223
223
|
start = time()
|
|
224
224
|
text = self.name.replace('\n', ' ')
|
|
225
|
-
self.name_embedding = await embedder.create(
|
|
225
|
+
self.name_embedding = await embedder.create(input_data=[text])
|
|
226
226
|
end = time()
|
|
227
227
|
logger.debug(f'embedded {text} in {end - start} ms')
|
|
228
228
|
|
|
@@ -334,7 +334,7 @@ class CommunityNode(Node):
|
|
|
334
334
|
async def generate_name_embedding(self, embedder: EmbedderClient):
|
|
335
335
|
start = time()
|
|
336
336
|
text = self.name.replace('\n', ' ')
|
|
337
|
-
self.name_embedding = await embedder.create(
|
|
337
|
+
self.name_embedding = await embedder.create(input_data=[text])
|
|
338
338
|
end = time()
|
|
339
339
|
logger.debug(f'embedded {text} in {end - start} ms')
|
|
340
340
|
|
graphiti_core/search/search.py
CHANGED
|
@@ -45,6 +45,7 @@ from graphiti_core.search.search_utils import (
|
|
|
45
45
|
edge_similarity_search,
|
|
46
46
|
episode_mentions_reranker,
|
|
47
47
|
maximal_marginal_relevance,
|
|
48
|
+
node_bfs_search,
|
|
48
49
|
node_distance_reranker,
|
|
49
50
|
node_fulltext_search,
|
|
50
51
|
node_similarity_search,
|
|
@@ -65,7 +66,7 @@ async def search(
|
|
|
65
66
|
bfs_origin_node_uuids: list[str] | None = None,
|
|
66
67
|
) -> SearchResults:
|
|
67
68
|
start = time()
|
|
68
|
-
query_vector = await embedder.create(
|
|
69
|
+
query_vector = await embedder.create(input_data=[query.replace('\n', ' ')])
|
|
69
70
|
|
|
70
71
|
# if group_ids is empty, set it to None
|
|
71
72
|
group_ids = group_ids if group_ids else None
|
|
@@ -138,7 +139,7 @@ async def edge_search(
|
|
|
138
139
|
edge_similarity_search(
|
|
139
140
|
driver, query_vector, None, None, group_ids, 2 * limit, config.sim_min_score
|
|
140
141
|
),
|
|
141
|
-
edge_bfs_search(driver, bfs_origin_node_uuids, config.bfs_max_depth),
|
|
142
|
+
edge_bfs_search(driver, bfs_origin_node_uuids, config.bfs_max_depth, 2 * limit),
|
|
142
143
|
]
|
|
143
144
|
)
|
|
144
145
|
)
|
|
@@ -160,7 +161,12 @@ async def edge_search(
|
|
|
160
161
|
query_vector, search_result_uuids_and_vectors, config.mmr_lambda
|
|
161
162
|
)
|
|
162
163
|
elif config.reranker == EdgeReranker.cross_encoder:
|
|
163
|
-
|
|
164
|
+
search_result_uuids = [[edge.uuid for edge in result] for result in search_results]
|
|
165
|
+
|
|
166
|
+
rrf_result_uuids = rrf(search_result_uuids)
|
|
167
|
+
rrf_edges = [edge_uuid_map[uuid] for uuid in rrf_result_uuids][:limit]
|
|
168
|
+
|
|
169
|
+
fact_to_uuid_map = {edge.fact: edge.uuid for edge in rrf_edges}
|
|
164
170
|
reranked_facts = await cross_encoder.rank(query, list(fact_to_uuid_map.keys()))
|
|
165
171
|
reranked_uuids = [fact_to_uuid_map[fact] for fact, _ in reranked_facts]
|
|
166
172
|
elif config.reranker == EdgeReranker.node_distance:
|
|
@@ -212,6 +218,7 @@ async def node_search(
|
|
|
212
218
|
node_similarity_search(
|
|
213
219
|
driver, query_vector, group_ids, 2 * limit, config.sim_min_score
|
|
214
220
|
),
|
|
221
|
+
node_bfs_search(driver, bfs_origin_node_uuids, config.bfs_max_depth, 2 * limit),
|
|
215
222
|
]
|
|
216
223
|
)
|
|
217
224
|
)
|
|
@@ -232,9 +239,12 @@ async def node_search(
|
|
|
232
239
|
query_vector, search_result_uuids_and_vectors, config.mmr_lambda
|
|
233
240
|
)
|
|
234
241
|
elif config.reranker == NodeReranker.cross_encoder:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
242
|
+
# use rrf as a preliminary reranker
|
|
243
|
+
rrf_result_uuids = rrf(search_result_uuids)
|
|
244
|
+
rrf_results = [node_uuid_map[uuid] for uuid in rrf_result_uuids][:limit]
|
|
245
|
+
|
|
246
|
+
summary_to_uuid_map = {node.summary: node.uuid for node in rrf_results}
|
|
247
|
+
|
|
238
248
|
reranked_summaries = await cross_encoder.rank(query, list(summary_to_uuid_map.keys()))
|
|
239
249
|
reranked_uuids = [summary_to_uuid_map[fact] for fact, _ in reranked_summaries]
|
|
240
250
|
elif config.reranker == NodeReranker.episode_mentions:
|
|
@@ -233,6 +233,7 @@ async def edge_bfs_search(
|
|
|
233
233
|
driver: AsyncDriver,
|
|
234
234
|
bfs_origin_node_uuids: list[str] | None,
|
|
235
235
|
bfs_max_depth: int,
|
|
236
|
+
limit: int,
|
|
236
237
|
) -> list[EntityEdge]:
|
|
237
238
|
# vector similarity search over embedded facts
|
|
238
239
|
if bfs_origin_node_uuids is None:
|
|
@@ -256,12 +257,14 @@ async def edge_bfs_search(
|
|
|
256
257
|
r.expired_at AS expired_at,
|
|
257
258
|
r.valid_at AS valid_at,
|
|
258
259
|
r.invalid_at AS invalid_at
|
|
260
|
+
LIMIT $limit
|
|
259
261
|
""")
|
|
260
262
|
|
|
261
263
|
records, _, _ = await driver.execute_query(
|
|
262
264
|
query,
|
|
263
265
|
bfs_origin_node_uuids=bfs_origin_node_uuids,
|
|
264
266
|
depth=bfs_max_depth,
|
|
267
|
+
limit=limit,
|
|
265
268
|
database_=DEFAULT_DATABASE,
|
|
266
269
|
routing_='r',
|
|
267
270
|
)
|
|
@@ -348,6 +351,7 @@ async def node_bfs_search(
|
|
|
348
351
|
driver: AsyncDriver,
|
|
349
352
|
bfs_origin_node_uuids: list[str] | None,
|
|
350
353
|
bfs_max_depth: int,
|
|
354
|
+
limit: int,
|
|
351
355
|
) -> list[EntityNode]:
|
|
352
356
|
# vector similarity search over entity names
|
|
353
357
|
if bfs_origin_node_uuids is None:
|
|
@@ -368,6 +372,7 @@ async def node_bfs_search(
|
|
|
368
372
|
""",
|
|
369
373
|
bfs_origin_node_uuids=bfs_origin_node_uuids,
|
|
370
374
|
depth=bfs_max_depth,
|
|
375
|
+
limit=limit,
|
|
371
376
|
database_=DEFAULT_DATABASE,
|
|
372
377
|
routing_='r',
|
|
373
378
|
)
|
|
@@ -690,4 +695,4 @@ def maximal_marginal_relevance(
|
|
|
690
695
|
|
|
691
696
|
candidates_with_mmr.sort(reverse=True, key=lambda c: c[1])
|
|
692
697
|
|
|
693
|
-
return [candidate[0] for candidate in candidates_with_mmr]
|
|
698
|
+
return list(set([candidate[0] for candidate in candidates_with_mmr]))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: graphiti-core
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.19
|
|
4
4
|
Summary: A temporal graph building library
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Paul Paliychuk
|
|
@@ -14,7 +14,7 @@ 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
16
|
Requires-Dist: numpy (>=1.0.0)
|
|
17
|
-
Requires-Dist: openai (>=1.
|
|
17
|
+
Requires-Dist: openai (>=1.52.2,<2.0.0)
|
|
18
18
|
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
|
|
19
19
|
Requires-Dist: tenacity (<9.0.0)
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
@@ -3,11 +3,11 @@ graphiti_core/cross_encoder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
3
3
|
graphiti_core/cross_encoder/bge_reranker_client.py,sha256=jsXBUHfFpGsNASHaRnfz1_miQ3x070DdU8QS4J3DciI,1466
|
|
4
4
|
graphiti_core/cross_encoder/client.py,sha256=PyFYYsALQAD9wu0gL5uquPsulmaBZ0AZkJmLq2DFA-c,1472
|
|
5
5
|
graphiti_core/cross_encoder/openai_reranker_client.py,sha256=ij1E1Y5G9GNP3h3h8nSUF-ZJrQ921B54uudZUsCUaDc,4063
|
|
6
|
-
graphiti_core/edges.py,sha256=
|
|
6
|
+
graphiti_core/edges.py,sha256=wKXmNXtu1deT5MfcqUNGHQlBLgwt3MJ_3j35ibNbpi8,13087
|
|
7
7
|
graphiti_core/embedder/__init__.py,sha256=eWd-0sPxflnYXLoWNT9sxwCIFun5JNO9Fk4E-ZXXf8Y,164
|
|
8
|
-
graphiti_core/embedder/client.py,sha256=
|
|
9
|
-
graphiti_core/embedder/openai.py,sha256=
|
|
10
|
-
graphiti_core/embedder/voyage.py,sha256=
|
|
8
|
+
graphiti_core/embedder/client.py,sha256=gVr_xdN-d0UQfeE4Nyoa4pL3M8UxllNH4eFqmarxwys,1011
|
|
9
|
+
graphiti_core/embedder/openai.py,sha256=yYUYPymx_lBlxDTGrlc03yNhPFyGG-etM2sszRK2G2U,1618
|
|
10
|
+
graphiti_core/embedder/voyage.py,sha256=_eGFI5_NjNG8z7qG3jTWCdE7sAs1Yb8fiSZSJlQLD9o,1879
|
|
11
11
|
graphiti_core/errors.py,sha256=ddHrHGQxhwkVAtSph4AV84UoOlgwZufMczXPwB7uqPo,1795
|
|
12
12
|
graphiti_core/graphiti.py,sha256=c9Rh777TrHYffPF6qvFAfm-m-PA4kD8a3ZW_ShsZGxE,27714
|
|
13
13
|
graphiti_core/helpers.py,sha256=kqC2TD8Auwty4sG7KH4BuRMX413oTChGaAT_XUt9ZjU,2108
|
|
@@ -18,13 +18,13 @@ graphiti_core/llm_client/config.py,sha256=VwtvD0B7TNqE6Cl-rvH5v-bAfmjMLhEUuFmHSP
|
|
|
18
18
|
graphiti_core/llm_client/errors.py,sha256=-qlWwv1X-UjfsFIiNl-7yJIYvPwi7z8srVRfX4-s6uk,814
|
|
19
19
|
graphiti_core/llm_client/groq_client.py,sha256=5uGWeQ903EuNxuRiaeH-_J1U2Le_b7Q1UGV_K8bQAiw,2329
|
|
20
20
|
graphiti_core/llm_client/openai_client.py,sha256=xLkbpusRVFRK0zPr3kOqY31HK_XCXrpO5rqUSpcEqEU,3825
|
|
21
|
-
graphiti_core/llm_client/utils.py,sha256=
|
|
21
|
+
graphiti_core/llm_client/utils.py,sha256=zKpxXEbKa369m4W7RDEf-m56kH46V1Mx3RowcWZEWWs,1000
|
|
22
22
|
graphiti_core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
graphiti_core/models/edges/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
24
|
graphiti_core/models/edges/edge_db_queries.py,sha256=gUC5AZeXvobsIzG8Zqxj4Sa-j0PKV4CuEPHWupFTXQs,1145
|
|
25
25
|
graphiti_core/models/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
graphiti_core/models/nodes/node_db_queries.py,sha256=HxZIjVLqVRnG7OJHeZv7t3KCEWFTWvdNOBJyLSN-1Ts,918
|
|
27
|
-
graphiti_core/nodes.py,sha256=
|
|
27
|
+
graphiti_core/nodes.py,sha256=xlObDAC6Osp6L0wwqREuzBlIFlOzuUs9lN3ZpIv4seM,13844
|
|
28
28
|
graphiti_core/prompts/__init__.py,sha256=EA-x9xUki9l8wnu2l8ek_oNf75-do5tq5hVq7Zbv8Kw,101
|
|
29
29
|
graphiti_core/prompts/dedupe_edges.py,sha256=DUNHdIudj50FAjkla4nc68tSFSD2yjmYHBw-Bb7ph20,6529
|
|
30
30
|
graphiti_core/prompts/dedupe_nodes.py,sha256=BZ9S-PB9SSGjc5Oo8ivdgA6rZx3OGOFhKtwrBlQ0bm0,7269
|
|
@@ -38,10 +38,10 @@ graphiti_core/prompts/models.py,sha256=cvx_Bv5RMFUD_5IUawYrbpOKLPHogai7_bm7YXrSz
|
|
|
38
38
|
graphiti_core/prompts/summarize_nodes.py,sha256=FLuZpGTABgcxuIDkx_IKH115nHEw0rIaFhcGlWveAMc,2357
|
|
39
39
|
graphiti_core/py.typed,sha256=vlmmzQOt7bmeQl9L3XJP4W6Ry0iiELepnOrinKz5KQg,79
|
|
40
40
|
graphiti_core/search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
-
graphiti_core/search/search.py,sha256=
|
|
41
|
+
graphiti_core/search/search.py,sha256=Fz45sXToQ6KN_y2k94kg9UyUZeqsS14jfaGfQ5KGifQ,11176
|
|
42
42
|
graphiti_core/search/search_config.py,sha256=UZN8jFA4pBlw2O5N1cuhVRBdTwMLR9N3Oyo6sQ4MDVw,3117
|
|
43
43
|
graphiti_core/search/search_config_recipes.py,sha256=20jS7veJExDnXA-ovJSUJfyDHKt7GW-nng-eoiT7ATA,5810
|
|
44
|
-
graphiti_core/search/search_utils.py,sha256=
|
|
44
|
+
graphiti_core/search/search_utils.py,sha256=l8BR4GOo-A2eIXx4ybC18n6t6CeerN_9KQbYzCB6ix0,22551
|
|
45
45
|
graphiti_core/utils/__init__.py,sha256=cJAcMnBZdHBQmWrZdU1PQ1YmaL75bhVUkyVpIPuOyns,260
|
|
46
46
|
graphiti_core/utils/bulk_utils.py,sha256=JtoYTZPCigPa3n2E43Oe7QhFZRTA_QKNGy1jVgklHag,12614
|
|
47
47
|
graphiti_core/utils/maintenance/__init__.py,sha256=TRY3wWWu5kn3Oahk_KKhltrWnh0NACw0FskjqF6OtlA,314
|
|
@@ -51,7 +51,7 @@ graphiti_core/utils/maintenance/graph_data_operations.py,sha256=w66_SLlvPapuG91Y
|
|
|
51
51
|
graphiti_core/utils/maintenance/node_operations.py,sha256=h5nlRojbXOGJs-alpv6z6WnZ1UCixVGlAQYBQUqz8Bs,9030
|
|
52
52
|
graphiti_core/utils/maintenance/temporal_operations.py,sha256=MvaRLWrBlDeYw8CQrKish1xbYcY5ovpfdqA2hSX7v5k,3367
|
|
53
53
|
graphiti_core/utils/maintenance/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
|
-
graphiti_core-0.3.
|
|
55
|
-
graphiti_core-0.3.
|
|
56
|
-
graphiti_core-0.3.
|
|
57
|
-
graphiti_core-0.3.
|
|
54
|
+
graphiti_core-0.3.19.dist-info/LICENSE,sha256=KCUwCyDXuVEgmDWkozHyniRyWjnWUWjkuDHfU6o3JlA,11325
|
|
55
|
+
graphiti_core-0.3.19.dist-info/METADATA,sha256=uwulLozcE0fov_hyYb3rIWUtuvcy6BObIuOcfng0aaQ,9396
|
|
56
|
+
graphiti_core-0.3.19.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
57
|
+
graphiti_core-0.3.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|