cognee 0.2.3.dev1__py3-none-any.whl → 0.2.4__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/__main__.py +4 -0
- cognee/api/v1/add/add.py +18 -6
- cognee/api/v1/cognify/code_graph_pipeline.py +7 -1
- cognee/api/v1/cognify/cognify.py +22 -107
- cognee/api/v1/cognify/routers/get_cognify_router.py +11 -3
- cognee/api/v1/datasets/routers/get_datasets_router.py +1 -1
- 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/search.py +6 -0
- 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/get_graph_engine.py +4 -9
- cognee/infrastructure/databases/graph/kuzu/adapter.py +64 -2
- cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +49 -0
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +5 -3
- 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/get_embedding_engine.py +6 -6
- 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 +14 -5
- cognee/infrastructure/llm/config.py +5 -5
- 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/knowledge_graph/extract_content_graph.py +19 -15
- 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 +3 -3
- 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/modules/data/methods/__init__.py +2 -0
- 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/load_or_create_datasets.py +2 -20
- cognee/modules/graph/methods/get_formatted_graph_data.py +3 -2
- 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 +12 -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 +23 -138
- cognee/modules/retrieval/base_feedback.py +11 -0
- cognee/modules/retrieval/cypher_search_retriever.py +1 -9
- cognee/modules/retrieval/graph_completion_context_extension_retriever.py +9 -2
- cognee/modules/retrieval/graph_completion_cot_retriever.py +13 -6
- cognee/modules/retrieval/graph_completion_retriever.py +89 -5
- cognee/modules/retrieval/graph_summary_completion_retriever.py +2 -0
- cognee/modules/retrieval/natural_language_retriever.py +0 -4
- cognee/modules/retrieval/user_qa_feedback.py +83 -0
- cognee/modules/retrieval/utils/extract_uuid_from_node.py +18 -0
- cognee/modules/retrieval/utils/models.py +40 -0
- cognee/modules/search/methods/search.py +46 -5
- cognee/modules/search/types/SearchType.py +1 -0
- cognee/modules/settings/get_settings.py +2 -2
- cognee/shared/CodeGraphEntities.py +1 -0
- cognee/shared/logging_utils.py +142 -31
- cognee/shared/utils.py +0 -1
- cognee/tasks/graph/extract_graph_from_data.py +6 -2
- cognee/tasks/repo_processor/get_local_dependencies.py +2 -0
- cognee/tasks/repo_processor/get_repo_file_dependencies.py +120 -48
- cognee/tasks/storage/add_data_points.py +33 -3
- 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_search_db.py +126 -7
- 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/graph_completion_retriever_context_extension_test.py +3 -3
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +3 -3
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +3 -3
- cognee/tests/unit/modules/search/search_methods_test.py +2 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.2.4.dist-info}/METADATA +7 -5
- {cognee-0.2.3.dev1.dist-info → cognee-0.2.4.dist-info}/RECORD +120 -83
- cognee-0.2.4.dist-info/entry_points.txt +2 -0
- cognee/infrastructure/databases/graph/networkx/__init__.py +0 -0
- cognee/infrastructure/databases/graph/networkx/adapter.py +0 -1017
- cognee/infrastructure/pipeline/models/Operation.py +0 -60
- cognee/infrastructure/pipeline/models/__init__.py +0 -0
- cognee/notebooks/github_analysis_step_by_step.ipynb +0 -37
- cognee/tests/tasks/descriptive_metrics/networkx_metrics_test.py +0 -7
- {cognee-0.2.3.dev1.dist-info → cognee-0.2.4.dist-info}/WHEEL +0 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.2.3.dev1.dist-info → cognee-0.2.4.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for the main CLI entry point and command discovery.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
import argparse
|
|
7
|
+
from unittest.mock import patch, MagicMock
|
|
8
|
+
from cognee.cli._cognee import main, _discover_commands, _create_parser
|
|
9
|
+
from cognee.cli.exceptions import CliCommandException, CliCommandInnerException
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestCliMain:
|
|
13
|
+
"""Test the main CLI functionality"""
|
|
14
|
+
|
|
15
|
+
def test_discover_commands(self):
|
|
16
|
+
"""Test that all expected commands are discovered"""
|
|
17
|
+
commands = _discover_commands()
|
|
18
|
+
|
|
19
|
+
# Check that we get command classes back
|
|
20
|
+
assert len(commands) > 0
|
|
21
|
+
|
|
22
|
+
# Check that we have the expected commands
|
|
23
|
+
command_strings = []
|
|
24
|
+
for command_class in commands:
|
|
25
|
+
command = command_class()
|
|
26
|
+
command_strings.append(command.command_string)
|
|
27
|
+
|
|
28
|
+
expected_commands = ["add", "search", "cognify", "delete", "config"]
|
|
29
|
+
for expected_command in expected_commands:
|
|
30
|
+
assert expected_command in command_strings
|
|
31
|
+
|
|
32
|
+
def test_create_parser(self):
|
|
33
|
+
"""Test parser creation and command installation"""
|
|
34
|
+
parser, installed_commands = _create_parser()
|
|
35
|
+
|
|
36
|
+
# Check parser is created
|
|
37
|
+
assert isinstance(parser, argparse.ArgumentParser)
|
|
38
|
+
|
|
39
|
+
# Check commands are installed
|
|
40
|
+
expected_commands = ["add", "search", "cognify", "delete", "config"]
|
|
41
|
+
for expected_command in expected_commands:
|
|
42
|
+
assert expected_command in installed_commands
|
|
43
|
+
|
|
44
|
+
# Check parser has version argument
|
|
45
|
+
actions = [action.dest for action in parser._actions]
|
|
46
|
+
assert "version" in actions
|
|
47
|
+
|
|
48
|
+
@patch("cognee.cli._cognee._create_parser")
|
|
49
|
+
def test_main_no_command(self, mock_create_parser):
|
|
50
|
+
"""Test main function when no command is provided"""
|
|
51
|
+
mock_parser = MagicMock()
|
|
52
|
+
mock_parser.parse_args.return_value = MagicMock(command=None)
|
|
53
|
+
mock_create_parser.return_value = (mock_parser, {})
|
|
54
|
+
|
|
55
|
+
result = main()
|
|
56
|
+
|
|
57
|
+
assert result == -1
|
|
58
|
+
mock_parser.print_help.assert_called_once()
|
|
59
|
+
|
|
60
|
+
@patch("cognee.cli._cognee._create_parser")
|
|
61
|
+
def test_main_with_valid_command(self, mock_create_parser):
|
|
62
|
+
"""Test main function with a valid command"""
|
|
63
|
+
mock_command = MagicMock()
|
|
64
|
+
mock_command.execute.return_value = None
|
|
65
|
+
|
|
66
|
+
mock_parser = MagicMock()
|
|
67
|
+
mock_args = MagicMock(command="test")
|
|
68
|
+
mock_parser.parse_args.return_value = mock_args
|
|
69
|
+
|
|
70
|
+
mock_create_parser.return_value = (mock_parser, {"test": mock_command})
|
|
71
|
+
|
|
72
|
+
result = main()
|
|
73
|
+
|
|
74
|
+
assert result == 0
|
|
75
|
+
mock_command.execute.assert_called_once_with(mock_args)
|
|
76
|
+
|
|
77
|
+
@patch("cognee.cli._cognee._create_parser")
|
|
78
|
+
@patch("cognee.cli.debug.is_debug_enabled")
|
|
79
|
+
def test_main_with_command_exception(self, mock_debug, mock_create_parser):
|
|
80
|
+
"""Test main function when command raises exception"""
|
|
81
|
+
mock_debug.return_value = False
|
|
82
|
+
|
|
83
|
+
mock_command = MagicMock()
|
|
84
|
+
mock_command.execute.side_effect = CliCommandException("Test error", error_code=2)
|
|
85
|
+
|
|
86
|
+
mock_parser = MagicMock()
|
|
87
|
+
mock_args = MagicMock(command="test")
|
|
88
|
+
mock_parser.parse_args.return_value = mock_args
|
|
89
|
+
|
|
90
|
+
mock_create_parser.return_value = (mock_parser, {"test": mock_command})
|
|
91
|
+
|
|
92
|
+
result = main()
|
|
93
|
+
|
|
94
|
+
assert result == 2
|
|
95
|
+
|
|
96
|
+
@patch("cognee.cli._cognee._create_parser")
|
|
97
|
+
@patch("cognee.cli.debug.is_debug_enabled")
|
|
98
|
+
def test_main_with_generic_exception(self, mock_debug, mock_create_parser):
|
|
99
|
+
"""Test main function when command raises generic exception"""
|
|
100
|
+
mock_debug.return_value = False
|
|
101
|
+
|
|
102
|
+
mock_command = MagicMock()
|
|
103
|
+
mock_command.execute.side_effect = Exception("Generic error")
|
|
104
|
+
|
|
105
|
+
mock_parser = MagicMock()
|
|
106
|
+
mock_args = MagicMock(command="test")
|
|
107
|
+
mock_parser.parse_args.return_value = mock_args
|
|
108
|
+
|
|
109
|
+
mock_create_parser.return_value = (mock_parser, {"test": mock_command})
|
|
110
|
+
|
|
111
|
+
result = main()
|
|
112
|
+
|
|
113
|
+
assert result == -1
|
|
114
|
+
|
|
115
|
+
@patch("cognee.cli._cognee._create_parser")
|
|
116
|
+
@patch("cognee.cli.debug.is_debug_enabled")
|
|
117
|
+
def test_main_debug_mode_reraises_exception(self, mock_debug, mock_create_parser):
|
|
118
|
+
"""Test main function reraises exceptions in debug mode"""
|
|
119
|
+
mock_debug.return_value = True
|
|
120
|
+
|
|
121
|
+
test_exception = CliCommandException(
|
|
122
|
+
"Test error", error_code=2, raiseable_exception=ValueError("Inner error")
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
mock_command = MagicMock()
|
|
126
|
+
mock_command.execute.side_effect = test_exception
|
|
127
|
+
|
|
128
|
+
mock_parser = MagicMock()
|
|
129
|
+
mock_args = MagicMock(command="test")
|
|
130
|
+
mock_parser.parse_args.return_value = mock_args
|
|
131
|
+
|
|
132
|
+
mock_create_parser.return_value = (mock_parser, {"test": mock_command})
|
|
133
|
+
|
|
134
|
+
with pytest.raises(ValueError, match="Inner error"):
|
|
135
|
+
main()
|
|
136
|
+
|
|
137
|
+
def test_version_argument(self):
|
|
138
|
+
"""Test that version argument is properly configured"""
|
|
139
|
+
parser, _ = _create_parser()
|
|
140
|
+
|
|
141
|
+
# Check that version action exists
|
|
142
|
+
version_actions = [action for action in parser._actions if action.dest == "version"]
|
|
143
|
+
assert len(version_actions) == 1
|
|
144
|
+
|
|
145
|
+
version_action = version_actions[0]
|
|
146
|
+
assert "cognee" in version_action.version
|
|
147
|
+
|
|
148
|
+
def test_debug_argument(self):
|
|
149
|
+
"""Test that debug argument is properly configured"""
|
|
150
|
+
parser, _ = _create_parser()
|
|
151
|
+
|
|
152
|
+
# Check that debug action exists
|
|
153
|
+
debug_actions = [action for action in parser._actions if action.dest == "debug"]
|
|
154
|
+
assert len(debug_actions) == 1
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class TestDebugAction:
|
|
158
|
+
"""Test the DebugAction class"""
|
|
159
|
+
|
|
160
|
+
@patch("cognee.cli.debug.enable_debug")
|
|
161
|
+
@patch("cognee.cli.echo.note")
|
|
162
|
+
def test_debug_action_call(self, mock_note, mock_enable_debug):
|
|
163
|
+
"""Test that DebugAction enables debug mode"""
|
|
164
|
+
from cognee.cli._cognee import DebugAction
|
|
165
|
+
|
|
166
|
+
action = DebugAction([])
|
|
167
|
+
parser = MagicMock()
|
|
168
|
+
namespace = MagicMock()
|
|
169
|
+
|
|
170
|
+
action(parser, namespace, None)
|
|
171
|
+
|
|
172
|
+
mock_enable_debug.assert_called_once()
|
|
173
|
+
mock_note.assert_called_once_with("Debug mode enabled. Full stack traces will be shown.")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test runner and utilities for CLI tests.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run_cli_tests():
|
|
11
|
+
"""Run all CLI tests"""
|
|
12
|
+
test_dir = Path(__file__).parent
|
|
13
|
+
integration_dir = test_dir.parent.parent / "integration" / "cli"
|
|
14
|
+
|
|
15
|
+
cli_unit_test_files = [
|
|
16
|
+
"test_cli_main.py",
|
|
17
|
+
"test_cli_commands.py",
|
|
18
|
+
"test_cli_utils.py",
|
|
19
|
+
"test_cli_edge_cases.py",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
cli_integration_test_files = ["test_cli_integration.py"]
|
|
23
|
+
|
|
24
|
+
# Run tests with pytest
|
|
25
|
+
args = ["-v", "--tb=short"]
|
|
26
|
+
|
|
27
|
+
# Add unit tests
|
|
28
|
+
for test_file in cli_unit_test_files:
|
|
29
|
+
test_path = test_dir / test_file
|
|
30
|
+
if test_path.exists():
|
|
31
|
+
args.append(str(test_path))
|
|
32
|
+
|
|
33
|
+
# Add integration tests
|
|
34
|
+
for test_file in cli_integration_test_files:
|
|
35
|
+
test_path = integration_dir / test_file
|
|
36
|
+
if test_path.exists():
|
|
37
|
+
args.append(str(test_path))
|
|
38
|
+
|
|
39
|
+
return pytest.main(args)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run_specific_cli_test(test_file):
|
|
43
|
+
"""Run a specific CLI test file"""
|
|
44
|
+
test_dir = Path(__file__).parent
|
|
45
|
+
test_path = test_dir / test_file
|
|
46
|
+
|
|
47
|
+
if not test_path.exists():
|
|
48
|
+
print(f"Test file {test_file} not found")
|
|
49
|
+
return 1
|
|
50
|
+
|
|
51
|
+
return pytest.main(["-v", "--tb=short", str(test_path)])
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
if len(sys.argv) > 1:
|
|
56
|
+
# Run specific test file
|
|
57
|
+
exit_code = run_specific_cli_test(sys.argv[1])
|
|
58
|
+
else:
|
|
59
|
+
# Run all CLI tests
|
|
60
|
+
exit_code = run_cli_tests()
|
|
61
|
+
|
|
62
|
+
sys.exit(exit_code)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for CLI utility functions and helper modules.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from cognee.cli import debug
|
|
6
|
+
from cognee.cli.config import (
|
|
7
|
+
CLI_DESCRIPTION,
|
|
8
|
+
DEFAULT_DOCS_URL,
|
|
9
|
+
COMMAND_DESCRIPTIONS,
|
|
10
|
+
SEARCH_TYPE_CHOICES,
|
|
11
|
+
CHUNKER_CHOICES,
|
|
12
|
+
OUTPUT_FORMAT_CHOICES,
|
|
13
|
+
)
|
|
14
|
+
from cognee.cli._cognee import _discover_commands
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestCliConfig:
|
|
18
|
+
"""Test CLI configuration constants"""
|
|
19
|
+
|
|
20
|
+
def test_cli_description_exists(self):
|
|
21
|
+
"""Test that CLI description is defined"""
|
|
22
|
+
assert CLI_DESCRIPTION
|
|
23
|
+
assert isinstance(CLI_DESCRIPTION, str)
|
|
24
|
+
assert "cognee" in CLI_DESCRIPTION.lower()
|
|
25
|
+
|
|
26
|
+
def test_default_docs_url_exists(self):
|
|
27
|
+
"""Test that default docs URL is defined"""
|
|
28
|
+
assert DEFAULT_DOCS_URL
|
|
29
|
+
assert isinstance(DEFAULT_DOCS_URL, str)
|
|
30
|
+
assert DEFAULT_DOCS_URL.startswith("https://")
|
|
31
|
+
assert "cognee.ai" in DEFAULT_DOCS_URL
|
|
32
|
+
|
|
33
|
+
def test_command_descriptions_complete(self):
|
|
34
|
+
"""Test that all expected commands have descriptions"""
|
|
35
|
+
commands = _discover_commands()
|
|
36
|
+
assert len(commands) > 0
|
|
37
|
+
|
|
38
|
+
expected_commands = []
|
|
39
|
+
for command_class in commands:
|
|
40
|
+
command = command_class()
|
|
41
|
+
expected_commands.append(command.command_string)
|
|
42
|
+
|
|
43
|
+
for command in expected_commands:
|
|
44
|
+
assert command in COMMAND_DESCRIPTIONS
|
|
45
|
+
assert isinstance(COMMAND_DESCRIPTIONS[command], str)
|
|
46
|
+
assert len(COMMAND_DESCRIPTIONS[command]) > 0
|
|
47
|
+
|
|
48
|
+
def test_search_type_choices_valid(self):
|
|
49
|
+
"""Test that search type choices are valid"""
|
|
50
|
+
assert isinstance(SEARCH_TYPE_CHOICES, list)
|
|
51
|
+
assert len(SEARCH_TYPE_CHOICES) > 0
|
|
52
|
+
|
|
53
|
+
expected_types = [
|
|
54
|
+
"GRAPH_COMPLETION",
|
|
55
|
+
"RAG_COMPLETION",
|
|
56
|
+
"INSIGHTS",
|
|
57
|
+
"CHUNKS",
|
|
58
|
+
"SUMMARIES",
|
|
59
|
+
"CODE",
|
|
60
|
+
"CYPHER",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
for expected_type in expected_types:
|
|
64
|
+
assert expected_type in SEARCH_TYPE_CHOICES
|
|
65
|
+
|
|
66
|
+
def test_chunker_choices_valid(self):
|
|
67
|
+
"""Test that chunker choices are valid"""
|
|
68
|
+
assert isinstance(CHUNKER_CHOICES, list)
|
|
69
|
+
assert len(CHUNKER_CHOICES) > 0
|
|
70
|
+
assert "TextChunker" in CHUNKER_CHOICES
|
|
71
|
+
assert "LangchainChunker" in CHUNKER_CHOICES
|
|
72
|
+
|
|
73
|
+
def test_output_format_choices_valid(self):
|
|
74
|
+
"""Test that output format choices are valid"""
|
|
75
|
+
assert isinstance(OUTPUT_FORMAT_CHOICES, list)
|
|
76
|
+
assert len(OUTPUT_FORMAT_CHOICES) > 0
|
|
77
|
+
|
|
78
|
+
expected_formats = ["json", "pretty", "simple"]
|
|
79
|
+
for expected_format in expected_formats:
|
|
80
|
+
assert expected_format in OUTPUT_FORMAT_CHOICES
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TestCliReference:
|
|
84
|
+
"""Test CLI reference protocol"""
|
|
85
|
+
|
|
86
|
+
def test_supports_cli_command_protocol(self):
|
|
87
|
+
"""Test that SupportsCliCommand protocol is properly defined"""
|
|
88
|
+
from cognee.cli.reference import SupportsCliCommand
|
|
89
|
+
|
|
90
|
+
# Test that it's a protocol
|
|
91
|
+
assert hasattr(SupportsCliCommand, "__annotations__")
|
|
92
|
+
|
|
93
|
+
# Test required attributes
|
|
94
|
+
annotations = SupportsCliCommand.__annotations__
|
|
95
|
+
assert "command_string" in annotations
|
|
96
|
+
assert "help_string" in annotations
|
|
97
|
+
assert "description" in annotations
|
|
98
|
+
assert "docs_url" in annotations
|
|
99
|
+
|
|
100
|
+
def test_protocol_methods(self):
|
|
101
|
+
"""Test that protocol defines required methods"""
|
|
102
|
+
from cognee.cli.reference import SupportsCliCommand
|
|
103
|
+
import inspect
|
|
104
|
+
|
|
105
|
+
# Get abstract methods
|
|
106
|
+
abstract_methods = []
|
|
107
|
+
for name, method in inspect.getmembers(SupportsCliCommand, predicate=inspect.ismethod):
|
|
108
|
+
if getattr(method, "__isabstractmethod__", False):
|
|
109
|
+
abstract_methods.append(name)
|
|
110
|
+
|
|
111
|
+
# Should have abstract methods for configure_parser and execute
|
|
112
|
+
method_names = [name for name, _ in inspect.getmembers(SupportsCliCommand)]
|
|
113
|
+
assert "configure_parser" in method_names
|
|
114
|
+
assert "execute" in method_names
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class TestCliUtilityFunctions:
|
|
118
|
+
"""Test utility functions and edge cases"""
|
|
119
|
+
|
|
120
|
+
def test_multiple_debug_enable_calls(self):
|
|
121
|
+
"""Test multiple calls to enable_debug"""
|
|
122
|
+
debug.enable_debug()
|
|
123
|
+
debug.enable_debug() # Should not cause issues
|
|
124
|
+
assert debug.is_debug_enabled() is True
|
|
125
|
+
|
|
126
|
+
# Reset for other tests
|
|
127
|
+
debug._debug_enabled = False
|
|
@@ -51,7 +51,7 @@ class TestGraphCompletionWithContextExtensionRetriever:
|
|
|
51
51
|
|
|
52
52
|
retriever = GraphCompletionContextExtensionRetriever()
|
|
53
53
|
|
|
54
|
-
context = await retriever.get_context("Who works at Canva?")
|
|
54
|
+
context, _ = await retriever.get_context("Who works at Canva?")
|
|
55
55
|
|
|
56
56
|
assert "Mike Broski --[works_for]--> Canva" in context, "Failed to get Mike Broski"
|
|
57
57
|
assert "Christina Mayer --[works_for]--> Canva" in context, "Failed to get Christina Mayer"
|
|
@@ -129,7 +129,7 @@ class TestGraphCompletionWithContextExtensionRetriever:
|
|
|
129
129
|
|
|
130
130
|
retriever = GraphCompletionContextExtensionRetriever(top_k=20)
|
|
131
131
|
|
|
132
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
132
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
133
133
|
|
|
134
134
|
print(context)
|
|
135
135
|
|
|
@@ -167,7 +167,7 @@ class TestGraphCompletionWithContextExtensionRetriever:
|
|
|
167
167
|
|
|
168
168
|
await setup()
|
|
169
169
|
|
|
170
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
170
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
171
171
|
assert context == "", "Context should be empty on an empty graph"
|
|
172
172
|
|
|
173
173
|
answer = await retriever.get_completion("Who works at Figma?")
|
|
@@ -47,7 +47,7 @@ class TestGraphCompletionCoTRetriever:
|
|
|
47
47
|
|
|
48
48
|
retriever = GraphCompletionCotRetriever()
|
|
49
49
|
|
|
50
|
-
context = await retriever.get_context("Who works at Canva?")
|
|
50
|
+
context, _ = await retriever.get_context("Who works at Canva?")
|
|
51
51
|
|
|
52
52
|
assert "Mike Broski --[works_for]--> Canva" in context, "Failed to get Mike Broski"
|
|
53
53
|
assert "Christina Mayer --[works_for]--> Canva" in context, "Failed to get Christina Mayer"
|
|
@@ -124,7 +124,7 @@ class TestGraphCompletionCoTRetriever:
|
|
|
124
124
|
|
|
125
125
|
retriever = GraphCompletionCotRetriever(top_k=20)
|
|
126
126
|
|
|
127
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
127
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
128
128
|
|
|
129
129
|
print(context)
|
|
130
130
|
|
|
@@ -162,7 +162,7 @@ class TestGraphCompletionCoTRetriever:
|
|
|
162
162
|
|
|
163
163
|
await setup()
|
|
164
164
|
|
|
165
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
165
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
166
166
|
assert context == "", "Context should be empty on an empty graph"
|
|
167
167
|
|
|
168
168
|
answer = await retriever.get_completion("Who works at Figma?")
|
|
@@ -67,7 +67,7 @@ class TestGraphCompletionRetriever:
|
|
|
67
67
|
|
|
68
68
|
retriever = GraphCompletionRetriever()
|
|
69
69
|
|
|
70
|
-
context = await retriever.get_context("Who works at Canva?")
|
|
70
|
+
context, _ = await retriever.get_context("Who works at Canva?")
|
|
71
71
|
|
|
72
72
|
# Ensure the top-level sections are present
|
|
73
73
|
assert "Nodes:" in context, "Missing 'Nodes:' section in context"
|
|
@@ -191,7 +191,7 @@ class TestGraphCompletionRetriever:
|
|
|
191
191
|
|
|
192
192
|
retriever = GraphCompletionRetriever(top_k=20)
|
|
193
193
|
|
|
194
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
194
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
195
195
|
|
|
196
196
|
print(context)
|
|
197
197
|
|
|
@@ -222,5 +222,5 @@ class TestGraphCompletionRetriever:
|
|
|
222
222
|
|
|
223
223
|
await setup()
|
|
224
224
|
|
|
225
|
-
context = await retriever.get_context("Who works at Figma?")
|
|
225
|
+
context, _ = await retriever.get_context("Who works at Figma?")
|
|
226
226
|
assert context == "", "Context should be empty on an empty graph"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognee
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Cognee - is a library for enriching LLM context with a semantic layer for better understanding and reasoning.
|
|
5
5
|
Project-URL: Homepage, https://www.cognee.ai
|
|
6
6
|
Project-URL: Repository, https://github.com/topoteretes/cognee
|
|
@@ -31,13 +31,13 @@ Requires-Dist: kuzu==0.11.0
|
|
|
31
31
|
Requires-Dist: lancedb<1.0.0,>=0.24.0
|
|
32
32
|
Requires-Dist: langfuse<3,>=2.32.0
|
|
33
33
|
Requires-Dist: limits<5,>=4.4.1
|
|
34
|
-
Requires-Dist: litellm<
|
|
34
|
+
Requires-Dist: litellm<2.0.0,>=1.71.0
|
|
35
35
|
Requires-Dist: matplotlib<4,>=3.8.3
|
|
36
36
|
Requires-Dist: networkx<4,>=3.4.2
|
|
37
37
|
Requires-Dist: nltk<4.0.0,>=3.9.1
|
|
38
38
|
Requires-Dist: numpy<=4.0.0,>=1.26.4
|
|
39
39
|
Requires-Dist: onnxruntime<2.0.0,>=1.0.0
|
|
40
|
-
Requires-Dist: openai<
|
|
40
|
+
Requires-Dist: openai<1.99.9,>=1.80.1
|
|
41
41
|
Requires-Dist: pandas<3.0.0,>=2.2.2
|
|
42
42
|
Requires-Dist: pre-commit<5,>=4.0.1
|
|
43
43
|
Requires-Dist: pydantic-settings<3,>=2.2.1
|
|
@@ -46,6 +46,7 @@ Requires-Dist: pylance<1.0.0,>=0.22.0
|
|
|
46
46
|
Requires-Dist: pympler<2.0.0,>=1.1
|
|
47
47
|
Requires-Dist: pypdf<6.0.0,>=4.1.0
|
|
48
48
|
Requires-Dist: python-dotenv<2.0.0,>=1.0.1
|
|
49
|
+
Requires-Dist: python-magic-bin<0.5; platform_system == 'Windows'
|
|
49
50
|
Requires-Dist: python-multipart<1.0.0,>=0.0.20
|
|
50
51
|
Requires-Dist: rdflib<7.2.0,>=7.1.4
|
|
51
52
|
Requires-Dist: s3fs[boto3]==2025.3.2
|
|
@@ -74,7 +75,7 @@ Requires-Dist: tree-sitter<0.25,>=0.24.0; extra == 'codegraph'
|
|
|
74
75
|
Provides-Extra: debug
|
|
75
76
|
Requires-Dist: debugpy<2.0.0,>=1.8.9; extra == 'debug'
|
|
76
77
|
Provides-Extra: deepeval
|
|
77
|
-
Requires-Dist: deepeval<3
|
|
78
|
+
Requires-Dist: deepeval<4,>=3.0.1; extra == 'deepeval'
|
|
78
79
|
Provides-Extra: dev
|
|
79
80
|
Requires-Dist: coverage<8,>=7.3.2; extra == 'dev'
|
|
80
81
|
Requires-Dist: deptry<0.21,>=0.20.0; extra == 'dev'
|
|
@@ -230,7 +231,8 @@ Your contributions are at the core of making this a true open source project. An
|
|
|
230
231
|
|
|
231
232
|
## 📦 Installation
|
|
232
233
|
|
|
233
|
-
You can install Cognee using either **
|
|
234
|
+
You can install Cognee using either **pip**, **poetry**, **uv** or any other python package manager.
|
|
235
|
+
|
|
234
236
|
Cognee supports Python 3.10 to 3.13
|
|
235
237
|
|
|
236
238
|
### With pip
|