graphiti-core 0.12.0rc1__py3-none-any.whl → 0.24.3__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.
- graphiti_core/cross_encoder/bge_reranker_client.py +12 -2
- graphiti_core/cross_encoder/gemini_reranker_client.py +161 -0
- graphiti_core/cross_encoder/openai_reranker_client.py +7 -5
- graphiti_core/decorators.py +110 -0
- graphiti_core/driver/__init__.py +19 -0
- graphiti_core/driver/driver.py +124 -0
- graphiti_core/driver/falkordb_driver.py +362 -0
- graphiti_core/driver/graph_operations/graph_operations.py +191 -0
- graphiti_core/driver/kuzu_driver.py +182 -0
- graphiti_core/driver/neo4j_driver.py +117 -0
- graphiti_core/driver/neptune_driver.py +305 -0
- graphiti_core/driver/search_interface/search_interface.py +89 -0
- graphiti_core/edges.py +287 -172
- graphiti_core/embedder/azure_openai.py +71 -0
- graphiti_core/embedder/client.py +2 -1
- graphiti_core/embedder/gemini.py +116 -22
- graphiti_core/embedder/voyage.py +13 -2
- graphiti_core/errors.py +8 -0
- graphiti_core/graph_queries.py +162 -0
- graphiti_core/graphiti.py +705 -193
- graphiti_core/graphiti_types.py +4 -2
- graphiti_core/helpers.py +87 -10
- graphiti_core/llm_client/__init__.py +16 -0
- graphiti_core/llm_client/anthropic_client.py +159 -56
- graphiti_core/llm_client/azure_openai_client.py +115 -0
- graphiti_core/llm_client/client.py +98 -21
- graphiti_core/llm_client/config.py +1 -1
- graphiti_core/llm_client/gemini_client.py +290 -41
- graphiti_core/llm_client/groq_client.py +14 -3
- graphiti_core/llm_client/openai_base_client.py +261 -0
- graphiti_core/llm_client/openai_client.py +56 -132
- graphiti_core/llm_client/openai_generic_client.py +91 -56
- graphiti_core/models/edges/edge_db_queries.py +259 -35
- graphiti_core/models/nodes/node_db_queries.py +311 -32
- graphiti_core/nodes.py +420 -205
- graphiti_core/prompts/dedupe_edges.py +46 -32
- graphiti_core/prompts/dedupe_nodes.py +67 -42
- graphiti_core/prompts/eval.py +4 -4
- graphiti_core/prompts/extract_edges.py +27 -16
- graphiti_core/prompts/extract_nodes.py +74 -31
- graphiti_core/prompts/prompt_helpers.py +39 -0
- graphiti_core/prompts/snippets.py +29 -0
- graphiti_core/prompts/summarize_nodes.py +23 -25
- graphiti_core/search/search.py +158 -82
- graphiti_core/search/search_config.py +39 -4
- graphiti_core/search/search_filters.py +126 -35
- graphiti_core/search/search_helpers.py +5 -6
- graphiti_core/search/search_utils.py +1405 -485
- graphiti_core/telemetry/__init__.py +9 -0
- graphiti_core/telemetry/telemetry.py +117 -0
- graphiti_core/tracer.py +193 -0
- graphiti_core/utils/bulk_utils.py +364 -285
- graphiti_core/utils/datetime_utils.py +13 -0
- graphiti_core/utils/maintenance/community_operations.py +67 -49
- graphiti_core/utils/maintenance/dedup_helpers.py +262 -0
- graphiti_core/utils/maintenance/edge_operations.py +339 -197
- graphiti_core/utils/maintenance/graph_data_operations.py +50 -114
- graphiti_core/utils/maintenance/node_operations.py +319 -238
- graphiti_core/utils/maintenance/temporal_operations.py +11 -3
- graphiti_core/utils/ontology_utils/entity_types_utils.py +1 -1
- graphiti_core/utils/text_utils.py +53 -0
- graphiti_core-0.24.3.dist-info/METADATA +726 -0
- graphiti_core-0.24.3.dist-info/RECORD +86 -0
- {graphiti_core-0.12.0rc1.dist-info → graphiti_core-0.24.3.dist-info}/WHEEL +1 -1
- graphiti_core-0.12.0rc1.dist-info/METADATA +0 -350
- graphiti_core-0.12.0rc1.dist-info/RECORD +0 -66
- /graphiti_core/{utils/maintenance/utils.py → migrations/__init__.py} +0 -0
- {graphiti_core-0.12.0rc1.dist-info → graphiti_core-0.24.3.dist-info/licenses}/LICENSE +0 -0
|
@@ -43,7 +43,9 @@ async def extract_edge_dates(
|
|
|
43
43
|
'reference_timestamp': current_episode.valid_at.isoformat(),
|
|
44
44
|
}
|
|
45
45
|
llm_response = await llm_client.generate_response(
|
|
46
|
-
prompt_library.extract_edge_dates.v1(context),
|
|
46
|
+
prompt_library.extract_edge_dates.v1(context),
|
|
47
|
+
response_model=EdgeDates,
|
|
48
|
+
prompt_name='extract_edge_dates.v1',
|
|
47
49
|
)
|
|
48
50
|
|
|
49
51
|
valid_at = llm_response.get('valid_at')
|
|
@@ -70,7 +72,9 @@ async def extract_edge_dates(
|
|
|
70
72
|
|
|
71
73
|
|
|
72
74
|
async def get_edge_contradictions(
|
|
73
|
-
llm_client: LLMClient,
|
|
75
|
+
llm_client: LLMClient,
|
|
76
|
+
new_edge: EntityEdge,
|
|
77
|
+
existing_edges: list[EntityEdge],
|
|
74
78
|
) -> list[EntityEdge]:
|
|
75
79
|
start = time()
|
|
76
80
|
|
|
@@ -79,12 +83,16 @@ async def get_edge_contradictions(
|
|
|
79
83
|
{'id': i, 'fact': existing_edge.fact} for i, existing_edge in enumerate(existing_edges)
|
|
80
84
|
]
|
|
81
85
|
|
|
82
|
-
context = {
|
|
86
|
+
context = {
|
|
87
|
+
'new_edge': new_edge_context,
|
|
88
|
+
'existing_edges': existing_edge_context,
|
|
89
|
+
}
|
|
83
90
|
|
|
84
91
|
llm_response = await llm_client.generate_response(
|
|
85
92
|
prompt_library.invalidate_edges.v2(context),
|
|
86
93
|
response_model=InvalidatedEdges,
|
|
87
94
|
model_size=ModelSize.small,
|
|
95
|
+
prompt_name='invalidate_edges.v2',
|
|
88
96
|
)
|
|
89
97
|
|
|
90
98
|
contradicted_facts: list[int] = llm_response.get('contradicted_facts', [])
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
import re
|
|
18
|
+
|
|
19
|
+
# Maximum length for entity/node summaries
|
|
20
|
+
MAX_SUMMARY_CHARS = 500
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def truncate_at_sentence(text: str, max_chars: int) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Truncate text at or about max_chars while respecting sentence boundaries.
|
|
26
|
+
|
|
27
|
+
Attempts to truncate at the last complete sentence before max_chars.
|
|
28
|
+
If no sentence boundary is found before max_chars, truncates at max_chars.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
text: The text to truncate
|
|
32
|
+
max_chars: Maximum number of characters
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Truncated text
|
|
36
|
+
"""
|
|
37
|
+
if not text or len(text) <= max_chars:
|
|
38
|
+
return text
|
|
39
|
+
|
|
40
|
+
# Find all sentence boundaries (., !, ?) up to max_chars
|
|
41
|
+
truncated = text[:max_chars]
|
|
42
|
+
|
|
43
|
+
# Look for sentence boundaries: period, exclamation, or question mark followed by space or end
|
|
44
|
+
sentence_pattern = r'[.!?](?:\s|$)'
|
|
45
|
+
matches = list(re.finditer(sentence_pattern, truncated))
|
|
46
|
+
|
|
47
|
+
if matches:
|
|
48
|
+
# Truncate at the last sentence boundary found
|
|
49
|
+
last_match = matches[-1]
|
|
50
|
+
return text[: last_match.end()].rstrip()
|
|
51
|
+
|
|
52
|
+
# No sentence boundary found, truncate at max_chars
|
|
53
|
+
return truncated.rstrip()
|