cognee 0.2.3.dev1__py3-none-any.whl → 0.3.0.dev0__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/__init__.py +1 -0
- cognee/__main__.py +4 -0
- cognee/api/client.py +28 -3
- cognee/api/health.py +10 -13
- cognee/api/v1/add/add.py +20 -6
- cognee/api/v1/add/routers/get_add_router.py +12 -37
- cognee/api/v1/cloud/routers/__init__.py +1 -0
- cognee/api/v1/cloud/routers/get_checks_router.py +23 -0
- cognee/api/v1/cognify/code_graph_pipeline.py +14 -3
- cognee/api/v1/cognify/cognify.py +67 -105
- cognee/api/v1/cognify/routers/get_cognify_router.py +11 -3
- cognee/api/v1/datasets/routers/get_datasets_router.py +16 -5
- cognee/api/v1/memify/routers/__init__.py +1 -0
- cognee/api/v1/memify/routers/get_memify_router.py +100 -0
- cognee/api/v1/notebooks/routers/__init__.py +1 -0
- cognee/api/v1/notebooks/routers/get_notebooks_router.py +96 -0
- cognee/api/v1/responses/default_tools.py +4 -0
- cognee/api/v1/responses/dispatch_function.py +6 -1
- cognee/api/v1/responses/models.py +1 -1
- cognee/api/v1/search/routers/get_search_router.py +20 -1
- cognee/api/v1/search/search.py +17 -4
- cognee/api/v1/sync/__init__.py +17 -0
- cognee/api/v1/sync/routers/__init__.py +3 -0
- cognee/api/v1/sync/routers/get_sync_router.py +241 -0
- cognee/api/v1/sync/sync.py +877 -0
- cognee/api/v1/users/routers/get_auth_router.py +13 -1
- cognee/base_config.py +10 -1
- cognee/cli/__init__.py +10 -0
- cognee/cli/_cognee.py +180 -0
- cognee/cli/commands/__init__.py +1 -0
- cognee/cli/commands/add_command.py +80 -0
- cognee/cli/commands/cognify_command.py +128 -0
- cognee/cli/commands/config_command.py +225 -0
- cognee/cli/commands/delete_command.py +80 -0
- cognee/cli/commands/search_command.py +149 -0
- cognee/cli/config.py +33 -0
- cognee/cli/debug.py +21 -0
- cognee/cli/echo.py +45 -0
- cognee/cli/exceptions.py +23 -0
- cognee/cli/minimal_cli.py +97 -0
- cognee/cli/reference.py +26 -0
- cognee/cli/suppress_logging.py +12 -0
- cognee/eval_framework/corpus_builder/corpus_builder_executor.py +2 -2
- cognee/eval_framework/eval_config.py +1 -1
- cognee/infrastructure/databases/graph/config.py +10 -4
- cognee/infrastructure/databases/graph/get_graph_engine.py +4 -9
- cognee/infrastructure/databases/graph/kuzu/adapter.py +199 -2
- cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +138 -0
- cognee/infrastructure/databases/relational/__init__.py +2 -0
- cognee/infrastructure/databases/relational/get_async_session.py +15 -0
- cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +6 -1
- cognee/infrastructure/databases/relational/with_async_session.py +25 -0
- cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +1 -1
- cognee/infrastructure/databases/vector/config.py +13 -6
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +6 -4
- cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +16 -7
- cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +5 -5
- cognee/infrastructure/databases/vector/embeddings/config.py +2 -2
- cognee/infrastructure/databases/vector/embeddings/embedding_rate_limiter.py +2 -6
- cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +10 -7
- cognee/infrastructure/files/storage/LocalFileStorage.py +9 -0
- cognee/infrastructure/files/storage/S3FileStorage.py +5 -0
- cognee/infrastructure/files/storage/StorageManager.py +7 -1
- cognee/infrastructure/files/storage/storage.py +16 -0
- cognee/infrastructure/files/utils/get_data_file_path.py +14 -9
- cognee/infrastructure/files/utils/get_file_metadata.py +2 -1
- cognee/infrastructure/llm/LLMGateway.py +32 -5
- cognee/infrastructure/llm/config.py +6 -4
- cognee/infrastructure/llm/prompts/extract_query_time.txt +15 -0
- cognee/infrastructure/llm/prompts/generate_event_entity_prompt.txt +25 -0
- cognee/infrastructure/llm/prompts/generate_event_graph_prompt.txt +30 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +16 -5
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/__init__.py +2 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/extract_event_entities.py +44 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/knowledge_graph/__init__.py +1 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/knowledge_graph/extract_content_graph.py +19 -15
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/knowledge_graph/extract_event_graph.py +46 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +3 -3
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +3 -3
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +2 -2
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +14 -8
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/ollama/adapter.py +6 -4
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +28 -4
- cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +2 -2
- cognee/infrastructure/llm/tokenizer/HuggingFace/adapter.py +3 -3
- cognee/infrastructure/llm/tokenizer/Mistral/adapter.py +3 -3
- cognee/infrastructure/llm/tokenizer/TikToken/adapter.py +6 -6
- cognee/infrastructure/llm/utils.py +7 -7
- cognee/infrastructure/utils/run_sync.py +8 -1
- cognee/modules/chunking/models/DocumentChunk.py +4 -3
- cognee/modules/cloud/exceptions/CloudApiKeyMissingError.py +15 -0
- cognee/modules/cloud/exceptions/CloudConnectionError.py +15 -0
- cognee/modules/cloud/exceptions/__init__.py +2 -0
- cognee/modules/cloud/operations/__init__.py +1 -0
- cognee/modules/cloud/operations/check_api_key.py +25 -0
- cognee/modules/data/deletion/prune_system.py +1 -1
- cognee/modules/data/methods/__init__.py +2 -0
- cognee/modules/data/methods/check_dataset_name.py +1 -1
- cognee/modules/data/methods/create_authorized_dataset.py +19 -0
- cognee/modules/data/methods/get_authorized_dataset.py +11 -5
- cognee/modules/data/methods/get_authorized_dataset_by_name.py +16 -0
- cognee/modules/data/methods/get_dataset_data.py +1 -1
- cognee/modules/data/methods/load_or_create_datasets.py +2 -20
- cognee/modules/engine/models/Event.py +16 -0
- cognee/modules/engine/models/Interval.py +8 -0
- cognee/modules/engine/models/Timestamp.py +13 -0
- cognee/modules/engine/models/__init__.py +3 -0
- cognee/modules/engine/utils/__init__.py +2 -0
- cognee/modules/engine/utils/generate_event_datapoint.py +46 -0
- cognee/modules/engine/utils/generate_timestamp_datapoint.py +51 -0
- cognee/modules/graph/cognee_graph/CogneeGraph.py +2 -2
- cognee/modules/graph/methods/get_formatted_graph_data.py +3 -2
- cognee/modules/graph/utils/__init__.py +1 -0
- cognee/modules/graph/utils/resolve_edges_to_text.py +71 -0
- cognee/modules/memify/__init__.py +1 -0
- cognee/modules/memify/memify.py +118 -0
- cognee/modules/notebooks/methods/__init__.py +5 -0
- cognee/modules/notebooks/methods/create_notebook.py +26 -0
- cognee/modules/notebooks/methods/delete_notebook.py +13 -0
- cognee/modules/notebooks/methods/get_notebook.py +21 -0
- cognee/modules/notebooks/methods/get_notebooks.py +18 -0
- cognee/modules/notebooks/methods/update_notebook.py +17 -0
- cognee/modules/notebooks/models/Notebook.py +53 -0
- cognee/modules/notebooks/models/__init__.py +1 -0
- cognee/modules/notebooks/operations/__init__.py +1 -0
- cognee/modules/notebooks/operations/run_in_local_sandbox.py +55 -0
- cognee/modules/pipelines/__init__.py +1 -1
- cognee/modules/pipelines/exceptions/tasks.py +18 -0
- cognee/modules/pipelines/layers/__init__.py +1 -0
- cognee/modules/pipelines/layers/check_pipeline_run_qualification.py +59 -0
- cognee/modules/pipelines/layers/pipeline_execution_mode.py +127 -0
- cognee/modules/pipelines/layers/reset_dataset_pipeline_run_status.py +28 -0
- cognee/modules/pipelines/layers/resolve_authorized_user_dataset.py +34 -0
- cognee/modules/pipelines/layers/resolve_authorized_user_datasets.py +55 -0
- cognee/modules/pipelines/layers/setup_and_check_environment.py +41 -0
- cognee/modules/pipelines/layers/validate_pipeline_tasks.py +20 -0
- cognee/modules/pipelines/methods/__init__.py +2 -0
- cognee/modules/pipelines/methods/get_pipeline_runs_by_dataset.py +34 -0
- cognee/modules/pipelines/methods/reset_pipeline_run_status.py +16 -0
- cognee/modules/pipelines/operations/__init__.py +0 -1
- cognee/modules/pipelines/operations/log_pipeline_run_initiated.py +1 -1
- cognee/modules/pipelines/operations/pipeline.py +24 -138
- cognee/modules/pipelines/operations/run_tasks.py +17 -41
- cognee/modules/retrieval/base_feedback.py +11 -0
- cognee/modules/retrieval/base_graph_retriever.py +18 -0
- cognee/modules/retrieval/base_retriever.py +1 -1
- cognee/modules/retrieval/code_retriever.py +8 -0
- cognee/modules/retrieval/coding_rules_retriever.py +31 -0
- cognee/modules/retrieval/completion_retriever.py +9 -3
- cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +1 -0
- cognee/modules/retrieval/cypher_search_retriever.py +1 -9
- cognee/modules/retrieval/graph_completion_context_extension_retriever.py +29 -13
- cognee/modules/retrieval/graph_completion_cot_retriever.py +30 -13
- cognee/modules/retrieval/graph_completion_retriever.py +107 -56
- cognee/modules/retrieval/graph_summary_completion_retriever.py +5 -1
- cognee/modules/retrieval/insights_retriever.py +14 -3
- cognee/modules/retrieval/natural_language_retriever.py +0 -4
- cognee/modules/retrieval/summaries_retriever.py +1 -1
- cognee/modules/retrieval/temporal_retriever.py +152 -0
- cognee/modules/retrieval/user_qa_feedback.py +83 -0
- cognee/modules/retrieval/utils/brute_force_triplet_search.py +7 -32
- cognee/modules/retrieval/utils/completion.py +10 -3
- cognee/modules/retrieval/utils/extract_uuid_from_node.py +18 -0
- cognee/modules/retrieval/utils/models.py +40 -0
- cognee/modules/search/methods/get_search_type_tools.py +168 -0
- cognee/modules/search/methods/no_access_control_search.py +47 -0
- cognee/modules/search/methods/search.py +239 -118
- cognee/modules/search/types/SearchResult.py +21 -0
- cognee/modules/search/types/SearchType.py +3 -0
- cognee/modules/search/types/__init__.py +1 -0
- cognee/modules/search/utils/__init__.py +2 -0
- cognee/modules/search/utils/prepare_search_result.py +41 -0
- cognee/modules/search/utils/transform_context_to_graph.py +38 -0
- cognee/modules/settings/get_settings.py +2 -2
- cognee/modules/sync/__init__.py +1 -0
- cognee/modules/sync/methods/__init__.py +23 -0
- cognee/modules/sync/methods/create_sync_operation.py +53 -0
- cognee/modules/sync/methods/get_sync_operation.py +107 -0
- cognee/modules/sync/methods/update_sync_operation.py +248 -0
- cognee/modules/sync/models/SyncOperation.py +142 -0
- cognee/modules/sync/models/__init__.py +3 -0
- cognee/modules/users/__init__.py +0 -1
- cognee/modules/users/methods/__init__.py +4 -1
- cognee/modules/users/methods/create_user.py +26 -1
- cognee/modules/users/methods/get_authenticated_user.py +36 -42
- cognee/modules/users/methods/get_default_user.py +3 -1
- cognee/modules/users/permissions/methods/get_specific_user_permission_datasets.py +2 -1
- cognee/root_dir.py +19 -0
- cognee/shared/CodeGraphEntities.py +1 -0
- cognee/shared/logging_utils.py +143 -32
- cognee/shared/utils.py +0 -1
- cognee/tasks/codingagents/coding_rule_associations.py +127 -0
- cognee/tasks/graph/extract_graph_from_data.py +6 -2
- cognee/tasks/ingestion/save_data_item_to_storage.py +23 -0
- cognee/tasks/memify/__init__.py +2 -0
- cognee/tasks/memify/extract_subgraph.py +7 -0
- cognee/tasks/memify/extract_subgraph_chunks.py +11 -0
- cognee/tasks/repo_processor/get_local_dependencies.py +2 -0
- cognee/tasks/repo_processor/get_repo_file_dependencies.py +144 -47
- cognee/tasks/storage/add_data_points.py +33 -3
- cognee/tasks/temporal_graph/__init__.py +1 -0
- cognee/tasks/temporal_graph/add_entities_to_event.py +85 -0
- cognee/tasks/temporal_graph/enrich_events.py +34 -0
- cognee/tasks/temporal_graph/extract_events_and_entities.py +32 -0
- cognee/tasks/temporal_graph/extract_knowledge_graph_from_events.py +41 -0
- cognee/tasks/temporal_graph/models.py +49 -0
- cognee/tests/integration/cli/__init__.py +3 -0
- cognee/tests/integration/cli/test_cli_integration.py +331 -0
- cognee/tests/integration/documents/PdfDocument_test.py +2 -2
- cognee/tests/integration/documents/TextDocument_test.py +2 -4
- cognee/tests/integration/documents/UnstructuredDocument_test.py +5 -8
- cognee/tests/{test_deletion.py → test_delete_hard.py} +0 -37
- cognee/tests/test_delete_soft.py +85 -0
- cognee/tests/test_kuzu.py +2 -2
- cognee/tests/test_neo4j.py +2 -2
- cognee/tests/test_permissions.py +3 -3
- cognee/tests/test_relational_db_migration.py +7 -5
- cognee/tests/test_search_db.py +136 -23
- cognee/tests/test_temporal_graph.py +167 -0
- cognee/tests/unit/api/__init__.py +1 -0
- cognee/tests/unit/api/test_conditional_authentication_endpoints.py +246 -0
- cognee/tests/unit/cli/__init__.py +3 -0
- cognee/tests/unit/cli/test_cli_commands.py +483 -0
- cognee/tests/unit/cli/test_cli_edge_cases.py +625 -0
- cognee/tests/unit/cli/test_cli_main.py +173 -0
- cognee/tests/unit/cli/test_cli_runner.py +62 -0
- cognee/tests/unit/cli/test_cli_utils.py +127 -0
- cognee/tests/unit/modules/retrieval/chunks_retriever_test.py +18 -2
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_context_extension_test.py +12 -15
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +10 -15
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +4 -3
- cognee/tests/unit/modules/retrieval/insights_retriever_test.py +4 -2
- cognee/tests/unit/modules/retrieval/rag_completion_retriever_test.py +18 -2
- cognee/tests/unit/modules/retrieval/temporal_retriever_test.py +225 -0
- cognee/tests/unit/modules/users/__init__.py +1 -0
- cognee/tests/unit/modules/users/test_conditional_authentication.py +277 -0
- cognee/tests/unit/processing/utils/utils_test.py +20 -1
- {cognee-0.2.3.dev1.dist-info → cognee-0.3.0.dev0.dist-info}/METADATA +13 -9
- {cognee-0.2.3.dev1.dist-info → cognee-0.3.0.dev0.dist-info}/RECORD +245 -135
- cognee-0.3.0.dev0.dist-info/entry_points.txt +2 -0
- cognee/infrastructure/databases/graph/networkx/adapter.py +0 -1017
- cognee/infrastructure/pipeline/models/Operation.py +0 -60
- cognee/notebooks/github_analysis_step_by_step.ipynb +0 -37
- cognee/tests/tasks/descriptive_metrics/networkx_metrics_test.py +0 -7
- cognee/tests/unit/modules/search/search_methods_test.py +0 -223
- /cognee/{infrastructure/databases/graph/networkx → api/v1/memify}/__init__.py +0 -0
- /cognee/{infrastructure/pipeline/models → tasks/codingagents}/__init__.py +0 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.3.0.dev0.dist-info}/WHEEL +0 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.3.0.dev0.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.3.0.dev0.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Integration tests for CLI commands that test end-to-end functionality.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import subprocess
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from unittest.mock import patch, MagicMock
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TestCliIntegration:
|
|
14
|
+
"""Integration tests for CLI commands"""
|
|
15
|
+
|
|
16
|
+
def test_cli_help(self):
|
|
17
|
+
"""Test that CLI help works"""
|
|
18
|
+
result = subprocess.run(
|
|
19
|
+
[sys.executable, "-m", "cognee.cli._cognee", "--help"],
|
|
20
|
+
capture_output=True,
|
|
21
|
+
text=True,
|
|
22
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
assert result.returncode == 0
|
|
26
|
+
assert "cognee" in result.stdout.lower()
|
|
27
|
+
assert "available commands" in result.stdout.lower()
|
|
28
|
+
|
|
29
|
+
def test_cli_version(self):
|
|
30
|
+
"""Test that CLI version works"""
|
|
31
|
+
result = subprocess.run(
|
|
32
|
+
[sys.executable, "-m", "cognee.cli._cognee", "--version"],
|
|
33
|
+
capture_output=True,
|
|
34
|
+
text=True,
|
|
35
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
assert result.returncode == 0
|
|
39
|
+
assert "cognee" in result.stdout.lower()
|
|
40
|
+
|
|
41
|
+
def test_command_help(self):
|
|
42
|
+
"""Test that individual command help works"""
|
|
43
|
+
commands = ["add", "search", "cognify", "delete", "config"]
|
|
44
|
+
|
|
45
|
+
for command in commands:
|
|
46
|
+
result = subprocess.run(
|
|
47
|
+
[sys.executable, "-m", "cognee.cli._cognee", command, "--help"],
|
|
48
|
+
capture_output=True,
|
|
49
|
+
text=True,
|
|
50
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
assert result.returncode == 0, f"Command {command} help failed"
|
|
54
|
+
assert command in result.stdout.lower()
|
|
55
|
+
|
|
56
|
+
def test_invalid_command(self):
|
|
57
|
+
"""Test that invalid commands are handled properly"""
|
|
58
|
+
result = subprocess.run(
|
|
59
|
+
[sys.executable, "-m", "cognee.cli._cognee", "invalid_command"],
|
|
60
|
+
capture_output=True,
|
|
61
|
+
text=True,
|
|
62
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
assert result.returncode != 0
|
|
66
|
+
|
|
67
|
+
@patch("cognee.add")
|
|
68
|
+
def test_add_command_integration(self, mock_add):
|
|
69
|
+
"""Test add command integration"""
|
|
70
|
+
mock_add.return_value = None
|
|
71
|
+
|
|
72
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
|
|
73
|
+
f.write("Test content for CLI integration")
|
|
74
|
+
temp_file = f.name
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
result = subprocess.run(
|
|
78
|
+
[sys.executable, "-m", "cognee.cli._cognee", "add", temp_file],
|
|
79
|
+
capture_output=True,
|
|
80
|
+
text=True,
|
|
81
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Note: This might fail due to dependencies, but we're testing the CLI structure
|
|
85
|
+
# The important thing is that it doesn't crash with argument parsing errors
|
|
86
|
+
# Allow litellm logging worker cancellation errors as they're expected during process shutdown
|
|
87
|
+
stderr_lower = result.stderr.lower()
|
|
88
|
+
has_error = "error" in stderr_lower
|
|
89
|
+
has_expected_failure = "failed to add data" in stderr_lower
|
|
90
|
+
has_litellm_cancellation = (
|
|
91
|
+
"loggingworker cancelled" in stderr_lower or "cancellederror" in stderr_lower
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
assert not has_error or has_expected_failure or has_litellm_cancellation
|
|
95
|
+
|
|
96
|
+
finally:
|
|
97
|
+
os.unlink(temp_file)
|
|
98
|
+
|
|
99
|
+
def test_config_subcommands(self):
|
|
100
|
+
"""Test config subcommands help"""
|
|
101
|
+
subcommands = ["get", "set", "list", "unset", "reset"]
|
|
102
|
+
|
|
103
|
+
for subcommand in subcommands:
|
|
104
|
+
result = subprocess.run(
|
|
105
|
+
[sys.executable, "-m", "cognee.cli._cognee", "config", subcommand, "--help"],
|
|
106
|
+
capture_output=True,
|
|
107
|
+
text=True,
|
|
108
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
assert result.returncode == 0, f"Config {subcommand} help failed"
|
|
112
|
+
|
|
113
|
+
def test_search_command_missing_query(self):
|
|
114
|
+
"""Test search command fails when query is missing"""
|
|
115
|
+
result = subprocess.run(
|
|
116
|
+
[sys.executable, "-m", "cognee.cli._cognee", "search"],
|
|
117
|
+
capture_output=True,
|
|
118
|
+
text=True,
|
|
119
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
assert result.returncode != 0
|
|
123
|
+
assert "required" in result.stderr.lower() or "error" in result.stderr.lower()
|
|
124
|
+
|
|
125
|
+
def test_delete_command_no_target(self):
|
|
126
|
+
"""Test delete command with no target specified"""
|
|
127
|
+
result = subprocess.run(
|
|
128
|
+
[sys.executable, "-m", "cognee.cli._cognee", "delete"],
|
|
129
|
+
capture_output=True,
|
|
130
|
+
text=True,
|
|
131
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Should run but show error message about missing target
|
|
135
|
+
# Return code might be 0 since the command handles this gracefully
|
|
136
|
+
assert (
|
|
137
|
+
"specify what to delete" in result.stdout.lower()
|
|
138
|
+
or "specify what to delete" in result.stderr.lower()
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class TestCliArgumentParsing:
|
|
143
|
+
"""Test CLI argument parsing edge cases"""
|
|
144
|
+
|
|
145
|
+
def test_add_multiple_files(self):
|
|
146
|
+
"""Test add command with multiple file arguments"""
|
|
147
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
148
|
+
file1 = os.path.join(temp_dir, "file1.txt")
|
|
149
|
+
file2 = os.path.join(temp_dir, "file2.txt")
|
|
150
|
+
|
|
151
|
+
with open(file1, "w") as f:
|
|
152
|
+
f.write("Content 1")
|
|
153
|
+
with open(file2, "w") as f:
|
|
154
|
+
f.write("Content 2")
|
|
155
|
+
|
|
156
|
+
result = subprocess.run(
|
|
157
|
+
[
|
|
158
|
+
sys.executable,
|
|
159
|
+
"-m",
|
|
160
|
+
"cognee.cli._cognee",
|
|
161
|
+
"add",
|
|
162
|
+
file1,
|
|
163
|
+
file2,
|
|
164
|
+
"--dataset-name",
|
|
165
|
+
"test",
|
|
166
|
+
],
|
|
167
|
+
capture_output=True,
|
|
168
|
+
text=True,
|
|
169
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# Test that argument parsing works (regardless of actual execution)
|
|
173
|
+
assert (
|
|
174
|
+
"argument" not in result.stderr.lower() or "failed to add" in result.stderr.lower()
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
def test_search_with_all_options(self):
|
|
178
|
+
"""Test search command with all possible options"""
|
|
179
|
+
result = subprocess.run(
|
|
180
|
+
[
|
|
181
|
+
sys.executable,
|
|
182
|
+
"-m",
|
|
183
|
+
"cognee.cli._cognee",
|
|
184
|
+
"search",
|
|
185
|
+
"test query",
|
|
186
|
+
"--query-type",
|
|
187
|
+
"CHUNKS",
|
|
188
|
+
"--datasets",
|
|
189
|
+
"dataset1",
|
|
190
|
+
"dataset2",
|
|
191
|
+
"--top-k",
|
|
192
|
+
"5",
|
|
193
|
+
"--output-format",
|
|
194
|
+
"json",
|
|
195
|
+
],
|
|
196
|
+
capture_output=True,
|
|
197
|
+
text=True,
|
|
198
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# Should not have argument parsing errors
|
|
202
|
+
assert "unrecognized arguments" not in result.stderr.lower()
|
|
203
|
+
assert "invalid choice" not in result.stderr.lower()
|
|
204
|
+
|
|
205
|
+
def test_cognify_with_all_options(self):
|
|
206
|
+
"""Test cognify command with all possible options"""
|
|
207
|
+
result = subprocess.run(
|
|
208
|
+
[
|
|
209
|
+
sys.executable,
|
|
210
|
+
"-m",
|
|
211
|
+
"cognee.cli._cognee",
|
|
212
|
+
"cognify",
|
|
213
|
+
"--datasets",
|
|
214
|
+
"dataset1",
|
|
215
|
+
"dataset2",
|
|
216
|
+
"--chunk-size",
|
|
217
|
+
"1024",
|
|
218
|
+
"--chunker",
|
|
219
|
+
"TextChunker",
|
|
220
|
+
"--background",
|
|
221
|
+
"--verbose",
|
|
222
|
+
],
|
|
223
|
+
capture_output=True,
|
|
224
|
+
text=True,
|
|
225
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
# Should not have argument parsing errors
|
|
229
|
+
assert "unrecognized arguments" not in result.stderr.lower()
|
|
230
|
+
assert "invalid choice" not in result.stderr.lower()
|
|
231
|
+
|
|
232
|
+
def test_config_set_command(self):
|
|
233
|
+
"""Test config set command argument parsing"""
|
|
234
|
+
result = subprocess.run(
|
|
235
|
+
[sys.executable, "-m", "cognee.cli._cognee", "config", "set", "test_key", "test_value"],
|
|
236
|
+
capture_output=True,
|
|
237
|
+
text=True,
|
|
238
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
# Should not have argument parsing errors
|
|
242
|
+
assert "unrecognized arguments" not in result.stderr.lower()
|
|
243
|
+
assert "required" not in result.stderr.lower() or "failed to set" in result.stderr.lower()
|
|
244
|
+
|
|
245
|
+
def test_delete_with_force(self):
|
|
246
|
+
"""Test delete command with force flag"""
|
|
247
|
+
result = subprocess.run(
|
|
248
|
+
[
|
|
249
|
+
sys.executable,
|
|
250
|
+
"-m",
|
|
251
|
+
"cognee.cli._cognee",
|
|
252
|
+
"delete",
|
|
253
|
+
"--dataset-name",
|
|
254
|
+
"test_dataset",
|
|
255
|
+
"--force",
|
|
256
|
+
],
|
|
257
|
+
capture_output=True,
|
|
258
|
+
text=True,
|
|
259
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Should not have argument parsing errors
|
|
263
|
+
assert "unrecognized arguments" not in result.stderr.lower()
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class TestCliErrorHandling:
|
|
267
|
+
"""Test CLI error handling and edge cases"""
|
|
268
|
+
|
|
269
|
+
def test_debug_mode_flag(self):
|
|
270
|
+
"""Test that debug flag is accepted"""
|
|
271
|
+
result = subprocess.run(
|
|
272
|
+
[sys.executable, "-m", "cognee.cli._cognee", "--debug", "search", "test query"],
|
|
273
|
+
capture_output=True,
|
|
274
|
+
text=True,
|
|
275
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
# Should not have argument parsing errors for debug flag
|
|
279
|
+
assert "unrecognized arguments" not in result.stderr.lower()
|
|
280
|
+
|
|
281
|
+
def test_invalid_search_type(self):
|
|
282
|
+
"""Test invalid search type handling"""
|
|
283
|
+
result = subprocess.run(
|
|
284
|
+
[
|
|
285
|
+
sys.executable,
|
|
286
|
+
"-m",
|
|
287
|
+
"cognee.cli._cognee",
|
|
288
|
+
"search",
|
|
289
|
+
"test query",
|
|
290
|
+
"--query-type",
|
|
291
|
+
"INVALID_TYPE",
|
|
292
|
+
],
|
|
293
|
+
capture_output=True,
|
|
294
|
+
text=True,
|
|
295
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
assert result.returncode != 0
|
|
299
|
+
assert "invalid choice" in result.stderr.lower()
|
|
300
|
+
|
|
301
|
+
def test_invalid_chunker(self):
|
|
302
|
+
"""Test invalid chunker handling"""
|
|
303
|
+
result = subprocess.run(
|
|
304
|
+
[sys.executable, "-m", "cognee.cli._cognee", "cognify", "--chunker", "InvalidChunker"],
|
|
305
|
+
capture_output=True,
|
|
306
|
+
text=True,
|
|
307
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
assert result.returncode != 0
|
|
311
|
+
assert "invalid choice" in result.stderr.lower()
|
|
312
|
+
|
|
313
|
+
def test_invalid_output_format(self):
|
|
314
|
+
"""Test invalid output format handling"""
|
|
315
|
+
result = subprocess.run(
|
|
316
|
+
[
|
|
317
|
+
sys.executable,
|
|
318
|
+
"-m",
|
|
319
|
+
"cognee.cli._cognee",
|
|
320
|
+
"search",
|
|
321
|
+
"test query",
|
|
322
|
+
"--output-format",
|
|
323
|
+
"invalid",
|
|
324
|
+
],
|
|
325
|
+
capture_output=True,
|
|
326
|
+
text=True,
|
|
327
|
+
cwd=Path(__file__).parent.parent.parent, # Go to project root
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
assert result.returncode != 0
|
|
331
|
+
assert "invalid choice" in result.stderr.lower()
|
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import uuid
|
|
4
4
|
import pytest
|
|
5
|
+
import pathlib
|
|
5
6
|
from unittest.mock import patch
|
|
6
7
|
|
|
7
8
|
from cognee.modules.chunking.TextChunker import TextChunker
|
|
@@ -24,8 +25,7 @@ GROUND_TRUTH = [
|
|
|
24
25
|
@pytest.mark.asyncio
|
|
25
26
|
async def test_PdfDocument(mock_engine):
|
|
26
27
|
test_file_path = os.path.join(
|
|
27
|
-
|
|
28
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
28
|
+
pathlib.Path(__file__).parent.parent.parent,
|
|
29
29
|
"test_data",
|
|
30
30
|
"artificial-intelligence.pdf",
|
|
31
31
|
)
|
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import uuid
|
|
4
4
|
import pytest
|
|
5
|
+
import pathlib
|
|
5
6
|
from unittest.mock import patch
|
|
6
7
|
|
|
7
8
|
from cognee.modules.chunking.TextChunker import TextChunker
|
|
@@ -34,10 +35,7 @@ GROUND_TRUTH = {
|
|
|
34
35
|
@pytest.mark.asyncio
|
|
35
36
|
async def test_TextDocument(mock_engine, input_file, chunk_size):
|
|
36
37
|
test_file_path = os.path.join(
|
|
37
|
-
|
|
38
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
39
|
-
"test_data",
|
|
40
|
-
input_file,
|
|
38
|
+
pathlib.Path(__file__).parent.parent.parent, "test_data", input_file
|
|
41
39
|
)
|
|
42
40
|
document = TextDocument(
|
|
43
41
|
id=uuid.uuid4(),
|
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import uuid
|
|
4
4
|
import pytest
|
|
5
|
+
import pathlib
|
|
5
6
|
from unittest.mock import patch
|
|
6
7
|
|
|
7
8
|
from cognee.modules.chunking.TextChunker import TextChunker
|
|
@@ -18,29 +19,25 @@ chunk_by_sentence_module = sys.modules.get("cognee.tasks.chunks.chunk_by_sentenc
|
|
|
18
19
|
async def test_UnstructuredDocument(mock_engine):
|
|
19
20
|
# Define file paths of test data
|
|
20
21
|
pptx_file_path = os.path.join(
|
|
21
|
-
|
|
22
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
22
|
+
pathlib.Path(__file__).parent.parent.parent,
|
|
23
23
|
"test_data",
|
|
24
24
|
"example.pptx",
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
docx_file_path = os.path.join(
|
|
28
|
-
|
|
29
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
28
|
+
pathlib.Path(__file__).parent.parent.parent,
|
|
30
29
|
"test_data",
|
|
31
30
|
"example.docx",
|
|
32
31
|
)
|
|
33
32
|
|
|
34
33
|
csv_file_path = os.path.join(
|
|
35
|
-
|
|
36
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
34
|
+
pathlib.Path(__file__).parent.parent.parent,
|
|
37
35
|
"test_data",
|
|
38
36
|
"example.csv",
|
|
39
37
|
)
|
|
40
38
|
|
|
41
39
|
xlsx_file_path = os.path.join(
|
|
42
|
-
|
|
43
|
-
*(os.path.dirname(__file__).split(os.sep)[:-2]),
|
|
40
|
+
pathlib.Path(__file__).parent.parent.parent,
|
|
44
41
|
"test_data",
|
|
45
42
|
"example.xlsx",
|
|
46
43
|
)
|
|
@@ -45,8 +45,6 @@ async def main():
|
|
|
45
45
|
Each of these car manufacturer contributes to Germany's reputation as a leader in the global automotive industry, showcasing a blend of innovation, performance, and design excellence.
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
|
-
################### HARD DELETE
|
|
49
|
-
|
|
50
48
|
# Add documents and get dataset information
|
|
51
49
|
add_result = await cognee.add(
|
|
52
50
|
[
|
|
@@ -80,41 +78,6 @@ async def main():
|
|
|
80
78
|
|
|
81
79
|
assert len(nodes) == 0 and len(edges) == 0, "Document is not deleted with hard delete."
|
|
82
80
|
|
|
83
|
-
################### SOFT DELETE
|
|
84
|
-
|
|
85
|
-
# Add documents and get dataset information
|
|
86
|
-
add_result = await cognee.add(
|
|
87
|
-
[
|
|
88
|
-
pdf_document,
|
|
89
|
-
txt_document,
|
|
90
|
-
text_document_as_literal,
|
|
91
|
-
unstructured_document,
|
|
92
|
-
audio_document,
|
|
93
|
-
image_document,
|
|
94
|
-
]
|
|
95
|
-
)
|
|
96
|
-
dataset_id = add_result.dataset_id
|
|
97
|
-
|
|
98
|
-
await cognee.cognify()
|
|
99
|
-
|
|
100
|
-
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
101
|
-
|
|
102
|
-
graph_engine = await get_graph_engine()
|
|
103
|
-
nodes, edges = await graph_engine.get_graph_data()
|
|
104
|
-
assert len(nodes) > 10 and len(edges) > 10, "Graph database is not loaded."
|
|
105
|
-
|
|
106
|
-
# Get the data IDs from the dataset
|
|
107
|
-
dataset_data = await get_dataset_data(dataset_id)
|
|
108
|
-
assert len(dataset_data) > 0, "Dataset should contain data"
|
|
109
|
-
|
|
110
|
-
# Delete each document using its ID
|
|
111
|
-
for data_item in dataset_data:
|
|
112
|
-
await cognee.delete(data_item.id, dataset_id, mode="soft")
|
|
113
|
-
|
|
114
|
-
nodes, edges = await graph_engine.get_graph_data()
|
|
115
|
-
|
|
116
|
-
assert len(nodes) == 0 and len(edges) == 0, "Document is not deleted with soft delete."
|
|
117
|
-
|
|
118
81
|
|
|
119
82
|
if __name__ == "__main__":
|
|
120
83
|
import asyncio
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
import cognee
|
|
4
|
+
import pathlib
|
|
5
|
+
from cognee.shared.logging_utils import get_logger
|
|
6
|
+
from cognee.modules.data.methods import get_dataset_data
|
|
7
|
+
|
|
8
|
+
logger = get_logger()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def main():
|
|
12
|
+
await cognee.prune.prune_data()
|
|
13
|
+
await cognee.prune.prune_system(metadata=True)
|
|
14
|
+
|
|
15
|
+
pdf_document = os.path.join(
|
|
16
|
+
pathlib.Path(__file__).parent, "test_data/artificial-intelligence.pdf"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
txt_document = os.path.join(
|
|
20
|
+
pathlib.Path(__file__).parent, "test_data/Natural_language_processing_copy.txt"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
audio_document = os.path.join(pathlib.Path(__file__).parent, "test_data/text_to_speech.mp3")
|
|
24
|
+
|
|
25
|
+
image_document = os.path.join(pathlib.Path(__file__).parent, "test_data/example.png")
|
|
26
|
+
|
|
27
|
+
unstructured_document = os.path.join(pathlib.Path(__file__).parent, "test_data/example.pptx")
|
|
28
|
+
|
|
29
|
+
text_document_as_literal = """
|
|
30
|
+
1. Audi
|
|
31
|
+
Audi is known for its modern designs and advanced technology. Founded in the early 1900s, the brand has earned a reputation for precision engineering and innovation. With features like the Quattro all-wheel-drive system, Audi offers a range of vehicles from stylish sedans to high-performance sports cars.
|
|
32
|
+
|
|
33
|
+
2. BMW
|
|
34
|
+
BMW, short for Bayerische Motoren Werke, is celebrated for its focus on performance and driving pleasure. The company's vehicles are designed to provide a dynamic and engaging driving experience, and their slogan, "The Ultimate Driving Machine," reflects that commitment. BMW produces a variety of cars that combine luxury with sporty performance.
|
|
35
|
+
|
|
36
|
+
3. Mercedes-Benz
|
|
37
|
+
Mercedes-Benz is synonymous with luxury and quality. With a history dating back to the early 20th century, the brand is known for its elegant designs, innovative safety features, and high-quality engineering. Mercedes-Benz manufactures not only luxury sedans but also SUVs, sports cars, and commercial vehicles, catering to a wide range of needs.
|
|
38
|
+
|
|
39
|
+
4. Porsche
|
|
40
|
+
Porsche is a name that stands for high-performance sports cars. Founded in 1931, the brand has become famous for models like the iconic Porsche 911. Porsche cars are celebrated for their speed, precision, and distinctive design, appealing to car enthusiasts who value both performance and style.
|
|
41
|
+
|
|
42
|
+
5. Volkswagen
|
|
43
|
+
Volkswagen, which means "people's car" in German, was established with the idea of making affordable and reliable vehicles accessible to everyone. Over the years, Volkswagen has produced several iconic models, such as the Beetle and the Golf. Today, it remains one of the largest car manufacturers in the world, offering a wide range of vehicles that balance practicality with quality.
|
|
44
|
+
|
|
45
|
+
Each of these car manufacturer contributes to Germany's reputation as a leader in the global automotive industry, showcasing a blend of innovation, performance, and design excellence.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
# Add documents and get dataset information
|
|
49
|
+
add_result = await cognee.add(
|
|
50
|
+
[
|
|
51
|
+
pdf_document,
|
|
52
|
+
txt_document,
|
|
53
|
+
text_document_as_literal,
|
|
54
|
+
unstructured_document,
|
|
55
|
+
audio_document,
|
|
56
|
+
image_document,
|
|
57
|
+
]
|
|
58
|
+
)
|
|
59
|
+
dataset_id = add_result.dataset_id
|
|
60
|
+
|
|
61
|
+
await cognee.cognify()
|
|
62
|
+
|
|
63
|
+
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
64
|
+
|
|
65
|
+
graph_engine = await get_graph_engine()
|
|
66
|
+
nodes, edges = await graph_engine.get_graph_data()
|
|
67
|
+
assert len(nodes) > 10 and len(edges) > 10, "Graph database is not loaded."
|
|
68
|
+
|
|
69
|
+
# Get the data IDs from the dataset
|
|
70
|
+
dataset_data = await get_dataset_data(dataset_id)
|
|
71
|
+
assert len(dataset_data) > 0, "Dataset should contain data"
|
|
72
|
+
|
|
73
|
+
# Delete each document using its ID
|
|
74
|
+
for data_item in dataset_data:
|
|
75
|
+
await cognee.delete(data_item.id, dataset_id, mode="soft")
|
|
76
|
+
|
|
77
|
+
nodes, edges = await graph_engine.get_graph_data()
|
|
78
|
+
|
|
79
|
+
assert len(nodes) == 0 and len(edges) == 0, "Document is not deleted with soft delete."
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
import asyncio
|
|
84
|
+
|
|
85
|
+
asyncio.run(main())
|
cognee/tests/test_kuzu.py
CHANGED
|
@@ -104,11 +104,11 @@ async def main():
|
|
|
104
104
|
node_name=["nonexistent"],
|
|
105
105
|
).get_context("What is in the context?")
|
|
106
106
|
|
|
107
|
-
assert isinstance(context_nonempty,
|
|
107
|
+
assert isinstance(context_nonempty, list) and context_nonempty != [], (
|
|
108
108
|
f"Nodeset_search_test:Expected non-empty string for context_nonempty, got: {context_nonempty!r}"
|
|
109
109
|
)
|
|
110
110
|
|
|
111
|
-
assert context_empty ==
|
|
111
|
+
assert context_empty == [], (
|
|
112
112
|
f"Nodeset_search_test:Expected empty string for context_empty, got: {context_empty!r}"
|
|
113
113
|
)
|
|
114
114
|
|
cognee/tests/test_neo4j.py
CHANGED
|
@@ -108,11 +108,11 @@ async def main():
|
|
|
108
108
|
node_name=["nonexistent"],
|
|
109
109
|
).get_context("What is in the context?")
|
|
110
110
|
|
|
111
|
-
assert isinstance(context_nonempty,
|
|
111
|
+
assert isinstance(context_nonempty, list) and context_nonempty != [], (
|
|
112
112
|
f"Nodeset_search_test:Expected non-empty string for context_nonempty, got: {context_nonempty!r}"
|
|
113
113
|
)
|
|
114
114
|
|
|
115
|
-
assert context_empty ==
|
|
115
|
+
assert context_empty == [], (
|
|
116
116
|
f"Nodeset_search_test:Expected empty string for context_empty, got: {context_empty!r}"
|
|
117
117
|
)
|
|
118
118
|
|
cognee/tests/test_permissions.py
CHANGED
|
@@ -79,7 +79,7 @@ async def main():
|
|
|
79
79
|
print("\n\nExtracted sentences are:\n")
|
|
80
80
|
for result in search_results:
|
|
81
81
|
print(f"{result}\n")
|
|
82
|
-
assert search_results[0]
|
|
82
|
+
assert search_results[0].dataset_name == "NLP", (
|
|
83
83
|
f"Dict must contain dataset name 'NLP': {search_results[0]}"
|
|
84
84
|
)
|
|
85
85
|
|
|
@@ -93,7 +93,7 @@ async def main():
|
|
|
93
93
|
print("\n\nExtracted sentences are:\n")
|
|
94
94
|
for result in search_results:
|
|
95
95
|
print(f"{result}\n")
|
|
96
|
-
assert search_results[0]
|
|
96
|
+
assert search_results[0].dataset_name == "QUANTUM", (
|
|
97
97
|
f"Dict must contain dataset name 'QUANTUM': {search_results[0]}"
|
|
98
98
|
)
|
|
99
99
|
|
|
@@ -170,7 +170,7 @@ async def main():
|
|
|
170
170
|
for result in search_results:
|
|
171
171
|
print(f"{result}\n")
|
|
172
172
|
|
|
173
|
-
assert search_results[0]
|
|
173
|
+
assert search_results[0].dataset_name == "QUANTUM", (
|
|
174
174
|
f"Dict must contain dataset name 'QUANTUM': {search_results[0]}"
|
|
175
175
|
)
|
|
176
176
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import json
|
|
2
1
|
import pathlib
|
|
3
2
|
import os
|
|
3
|
+
from typing import List
|
|
4
4
|
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
5
5
|
from cognee.infrastructure.databases.relational import (
|
|
6
6
|
get_migration_relational_engine,
|
|
@@ -10,7 +10,7 @@ from cognee.infrastructure.databases.vector.pgvector import (
|
|
|
10
10
|
create_db_and_tables as create_pgvector_db_and_tables,
|
|
11
11
|
)
|
|
12
12
|
from cognee.tasks.ingestion import migrate_relational_database
|
|
13
|
-
from cognee.modules.search.types import SearchType
|
|
13
|
+
from cognee.modules.search.types import SearchResult, SearchType
|
|
14
14
|
import cognee
|
|
15
15
|
|
|
16
16
|
|
|
@@ -45,13 +45,15 @@ async def relational_db_migration():
|
|
|
45
45
|
await migrate_relational_database(graph_engine, schema=schema)
|
|
46
46
|
|
|
47
47
|
# 1. Search the graph
|
|
48
|
-
search_results = await cognee.search(
|
|
48
|
+
search_results: List[SearchResult] = await cognee.search(
|
|
49
49
|
query_type=SearchType.GRAPH_COMPLETION, query_text="Tell me about the artist AC/DC"
|
|
50
|
-
)
|
|
50
|
+
) # type: ignore
|
|
51
51
|
print("Search results:", search_results)
|
|
52
52
|
|
|
53
53
|
# 2. Assert that the search results contain "AC/DC"
|
|
54
|
-
assert any("AC/DC" in r for r in search_results),
|
|
54
|
+
assert any("AC/DC" in r.search_result for r in search_results), (
|
|
55
|
+
"AC/DC not found in search results!"
|
|
56
|
+
)
|
|
55
57
|
|
|
56
58
|
migration_db_provider = migration_engine.engine.dialect.name
|
|
57
59
|
if migration_db_provider == "postgresql":
|