cognee 0.3.4.dev4__py3-none-any.whl → 0.3.5__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.
- cognee/api/client.py +16 -7
- cognee/api/health.py +5 -9
- cognee/api/v1/add/add.py +3 -1
- cognee/api/v1/cognify/cognify.py +44 -7
- cognee/api/v1/permissions/routers/get_permissions_router.py +8 -4
- cognee/api/v1/search/search.py +3 -0
- cognee/api/v1/ui/__init__.py +1 -1
- cognee/api/v1/ui/ui.py +215 -150
- cognee/api/v1/update/__init__.py +1 -0
- cognee/api/v1/update/routers/__init__.py +1 -0
- cognee/api/v1/update/routers/get_update_router.py +90 -0
- cognee/api/v1/update/update.py +100 -0
- cognee/base_config.py +5 -2
- cognee/cli/_cognee.py +28 -10
- cognee/cli/commands/delete_command.py +34 -2
- cognee/eval_framework/corpus_builder/task_getters/get_default_tasks_by_indices.py +2 -2
- cognee/eval_framework/evaluation/direct_llm_eval_adapter.py +3 -2
- cognee/eval_framework/modal_eval_dashboard.py +9 -1
- cognee/infrastructure/databases/graph/config.py +9 -9
- cognee/infrastructure/databases/graph/get_graph_engine.py +4 -21
- cognee/infrastructure/databases/graph/kuzu/adapter.py +60 -9
- cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py +3 -3
- cognee/infrastructure/databases/relational/config.py +4 -4
- cognee/infrastructure/databases/relational/create_relational_engine.py +11 -3
- cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +7 -3
- cognee/infrastructure/databases/vector/config.py +7 -7
- cognee/infrastructure/databases/vector/create_vector_engine.py +7 -15
- cognee/infrastructure/databases/vector/embeddings/EmbeddingEngine.py +9 -0
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +19 -2
- cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/config.py +8 -0
- cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +5 -0
- cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +11 -10
- cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py +48 -38
- cognee/infrastructure/databases/vector/vector_db_interface.py +8 -4
- cognee/infrastructure/files/storage/S3FileStorage.py +15 -5
- cognee/infrastructure/files/storage/s3_config.py +1 -0
- cognee/infrastructure/files/utils/open_data_file.py +7 -14
- cognee/infrastructure/llm/LLMGateway.py +19 -117
- cognee/infrastructure/llm/config.py +28 -13
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_categories.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_event_entities.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_summary.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_content_graph.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_event_graph.py +3 -2
- cognee/infrastructure/llm/prompts/read_query_prompt.py +3 -2
- cognee/infrastructure/llm/prompts/show_prompt.py +35 -0
- cognee/infrastructure/llm/prompts/test.txt +1 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/__init__.py +2 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/async_client.py +50 -397
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/inlinedbaml.py +2 -3
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/parser.py +8 -88
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/runtime.py +78 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/stream_types.py +2 -99
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/sync_client.py +49 -401
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_builder.py +19 -882
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_map.py +2 -34
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/types.py +2 -107
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/acreate_structured_output.baml +26 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/__init__.py +1 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/acreate_structured_output.py +76 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/create_dynamic_baml_type.py +122 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/generators.baml +3 -3
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +0 -32
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +107 -98
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/llm_interface.py +0 -26
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +17 -67
- cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +8 -7
- cognee/infrastructure/llm/utils.py +4 -4
- cognee/infrastructure/loaders/LoaderEngine.py +5 -2
- cognee/infrastructure/loaders/external/__init__.py +7 -0
- cognee/infrastructure/loaders/external/advanced_pdf_loader.py +244 -0
- cognee/infrastructure/loaders/supported_loaders.py +7 -0
- cognee/modules/data/methods/create_authorized_dataset.py +9 -0
- cognee/modules/data/methods/get_authorized_dataset.py +1 -1
- cognee/modules/data/methods/get_authorized_dataset_by_name.py +11 -0
- cognee/modules/data/methods/get_deletion_counts.py +92 -0
- cognee/modules/graph/cognee_graph/CogneeGraph.py +1 -1
- cognee/modules/graph/utils/expand_with_nodes_and_edges.py +22 -8
- cognee/modules/graph/utils/retrieve_existing_edges.py +0 -2
- cognee/modules/ingestion/data_types/TextData.py +0 -1
- cognee/modules/observability/get_observe.py +14 -0
- cognee/modules/observability/observers.py +1 -0
- cognee/modules/ontology/base_ontology_resolver.py +42 -0
- cognee/modules/ontology/get_default_ontology_resolver.py +41 -0
- cognee/modules/ontology/matching_strategies.py +53 -0
- cognee/modules/ontology/models.py +20 -0
- cognee/modules/ontology/ontology_config.py +24 -0
- cognee/modules/ontology/ontology_env_config.py +45 -0
- cognee/modules/ontology/rdf_xml/{OntologyResolver.py → RDFLibOntologyResolver.py} +20 -28
- cognee/modules/pipelines/layers/resolve_authorized_user_dataset.py +21 -24
- cognee/modules/pipelines/layers/resolve_authorized_user_datasets.py +3 -3
- cognee/modules/retrieval/code_retriever.py +2 -1
- cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +1 -4
- cognee/modules/retrieval/graph_completion_cot_retriever.py +6 -5
- cognee/modules/retrieval/graph_completion_retriever.py +0 -3
- cognee/modules/retrieval/insights_retriever.py +1 -1
- cognee/modules/retrieval/jaccard_retrival.py +60 -0
- cognee/modules/retrieval/lexical_retriever.py +123 -0
- cognee/modules/retrieval/natural_language_retriever.py +2 -1
- cognee/modules/retrieval/temporal_retriever.py +3 -2
- cognee/modules/retrieval/utils/brute_force_triplet_search.py +2 -12
- cognee/modules/retrieval/utils/completion.py +4 -7
- cognee/modules/search/methods/get_search_type_tools.py +7 -0
- cognee/modules/search/methods/no_access_control_search.py +1 -1
- cognee/modules/search/methods/search.py +32 -13
- cognee/modules/search/types/SearchType.py +1 -0
- cognee/modules/users/permissions/methods/authorized_give_permission_on_datasets.py +12 -0
- cognee/modules/users/permissions/methods/check_permission_on_dataset.py +11 -0
- cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py +10 -0
- cognee/modules/users/permissions/methods/get_document_ids_for_user.py +10 -0
- cognee/modules/users/permissions/methods/get_principal.py +9 -0
- cognee/modules/users/permissions/methods/get_principal_datasets.py +11 -0
- cognee/modules/users/permissions/methods/get_role.py +10 -0
- cognee/modules/users/permissions/methods/get_specific_user_permission_datasets.py +3 -3
- cognee/modules/users/permissions/methods/get_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_role.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_user.py +9 -0
- cognee/modules/users/permissions/methods/give_permission_on_dataset.py +10 -0
- cognee/modules/users/roles/methods/add_user_to_role.py +11 -0
- cognee/modules/users/roles/methods/create_role.py +12 -1
- cognee/modules/users/tenants/methods/add_user_to_tenant.py +12 -0
- cognee/modules/users/tenants/methods/create_tenant.py +12 -1
- cognee/modules/visualization/cognee_network_visualization.py +13 -9
- cognee/shared/data_models.py +0 -1
- cognee/shared/utils.py +0 -32
- cognee/tasks/chunk_naive_llm_classifier/chunk_naive_llm_classifier.py +2 -2
- cognee/tasks/codingagents/coding_rule_associations.py +3 -2
- cognee/tasks/entity_completion/entity_extractors/llm_entity_extractor.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_content_nodes_and_relationship_names.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_edge_triplets.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_nodes.py +3 -2
- cognee/tasks/graph/extract_graph_from_code.py +2 -2
- cognee/tasks/graph/extract_graph_from_data.py +55 -12
- cognee/tasks/graph/extract_graph_from_data_v2.py +16 -4
- cognee/tasks/ingestion/migrate_relational_database.py +132 -41
- cognee/tasks/ingestion/resolve_data_directories.py +4 -1
- cognee/tasks/schema/ingest_database_schema.py +134 -0
- cognee/tasks/schema/models.py +40 -0
- cognee/tasks/storage/index_data_points.py +1 -1
- cognee/tasks/storage/index_graph_edges.py +3 -1
- cognee/tasks/summarization/summarize_code.py +2 -2
- cognee/tasks/summarization/summarize_text.py +2 -2
- cognee/tasks/temporal_graph/enrich_events.py +2 -2
- cognee/tasks/temporal_graph/extract_events_and_entities.py +2 -2
- cognee/tests/cli_tests/cli_unit_tests/test_cli_commands.py +13 -4
- cognee/tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py +13 -3
- cognee/tests/test_advanced_pdf_loader.py +141 -0
- cognee/tests/test_chromadb.py +40 -0
- cognee/tests/test_cognee_server_start.py +6 -1
- cognee/tests/test_data/Quantum_computers.txt +9 -0
- cognee/tests/test_lancedb.py +211 -0
- cognee/tests/test_pgvector.py +40 -0
- cognee/tests/test_relational_db_migration.py +76 -0
- cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py +2 -1
- cognee/tests/unit/modules/ontology/test_ontology_adapter.py +330 -13
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_context_extension_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +0 -4
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/METADATA +92 -96
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/RECORD +173 -159
- distributed/pyproject.toml +0 -1
- cognee/infrastructure/data/utils/extract_keywords.py +0 -48
- cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py +0 -1227
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_categories.baml +0 -109
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_content_graph.baml +0 -343
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_categories.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_summary.py +0 -89
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/__init__.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +0 -44
- cognee/tasks/graph/infer_data_ontology.py +0 -309
- cognee/tests/test_falkordb.py +0 -174
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/texts.json +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/WHEEL +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/entry_points.txt +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/licenses/NOTICE.md +0 -0
cognee/tests/test_pgvector.py
CHANGED
|
@@ -68,6 +68,44 @@ async def test_getting_of_documents(dataset_name_1):
|
|
|
68
68
|
)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
async def test_vector_engine_search_none_limit():
|
|
72
|
+
file_path_quantum = os.path.join(
|
|
73
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
file_path_nlp = os.path.join(
|
|
77
|
+
pathlib.Path(__file__).parent,
|
|
78
|
+
"test_data/Natural_language_processing.txt",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
await cognee.prune.prune_data()
|
|
82
|
+
await cognee.prune.prune_system(metadata=True)
|
|
83
|
+
|
|
84
|
+
await cognee.add(file_path_quantum)
|
|
85
|
+
|
|
86
|
+
await cognee.add(file_path_nlp)
|
|
87
|
+
|
|
88
|
+
await cognee.cognify()
|
|
89
|
+
|
|
90
|
+
query_text = "Tell me about Quantum computers"
|
|
91
|
+
|
|
92
|
+
from cognee.infrastructure.databases.vector import get_vector_engine
|
|
93
|
+
|
|
94
|
+
vector_engine = get_vector_engine()
|
|
95
|
+
|
|
96
|
+
collection_name = "Entity_name"
|
|
97
|
+
|
|
98
|
+
query_vector = (await vector_engine.embedding_engine.embed_text([query_text]))[0]
|
|
99
|
+
|
|
100
|
+
result = await vector_engine.search(
|
|
101
|
+
collection_name=collection_name, query_vector=query_vector, limit=None
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Check that we did not accidentally use any default value for limit
|
|
105
|
+
# in vector search along the way (like 5, 10, or 15)
|
|
106
|
+
assert len(result) > 15
|
|
107
|
+
|
|
108
|
+
|
|
71
109
|
async def main():
|
|
72
110
|
cognee.config.set_vector_db_config(
|
|
73
111
|
{"vector_db_url": "", "vector_db_key": "", "vector_db_provider": "pgvector"}
|
|
@@ -174,6 +212,8 @@ async def main():
|
|
|
174
212
|
tables_in_database = await vector_engine.get_table_names()
|
|
175
213
|
assert len(tables_in_database) == 0, "PostgreSQL database is not empty"
|
|
176
214
|
|
|
215
|
+
await test_vector_engine_search_none_limit()
|
|
216
|
+
|
|
177
217
|
|
|
178
218
|
if __name__ == "__main__":
|
|
179
219
|
import asyncio
|
|
@@ -197,6 +197,80 @@ async def relational_db_migration():
|
|
|
197
197
|
print(f"All checks passed for {graph_db_provider} provider with '{relationship_label}' edges!")
|
|
198
198
|
|
|
199
199
|
|
|
200
|
+
async def test_schema_only_migration():
|
|
201
|
+
# 1. Setup test DB and extract schema
|
|
202
|
+
migration_engine = await setup_test_db()
|
|
203
|
+
schema = await migration_engine.extract_schema()
|
|
204
|
+
|
|
205
|
+
# 2. Setup graph engine
|
|
206
|
+
graph_engine = await get_graph_engine()
|
|
207
|
+
|
|
208
|
+
# 4. Migrate schema only
|
|
209
|
+
await migrate_relational_database(graph_engine, schema=schema, schema_only=True)
|
|
210
|
+
|
|
211
|
+
# 5. Verify number of tables through search
|
|
212
|
+
search_results = await cognee.search(
|
|
213
|
+
query_text="How many tables are there in this database",
|
|
214
|
+
query_type=cognee.SearchType.GRAPH_COMPLETION,
|
|
215
|
+
top_k=30,
|
|
216
|
+
)
|
|
217
|
+
assert any("11" in r for r in search_results), (
|
|
218
|
+
"Number of tables in the database reported in search_results is either None or not equal to 11"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
graph_db_provider = os.getenv("GRAPH_DATABASE_PROVIDER", "networkx").lower()
|
|
222
|
+
|
|
223
|
+
edge_counts = {
|
|
224
|
+
"is_part_of": 0,
|
|
225
|
+
"has_relationship": 0,
|
|
226
|
+
"foreign_key": 0,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if graph_db_provider == "neo4j":
|
|
230
|
+
for rel_type in edge_counts.keys():
|
|
231
|
+
query_str = f"""
|
|
232
|
+
MATCH ()-[r:{rel_type}]->()
|
|
233
|
+
RETURN count(r) as c
|
|
234
|
+
"""
|
|
235
|
+
rows = await graph_engine.query(query_str)
|
|
236
|
+
edge_counts[rel_type] = rows[0]["c"]
|
|
237
|
+
|
|
238
|
+
elif graph_db_provider == "kuzu":
|
|
239
|
+
for rel_type in edge_counts.keys():
|
|
240
|
+
query_str = f"""
|
|
241
|
+
MATCH ()-[r:EDGE]->()
|
|
242
|
+
WHERE r.relationship_name = '{rel_type}'
|
|
243
|
+
RETURN count(r) as c
|
|
244
|
+
"""
|
|
245
|
+
rows = await graph_engine.query(query_str)
|
|
246
|
+
edge_counts[rel_type] = rows[0][0]
|
|
247
|
+
|
|
248
|
+
elif graph_db_provider == "networkx":
|
|
249
|
+
nodes, edges = await graph_engine.get_graph_data()
|
|
250
|
+
for _, _, key, _ in edges:
|
|
251
|
+
if key in edge_counts:
|
|
252
|
+
edge_counts[key] += 1
|
|
253
|
+
|
|
254
|
+
else:
|
|
255
|
+
raise ValueError(f"Unsupported graph database provider: {graph_db_provider}")
|
|
256
|
+
|
|
257
|
+
# 7. Assert counts match expected values
|
|
258
|
+
expected_counts = {
|
|
259
|
+
"is_part_of": 11,
|
|
260
|
+
"has_relationship": 22,
|
|
261
|
+
"foreign_key": 11,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
for rel_type, expected in expected_counts.items():
|
|
265
|
+
actual = edge_counts[rel_type]
|
|
266
|
+
assert actual == expected, (
|
|
267
|
+
f"Expected {expected} edges for relationship '{rel_type}', but found {actual}"
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
print("Schema-only migration edge counts validated successfully!")
|
|
271
|
+
print(f"Edge counts: {edge_counts}")
|
|
272
|
+
|
|
273
|
+
|
|
200
274
|
async def test_migration_sqlite():
|
|
201
275
|
database_to_migrate_path = os.path.join(pathlib.Path(__file__).parent, "test_data/")
|
|
202
276
|
|
|
@@ -209,6 +283,7 @@ async def test_migration_sqlite():
|
|
|
209
283
|
)
|
|
210
284
|
|
|
211
285
|
await relational_db_migration()
|
|
286
|
+
await test_schema_only_migration()
|
|
212
287
|
|
|
213
288
|
|
|
214
289
|
async def test_migration_postgres():
|
|
@@ -224,6 +299,7 @@ async def test_migration_postgres():
|
|
|
224
299
|
}
|
|
225
300
|
)
|
|
226
301
|
await relational_db_migration()
|
|
302
|
+
await test_schema_only_migration()
|
|
227
303
|
|
|
228
304
|
|
|
229
305
|
async def main():
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pytest
|
|
2
|
-
from unittest.mock import AsyncMock, patch
|
|
2
|
+
from unittest.mock import AsyncMock, patch, MagicMock
|
|
3
3
|
from cognee.tasks.storage.index_graph_edges import index_graph_edges
|
|
4
4
|
|
|
5
5
|
|
|
@@ -16,6 +16,7 @@ async def test_index_graph_edges_success():
|
|
|
16
16
|
],
|
|
17
17
|
)
|
|
18
18
|
mock_vector_engine = AsyncMock()
|
|
19
|
+
mock_vector_engine.embedding_engine.get_batch_size = MagicMock(return_value=100)
|
|
19
20
|
|
|
20
21
|
# Patch the globals of the function so that when it does:
|
|
21
22
|
# vector_engine = get_vector_engine()
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from rdflib import Graph, Namespace, RDF, OWL, RDFS
|
|
3
|
-
from cognee.modules.ontology.rdf_xml.
|
|
3
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
4
|
+
from cognee.modules.ontology.models import AttachedOntologyNode
|
|
5
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_default_ontology_resolver
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
def test_ontology_adapter_initialization_success():
|
|
7
|
-
"""Test successful initialization of
|
|
9
|
+
"""Test successful initialization of RDFLibOntologyResolver from get_default_ontology_resolver."""
|
|
8
10
|
|
|
9
|
-
adapter =
|
|
11
|
+
adapter = get_default_ontology_resolver()
|
|
10
12
|
adapter.build_lookup()
|
|
11
13
|
|
|
12
14
|
assert isinstance(adapter.lookup, dict)
|
|
@@ -14,7 +16,7 @@ def test_ontology_adapter_initialization_success():
|
|
|
14
16
|
|
|
15
17
|
def test_ontology_adapter_initialization_file_not_found():
|
|
16
18
|
"""Test OntologyAdapter initialization with nonexistent file."""
|
|
17
|
-
adapter =
|
|
19
|
+
adapter = RDFLibOntologyResolver(ontology_file="nonexistent.owl")
|
|
18
20
|
assert adapter.graph is None
|
|
19
21
|
|
|
20
22
|
|
|
@@ -27,7 +29,7 @@ def test_build_lookup():
|
|
|
27
29
|
|
|
28
30
|
g.add((ns.Audi, RDF.type, ns.Car))
|
|
29
31
|
|
|
30
|
-
resolver =
|
|
32
|
+
resolver = RDFLibOntologyResolver()
|
|
31
33
|
resolver.graph = g
|
|
32
34
|
resolver.build_lookup()
|
|
33
35
|
|
|
@@ -50,7 +52,7 @@ def test_find_closest_match_exact():
|
|
|
50
52
|
g.add((ns.Car, RDF.type, OWL.Class))
|
|
51
53
|
g.add((ns.Audi, RDF.type, ns.Car))
|
|
52
54
|
|
|
53
|
-
resolver =
|
|
55
|
+
resolver = RDFLibOntologyResolver()
|
|
54
56
|
resolver.graph = g
|
|
55
57
|
resolver.build_lookup()
|
|
56
58
|
|
|
@@ -71,7 +73,7 @@ def test_find_closest_match_fuzzy():
|
|
|
71
73
|
g.add((ns.Audi, RDF.type, ns.Car))
|
|
72
74
|
g.add((ns.BMW, RDF.type, ns.Car))
|
|
73
75
|
|
|
74
|
-
resolver =
|
|
76
|
+
resolver = RDFLibOntologyResolver()
|
|
75
77
|
resolver.graph = g
|
|
76
78
|
resolver.build_lookup()
|
|
77
79
|
|
|
@@ -92,7 +94,7 @@ def test_find_closest_match_no_match():
|
|
|
92
94
|
g.add((ns.Audi, RDF.type, ns.Car))
|
|
93
95
|
g.add((ns.BMW, RDF.type, ns.Car))
|
|
94
96
|
|
|
95
|
-
resolver =
|
|
97
|
+
resolver = RDFLibOntologyResolver()
|
|
96
98
|
resolver.graph = g
|
|
97
99
|
resolver.build_lookup()
|
|
98
100
|
|
|
@@ -102,10 +104,10 @@ def test_find_closest_match_no_match():
|
|
|
102
104
|
|
|
103
105
|
|
|
104
106
|
def test_get_subgraph_no_match_rdflib():
|
|
105
|
-
"""Test get_subgraph returns empty results for a non-existent node."""
|
|
107
|
+
"""Test get_subgraph returns empty results for a non-existent node using RDFLibOntologyResolver."""
|
|
106
108
|
g = Graph()
|
|
107
109
|
|
|
108
|
-
resolver =
|
|
110
|
+
resolver = get_default_ontology_resolver()
|
|
109
111
|
resolver.graph = g
|
|
110
112
|
resolver.build_lookup()
|
|
111
113
|
|
|
@@ -138,7 +140,7 @@ def test_get_subgraph_success_rdflib():
|
|
|
138
140
|
g.add((ns.VW, owns, ns.Audi))
|
|
139
141
|
g.add((ns.VW, owns, ns.Porsche))
|
|
140
142
|
|
|
141
|
-
resolver =
|
|
143
|
+
resolver = RDFLibOntologyResolver()
|
|
142
144
|
resolver.graph = g
|
|
143
145
|
resolver.build_lookup()
|
|
144
146
|
|
|
@@ -160,10 +162,10 @@ def test_get_subgraph_success_rdflib():
|
|
|
160
162
|
|
|
161
163
|
|
|
162
164
|
def test_refresh_lookup_rdflib():
|
|
163
|
-
"""Test that refresh_lookup rebuilds the lookup dict into a new object."""
|
|
165
|
+
"""Test that refresh_lookup rebuilds the lookup dict into a new object using RDFLibOntologyResolver."""
|
|
164
166
|
g = Graph()
|
|
165
167
|
|
|
166
|
-
resolver =
|
|
168
|
+
resolver = get_default_ontology_resolver()
|
|
167
169
|
resolver.graph = g
|
|
168
170
|
resolver.build_lookup()
|
|
169
171
|
|
|
@@ -172,3 +174,318 @@ def test_refresh_lookup_rdflib():
|
|
|
172
174
|
resolver.refresh_lookup()
|
|
173
175
|
|
|
174
176
|
assert resolver.lookup is not original_lookup
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def test_fuzzy_matching_strategy_exact_match():
|
|
180
|
+
"""Test FuzzyMatchingStrategy finds exact matches."""
|
|
181
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
182
|
+
|
|
183
|
+
strategy = FuzzyMatchingStrategy()
|
|
184
|
+
candidates = ["audi", "bmw", "mercedes"]
|
|
185
|
+
|
|
186
|
+
result = strategy.find_match("audi", candidates)
|
|
187
|
+
assert result == "audi"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def test_fuzzy_matching_strategy_fuzzy_match():
|
|
191
|
+
"""Test FuzzyMatchingStrategy finds fuzzy matches."""
|
|
192
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
193
|
+
|
|
194
|
+
strategy = FuzzyMatchingStrategy(cutoff=0.6)
|
|
195
|
+
candidates = ["audi", "bmw", "mercedes"]
|
|
196
|
+
|
|
197
|
+
result = strategy.find_match("audii", candidates)
|
|
198
|
+
assert result == "audi"
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def test_fuzzy_matching_strategy_no_match():
|
|
202
|
+
"""Test FuzzyMatchingStrategy returns None when no match meets cutoff."""
|
|
203
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
204
|
+
|
|
205
|
+
strategy = FuzzyMatchingStrategy(cutoff=0.9)
|
|
206
|
+
candidates = ["audi", "bmw", "mercedes"]
|
|
207
|
+
|
|
208
|
+
result = strategy.find_match("completely_different", candidates)
|
|
209
|
+
assert result is None
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_fuzzy_matching_strategy_empty_candidates():
|
|
213
|
+
"""Test FuzzyMatchingStrategy handles empty candidates list."""
|
|
214
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
215
|
+
|
|
216
|
+
strategy = FuzzyMatchingStrategy()
|
|
217
|
+
|
|
218
|
+
result = strategy.find_match("audi", [])
|
|
219
|
+
assert result is None
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def test_base_ontology_resolver_initialization():
|
|
223
|
+
"""Test BaseOntologyResolver initialization with default matching strategy."""
|
|
224
|
+
from cognee.modules.ontology.base_ontology_resolver import BaseOntologyResolver
|
|
225
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
226
|
+
|
|
227
|
+
class TestOntologyResolver(BaseOntologyResolver):
|
|
228
|
+
def build_lookup(self):
|
|
229
|
+
pass
|
|
230
|
+
|
|
231
|
+
def refresh_lookup(self):
|
|
232
|
+
pass
|
|
233
|
+
|
|
234
|
+
def find_closest_match(self, name, category):
|
|
235
|
+
return None
|
|
236
|
+
|
|
237
|
+
def get_subgraph(self, node_name, node_type="individuals", directed=True):
|
|
238
|
+
return [], [], None
|
|
239
|
+
|
|
240
|
+
resolver = TestOntologyResolver()
|
|
241
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def test_base_ontology_resolver_custom_matching_strategy():
|
|
245
|
+
"""Test BaseOntologyResolver initialization with custom matching strategy."""
|
|
246
|
+
from cognee.modules.ontology.base_ontology_resolver import BaseOntologyResolver
|
|
247
|
+
from cognee.modules.ontology.matching_strategies import MatchingStrategy
|
|
248
|
+
|
|
249
|
+
class CustomMatchingStrategy(MatchingStrategy):
|
|
250
|
+
def find_match(self, name, candidates):
|
|
251
|
+
return "custom_match"
|
|
252
|
+
|
|
253
|
+
class TestOntologyResolver(BaseOntologyResolver):
|
|
254
|
+
def build_lookup(self):
|
|
255
|
+
pass
|
|
256
|
+
|
|
257
|
+
def refresh_lookup(self):
|
|
258
|
+
pass
|
|
259
|
+
|
|
260
|
+
def find_closest_match(self, name, category):
|
|
261
|
+
return None
|
|
262
|
+
|
|
263
|
+
def get_subgraph(self, node_name, node_type="individuals", directed=True):
|
|
264
|
+
return [], [], None
|
|
265
|
+
|
|
266
|
+
custom_strategy = CustomMatchingStrategy()
|
|
267
|
+
resolver = TestOntologyResolver(matching_strategy=custom_strategy)
|
|
268
|
+
assert resolver.matching_strategy == custom_strategy
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def test_ontology_config_structure():
|
|
272
|
+
"""Test TypedDict structure for ontology configuration."""
|
|
273
|
+
from cognee.modules.ontology.ontology_config import Config
|
|
274
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
275
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
276
|
+
|
|
277
|
+
matching_strategy = FuzzyMatchingStrategy()
|
|
278
|
+
resolver = RDFLibOntologyResolver(matching_strategy=matching_strategy)
|
|
279
|
+
|
|
280
|
+
config: Config = {"ontology_config": {"ontology_resolver": resolver}}
|
|
281
|
+
|
|
282
|
+
assert config["ontology_config"]["ontology_resolver"] == resolver
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def test_get_ontology_resolver_default():
|
|
286
|
+
"""Test get_default_ontology_resolver returns a properly configured RDFLibOntologyResolver with FuzzyMatchingStrategy."""
|
|
287
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
288
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
289
|
+
|
|
290
|
+
resolver = get_default_ontology_resolver()
|
|
291
|
+
|
|
292
|
+
assert isinstance(resolver, RDFLibOntologyResolver)
|
|
293
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_get_default_ontology_resolver():
|
|
297
|
+
"""Test get_default_ontology_resolver returns a properly configured RDFLibOntologyResolver with FuzzyMatchingStrategy."""
|
|
298
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
299
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
300
|
+
|
|
301
|
+
resolver = get_default_ontology_resolver()
|
|
302
|
+
|
|
303
|
+
assert isinstance(resolver, RDFLibOntologyResolver)
|
|
304
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def test_rdflib_ontology_resolver_uses_matching_strategy():
|
|
308
|
+
"""Test that RDFLibOntologyResolver uses the provided matching strategy."""
|
|
309
|
+
from cognee.modules.ontology.matching_strategies import MatchingStrategy
|
|
310
|
+
|
|
311
|
+
class TestMatchingStrategy(MatchingStrategy):
|
|
312
|
+
def find_match(self, name, candidates):
|
|
313
|
+
return "test_match" if candidates else None
|
|
314
|
+
|
|
315
|
+
ns = Namespace("http://example.org/test#")
|
|
316
|
+
g = Graph()
|
|
317
|
+
g.add((ns.Car, RDF.type, OWL.Class))
|
|
318
|
+
g.add((ns.Audi, RDF.type, ns.Car))
|
|
319
|
+
|
|
320
|
+
resolver = RDFLibOntologyResolver(matching_strategy=TestMatchingStrategy())
|
|
321
|
+
resolver.graph = g
|
|
322
|
+
resolver.build_lookup()
|
|
323
|
+
|
|
324
|
+
result = resolver.find_closest_match("Audi", "individuals")
|
|
325
|
+
assert result == "test_match"
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def test_rdflib_ontology_resolver_default_matching_strategy():
|
|
329
|
+
"""Test that RDFLibOntologyResolver uses FuzzyMatchingStrategy by default."""
|
|
330
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
331
|
+
|
|
332
|
+
resolver = RDFLibOntologyResolver()
|
|
333
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def test_get_ontology_resolver_from_env_success():
|
|
337
|
+
"""Test get_ontology_resolver_from_env returns correct resolver with valid parameters."""
|
|
338
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
339
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
340
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
341
|
+
|
|
342
|
+
resolver = get_ontology_resolver_from_env(
|
|
343
|
+
ontology_resolver="rdflib", matching_strategy="fuzzy", ontology_file_path="/test/path.owl"
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
assert isinstance(resolver, RDFLibOntologyResolver)
|
|
347
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
348
|
+
assert resolver.ontology_file == "/test/path.owl"
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def test_get_ontology_resolver_from_env_unsupported_resolver():
|
|
352
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for unsupported resolver."""
|
|
353
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
354
|
+
|
|
355
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
356
|
+
get_ontology_resolver_from_env(
|
|
357
|
+
ontology_resolver="unsupported",
|
|
358
|
+
matching_strategy="fuzzy",
|
|
359
|
+
ontology_file_path="/test/path.owl",
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
assert "Unsupported ontology resolver: unsupported" in str(exc_info.value)
|
|
363
|
+
assert "Supported resolvers are: RdfLib with FuzzyMatchingStrategy" in str(exc_info.value)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def test_get_ontology_resolver_from_env_unsupported_strategy():
|
|
367
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for unsupported strategy."""
|
|
368
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
369
|
+
|
|
370
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
371
|
+
get_ontology_resolver_from_env(
|
|
372
|
+
ontology_resolver="rdflib",
|
|
373
|
+
matching_strategy="unsupported",
|
|
374
|
+
ontology_file_path="/test/path.owl",
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
assert "Unsupported ontology resolver: rdflib" in str(exc_info.value)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def test_get_ontology_resolver_from_env_empty_file_path():
|
|
381
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for empty file path."""
|
|
382
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
383
|
+
|
|
384
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
385
|
+
get_ontology_resolver_from_env(
|
|
386
|
+
ontology_resolver="rdflib", matching_strategy="fuzzy", ontology_file_path=""
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
assert "Unsupported ontology resolver: rdflib" in str(exc_info.value)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def test_get_ontology_resolver_from_env_none_file_path():
|
|
393
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for None file path."""
|
|
394
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
395
|
+
|
|
396
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
397
|
+
get_ontology_resolver_from_env(
|
|
398
|
+
ontology_resolver="rdflib", matching_strategy="fuzzy", ontology_file_path=None
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
assert "Unsupported ontology resolver: rdflib" in str(exc_info.value)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def test_get_ontology_resolver_from_env_empty_resolver():
|
|
405
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for empty resolver."""
|
|
406
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
407
|
+
|
|
408
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
409
|
+
get_ontology_resolver_from_env(
|
|
410
|
+
ontology_resolver="", matching_strategy="fuzzy", ontology_file_path="/test/path.owl"
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
assert "Unsupported ontology resolver:" in str(exc_info.value)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_get_ontology_resolver_from_env_empty_strategy():
|
|
417
|
+
"""Test get_ontology_resolver_from_env raises EnvironmentError for empty strategy."""
|
|
418
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
419
|
+
|
|
420
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
421
|
+
get_ontology_resolver_from_env(
|
|
422
|
+
ontology_resolver="rdflib", matching_strategy="", ontology_file_path="/test/path.owl"
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
assert "Unsupported ontology resolver: rdflib" in str(exc_info.value)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def test_get_ontology_resolver_from_env_default_parameters():
|
|
429
|
+
"""Test get_ontology_resolver_from_env with default empty parameters raises EnvironmentError."""
|
|
430
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
431
|
+
|
|
432
|
+
with pytest.raises(EnvironmentError) as exc_info:
|
|
433
|
+
get_ontology_resolver_from_env()
|
|
434
|
+
|
|
435
|
+
assert "Unsupported ontology resolver:" in str(exc_info.value)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
def test_get_ontology_resolver_from_env_case_sensitivity():
|
|
439
|
+
"""Test get_ontology_resolver_from_env is case sensitive."""
|
|
440
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
441
|
+
|
|
442
|
+
with pytest.raises(EnvironmentError):
|
|
443
|
+
get_ontology_resolver_from_env(
|
|
444
|
+
ontology_resolver="RDFLIB",
|
|
445
|
+
matching_strategy="fuzzy",
|
|
446
|
+
ontology_file_path="/test/path.owl",
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
with pytest.raises(EnvironmentError):
|
|
450
|
+
get_ontology_resolver_from_env(
|
|
451
|
+
ontology_resolver="RdfLib",
|
|
452
|
+
matching_strategy="fuzzy",
|
|
453
|
+
ontology_file_path="/test/path.owl",
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def test_get_ontology_resolver_from_env_with_actual_file():
|
|
458
|
+
"""Test get_ontology_resolver_from_env works with actual file path."""
|
|
459
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
460
|
+
from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver
|
|
461
|
+
from cognee.modules.ontology.matching_strategies import FuzzyMatchingStrategy
|
|
462
|
+
|
|
463
|
+
resolver = get_ontology_resolver_from_env(
|
|
464
|
+
ontology_resolver="rdflib",
|
|
465
|
+
matching_strategy="fuzzy",
|
|
466
|
+
ontology_file_path="/path/to/ontology.owl",
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
assert isinstance(resolver, RDFLibOntologyResolver)
|
|
470
|
+
assert isinstance(resolver.matching_strategy, FuzzyMatchingStrategy)
|
|
471
|
+
assert resolver.ontology_file == "/path/to/ontology.owl"
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def test_get_ontology_resolver_from_env_resolver_functionality():
|
|
475
|
+
"""Test that resolver created from env function works correctly."""
|
|
476
|
+
from cognee.modules.ontology.get_default_ontology_resolver import get_ontology_resolver_from_env
|
|
477
|
+
|
|
478
|
+
resolver = get_ontology_resolver_from_env(
|
|
479
|
+
ontology_resolver="rdflib", matching_strategy="fuzzy", ontology_file_path="/test/path.owl"
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
resolver.build_lookup()
|
|
483
|
+
assert isinstance(resolver.lookup, dict)
|
|
484
|
+
|
|
485
|
+
result = resolver.find_closest_match("test", "individuals")
|
|
486
|
+
assert result is None # Should return None for non-existent entity
|
|
487
|
+
|
|
488
|
+
nodes, relationships, start_node = resolver.get_subgraph("test", "individuals")
|
|
489
|
+
assert nodes == []
|
|
490
|
+
assert relationships == []
|
|
491
|
+
assert start_node is None
|
|
@@ -7,7 +7,6 @@ import cognee
|
|
|
7
7
|
from cognee.low_level import setup, DataPoint
|
|
8
8
|
from cognee.tasks.storage import add_data_points
|
|
9
9
|
from cognee.modules.graph.utils import resolve_edges_to_text
|
|
10
|
-
from cognee.infrastructure.databases.exceptions import DatabaseNotCreatedError
|
|
11
10
|
from cognee.modules.retrieval.graph_completion_context_extension_retriever import (
|
|
12
11
|
GraphCompletionContextExtensionRetriever,
|
|
13
12
|
)
|
|
@@ -165,9 +164,6 @@ class TestGraphCompletionWithContextExtensionRetriever:
|
|
|
165
164
|
|
|
166
165
|
retriever = GraphCompletionContextExtensionRetriever()
|
|
167
166
|
|
|
168
|
-
with pytest.raises(DatabaseNotCreatedError):
|
|
169
|
-
await retriever.get_context("Who works at Figma?")
|
|
170
|
-
|
|
171
167
|
await setup()
|
|
172
168
|
|
|
173
169
|
context = await retriever.get_context("Who works at Figma?")
|
|
@@ -7,7 +7,6 @@ import cognee
|
|
|
7
7
|
from cognee.low_level import setup, DataPoint
|
|
8
8
|
from cognee.modules.graph.utils import resolve_edges_to_text
|
|
9
9
|
from cognee.tasks.storage import add_data_points
|
|
10
|
-
from cognee.infrastructure.databases.exceptions import DatabaseNotCreatedError
|
|
11
10
|
from cognee.modules.retrieval.graph_completion_cot_retriever import GraphCompletionCotRetriever
|
|
12
11
|
|
|
13
12
|
|
|
@@ -158,9 +157,6 @@ class TestGraphCompletionCoTRetriever:
|
|
|
158
157
|
|
|
159
158
|
retriever = GraphCompletionCotRetriever()
|
|
160
159
|
|
|
161
|
-
with pytest.raises(DatabaseNotCreatedError):
|
|
162
|
-
await retriever.get_context("Who works at Figma?")
|
|
163
|
-
|
|
164
160
|
await setup()
|
|
165
161
|
|
|
166
162
|
context = await retriever.get_context("Who works at Figma?")
|
|
@@ -7,7 +7,6 @@ import cognee
|
|
|
7
7
|
from cognee.low_level import setup, DataPoint
|
|
8
8
|
from cognee.modules.graph.utils import resolve_edges_to_text
|
|
9
9
|
from cognee.tasks.storage import add_data_points
|
|
10
|
-
from cognee.infrastructure.databases.exceptions import DatabaseNotCreatedError
|
|
11
10
|
from cognee.modules.retrieval.graph_completion_retriever import GraphCompletionRetriever
|
|
12
11
|
|
|
13
12
|
|
|
@@ -218,9 +217,6 @@ class TestGraphCompletionRetriever:
|
|
|
218
217
|
|
|
219
218
|
retriever = GraphCompletionRetriever()
|
|
220
219
|
|
|
221
|
-
with pytest.raises(DatabaseNotCreatedError):
|
|
222
|
-
await retriever.get_context("Who works at Figma?")
|
|
223
|
-
|
|
224
220
|
await setup()
|
|
225
221
|
|
|
226
222
|
context = await retriever.get_context("Who works at Figma?")
|