cognee 0.3.6__py3-none-any.whl → 0.3.7.dev1__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/api/health.py +2 -12
- cognee/api/v1/add/add.py +46 -6
- cognee/api/v1/add/routers/get_add_router.py +11 -2
- cognee/api/v1/cognify/cognify.py +29 -9
- cognee/api/v1/cognify/routers/get_cognify_router.py +2 -1
- cognee/api/v1/datasets/datasets.py +11 -0
- cognee/api/v1/datasets/routers/get_datasets_router.py +8 -0
- cognee/api/v1/delete/routers/get_delete_router.py +2 -0
- cognee/api/v1/memify/routers/get_memify_router.py +2 -1
- cognee/api/v1/permissions/routers/get_permissions_router.py +6 -0
- cognee/api/v1/responses/default_tools.py +0 -1
- cognee/api/v1/responses/dispatch_function.py +1 -1
- cognee/api/v1/responses/routers/default_tools.py +0 -1
- cognee/api/v1/search/routers/get_search_router.py +3 -3
- cognee/api/v1/search/search.py +11 -9
- cognee/api/v1/settings/routers/get_settings_router.py +7 -1
- cognee/api/v1/sync/routers/get_sync_router.py +3 -0
- cognee/api/v1/ui/ui.py +45 -16
- cognee/api/v1/update/routers/get_update_router.py +3 -1
- cognee/api/v1/update/update.py +3 -3
- cognee/api/v1/users/routers/get_visualize_router.py +2 -0
- cognee/cli/_cognee.py +61 -10
- cognee/cli/commands/add_command.py +3 -3
- cognee/cli/commands/cognify_command.py +3 -3
- cognee/cli/commands/config_command.py +9 -7
- cognee/cli/commands/delete_command.py +3 -3
- cognee/cli/commands/search_command.py +3 -7
- cognee/cli/config.py +0 -1
- cognee/context_global_variables.py +5 -0
- cognee/exceptions/exceptions.py +1 -1
- cognee/infrastructure/databases/cache/__init__.py +2 -0
- cognee/infrastructure/databases/cache/cache_db_interface.py +79 -0
- cognee/infrastructure/databases/cache/config.py +44 -0
- cognee/infrastructure/databases/cache/get_cache_engine.py +67 -0
- cognee/infrastructure/databases/cache/redis/RedisAdapter.py +243 -0
- cognee/infrastructure/databases/exceptions/__init__.py +1 -0
- cognee/infrastructure/databases/exceptions/exceptions.py +18 -2
- cognee/infrastructure/databases/graph/get_graph_engine.py +1 -1
- cognee/infrastructure/databases/graph/graph_db_interface.py +5 -0
- cognee/infrastructure/databases/graph/kuzu/adapter.py +76 -47
- cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +13 -3
- cognee/infrastructure/databases/graph/neo4j_driver/deadlock_retry.py +1 -1
- cognee/infrastructure/databases/graph/neptune_driver/neptune_utils.py +1 -1
- cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +1 -1
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +21 -3
- cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +17 -10
- cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +17 -4
- cognee/infrastructure/databases/vector/embeddings/config.py +2 -3
- cognee/infrastructure/databases/vector/exceptions/exceptions.py +1 -1
- cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +0 -1
- cognee/infrastructure/files/exceptions.py +1 -1
- cognee/infrastructure/files/storage/LocalFileStorage.py +9 -9
- cognee/infrastructure/files/storage/S3FileStorage.py +11 -11
- cognee/infrastructure/files/utils/guess_file_type.py +6 -0
- cognee/infrastructure/llm/prompts/feedback_reaction_prompt.txt +14 -0
- cognee/infrastructure/llm/prompts/feedback_report_prompt.txt +13 -0
- cognee/infrastructure/llm/prompts/feedback_user_context_prompt.txt +5 -0
- cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt +0 -5
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +19 -9
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +17 -5
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +17 -5
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +32 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/mistral/__init__.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/mistral/adapter.py +109 -0
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/ollama/adapter.py +33 -8
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +40 -18
- cognee/infrastructure/loaders/LoaderEngine.py +27 -7
- cognee/infrastructure/loaders/external/__init__.py +7 -0
- cognee/infrastructure/loaders/external/advanced_pdf_loader.py +2 -8
- cognee/infrastructure/loaders/external/beautiful_soup_loader.py +310 -0
- cognee/infrastructure/loaders/supported_loaders.py +7 -0
- cognee/modules/data/exceptions/exceptions.py +1 -1
- cognee/modules/data/methods/__init__.py +3 -0
- cognee/modules/data/methods/get_dataset_data.py +4 -1
- cognee/modules/data/methods/has_dataset_data.py +21 -0
- cognee/modules/engine/models/TableRow.py +0 -1
- cognee/modules/ingestion/save_data_to_file.py +9 -2
- cognee/modules/pipelines/exceptions/exceptions.py +1 -1
- cognee/modules/pipelines/operations/pipeline.py +12 -1
- cognee/modules/pipelines/operations/run_tasks.py +25 -197
- cognee/modules/pipelines/operations/run_tasks_base.py +7 -0
- cognee/modules/pipelines/operations/run_tasks_data_item.py +260 -0
- cognee/modules/pipelines/operations/run_tasks_distributed.py +121 -38
- cognee/modules/pipelines/operations/run_tasks_with_telemetry.py +9 -1
- cognee/modules/retrieval/EntityCompletionRetriever.py +48 -8
- cognee/modules/retrieval/base_graph_retriever.py +3 -1
- cognee/modules/retrieval/base_retriever.py +3 -1
- cognee/modules/retrieval/chunks_retriever.py +5 -1
- cognee/modules/retrieval/code_retriever.py +20 -2
- cognee/modules/retrieval/completion_retriever.py +50 -9
- cognee/modules/retrieval/cypher_search_retriever.py +11 -1
- cognee/modules/retrieval/graph_completion_context_extension_retriever.py +47 -8
- cognee/modules/retrieval/graph_completion_cot_retriever.py +152 -22
- cognee/modules/retrieval/graph_completion_retriever.py +54 -10
- cognee/modules/retrieval/lexical_retriever.py +20 -2
- cognee/modules/retrieval/natural_language_retriever.py +10 -1
- cognee/modules/retrieval/summaries_retriever.py +5 -1
- cognee/modules/retrieval/temporal_retriever.py +62 -10
- cognee/modules/retrieval/user_qa_feedback.py +3 -2
- cognee/modules/retrieval/utils/completion.py +30 -4
- cognee/modules/retrieval/utils/description_to_codepart_search.py +1 -1
- cognee/modules/retrieval/utils/session_cache.py +156 -0
- cognee/modules/search/methods/get_search_type_tools.py +0 -5
- cognee/modules/search/methods/no_access_control_search.py +12 -1
- cognee/modules/search/methods/search.py +51 -5
- cognee/modules/search/types/SearchType.py +0 -1
- cognee/modules/settings/get_settings.py +23 -0
- cognee/modules/users/methods/get_authenticated_user.py +3 -1
- cognee/modules/users/methods/get_default_user.py +1 -6
- cognee/modules/users/roles/methods/create_role.py +2 -2
- cognee/modules/users/tenants/methods/create_tenant.py +2 -2
- cognee/shared/exceptions/exceptions.py +1 -1
- cognee/shared/logging_utils.py +18 -11
- cognee/shared/utils.py +24 -2
- cognee/tasks/codingagents/coding_rule_associations.py +1 -2
- cognee/tasks/documents/exceptions/exceptions.py +1 -1
- cognee/tasks/feedback/__init__.py +13 -0
- cognee/tasks/feedback/create_enrichments.py +84 -0
- cognee/tasks/feedback/extract_feedback_interactions.py +230 -0
- cognee/tasks/feedback/generate_improved_answers.py +130 -0
- cognee/tasks/feedback/link_enrichments_to_feedback.py +67 -0
- cognee/tasks/feedback/models.py +26 -0
- cognee/tasks/graph/extract_graph_from_data.py +2 -0
- cognee/tasks/ingestion/data_item_to_text_file.py +3 -3
- cognee/tasks/ingestion/ingest_data.py +11 -5
- cognee/tasks/ingestion/save_data_item_to_storage.py +12 -1
- cognee/tasks/storage/add_data_points.py +3 -10
- cognee/tasks/storage/index_data_points.py +19 -14
- cognee/tasks/storage/index_graph_edges.py +25 -11
- cognee/tasks/web_scraper/__init__.py +34 -0
- cognee/tasks/web_scraper/config.py +26 -0
- cognee/tasks/web_scraper/default_url_crawler.py +446 -0
- cognee/tasks/web_scraper/models.py +46 -0
- cognee/tasks/web_scraper/types.py +4 -0
- cognee/tasks/web_scraper/utils.py +142 -0
- cognee/tasks/web_scraper/web_scraper_task.py +396 -0
- cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py +0 -1
- cognee/tests/integration/web_url_crawler/test_default_url_crawler.py +13 -0
- cognee/tests/integration/web_url_crawler/test_tavily_crawler.py +19 -0
- cognee/tests/integration/web_url_crawler/test_url_adding_e2e.py +344 -0
- cognee/tests/subprocesses/reader.py +25 -0
- cognee/tests/subprocesses/simple_cognify_1.py +31 -0
- cognee/tests/subprocesses/simple_cognify_2.py +31 -0
- cognee/tests/subprocesses/writer.py +32 -0
- cognee/tests/tasks/descriptive_metrics/metrics_test_utils.py +0 -2
- cognee/tests/tasks/descriptive_metrics/neo4j_metrics_test.py +8 -3
- cognee/tests/tasks/entity_extraction/entity_extraction_test.py +89 -0
- cognee/tests/tasks/web_scraping/web_scraping_test.py +172 -0
- cognee/tests/test_add_docling_document.py +56 -0
- cognee/tests/test_chromadb.py +7 -11
- cognee/tests/test_concurrent_subprocess_access.py +76 -0
- cognee/tests/test_conversation_history.py +240 -0
- cognee/tests/test_feedback_enrichment.py +174 -0
- cognee/tests/test_kuzu.py +27 -15
- cognee/tests/test_lancedb.py +7 -11
- cognee/tests/test_library.py +32 -2
- cognee/tests/test_neo4j.py +24 -16
- cognee/tests/test_neptune_analytics_vector.py +7 -11
- cognee/tests/test_permissions.py +9 -13
- cognee/tests/test_pgvector.py +4 -4
- cognee/tests/test_remote_kuzu.py +8 -11
- cognee/tests/test_s3_file_storage.py +1 -1
- cognee/tests/test_search_db.py +6 -8
- cognee/tests/unit/infrastructure/databases/cache/test_cache_config.py +89 -0
- cognee/tests/unit/modules/retrieval/conversation_history_test.py +154 -0
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +51 -0
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/METADATA +21 -6
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/RECORD +178 -139
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/entry_points.txt +1 -0
- distributed/Dockerfile +0 -3
- distributed/entrypoint.py +21 -9
- distributed/signal.py +5 -0
- distributed/workers/data_point_saving_worker.py +64 -34
- distributed/workers/graph_saving_worker.py +71 -47
- cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py +0 -1116
- cognee/modules/retrieval/insights_retriever.py +0 -133
- cognee/tests/test_memgraph.py +0 -109
- cognee/tests/unit/modules/retrieval/insights_retriever_test.py +0 -251
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/WHEEL +0 -0
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""
|
|
2
|
+
End-to-end integration test for feedback enrichment feature.
|
|
3
|
+
|
|
4
|
+
Tests the complete feedback enrichment pipeline:
|
|
5
|
+
1. Add data and cognify
|
|
6
|
+
2. Run search with save_interaction=True to create CogneeUserInteraction nodes
|
|
7
|
+
3. Submit feedback to create CogneeUserFeedback nodes
|
|
8
|
+
4. Run memify with feedback enrichment tasks to create FeedbackEnrichment nodes
|
|
9
|
+
5. Verify all nodes and edges are properly created and linked in the graph
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import pathlib
|
|
14
|
+
from collections import Counter
|
|
15
|
+
|
|
16
|
+
import cognee
|
|
17
|
+
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
18
|
+
from cognee.modules.pipelines.tasks.task import Task
|
|
19
|
+
from cognee.modules.search.types import SearchType
|
|
20
|
+
from cognee.shared.data_models import KnowledgeGraph
|
|
21
|
+
from cognee.shared.logging_utils import get_logger
|
|
22
|
+
from cognee.tasks.feedback.create_enrichments import create_enrichments
|
|
23
|
+
from cognee.tasks.feedback.extract_feedback_interactions import (
|
|
24
|
+
extract_feedback_interactions,
|
|
25
|
+
)
|
|
26
|
+
from cognee.tasks.feedback.generate_improved_answers import generate_improved_answers
|
|
27
|
+
from cognee.tasks.feedback.link_enrichments_to_feedback import (
|
|
28
|
+
link_enrichments_to_feedback,
|
|
29
|
+
)
|
|
30
|
+
from cognee.tasks.graph import extract_graph_from_data
|
|
31
|
+
from cognee.tasks.storage import add_data_points
|
|
32
|
+
|
|
33
|
+
logger = get_logger()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async def main():
|
|
37
|
+
data_directory_path = str(
|
|
38
|
+
pathlib.Path(
|
|
39
|
+
os.path.join(
|
|
40
|
+
pathlib.Path(__file__).parent,
|
|
41
|
+
".data_storage/test_feedback_enrichment",
|
|
42
|
+
)
|
|
43
|
+
).resolve()
|
|
44
|
+
)
|
|
45
|
+
cognee_directory_path = str(
|
|
46
|
+
pathlib.Path(
|
|
47
|
+
os.path.join(
|
|
48
|
+
pathlib.Path(__file__).parent,
|
|
49
|
+
".cognee_system/test_feedback_enrichment",
|
|
50
|
+
)
|
|
51
|
+
).resolve()
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
cognee.config.data_root_directory(data_directory_path)
|
|
55
|
+
cognee.config.system_root_directory(cognee_directory_path)
|
|
56
|
+
|
|
57
|
+
await cognee.prune.prune_data()
|
|
58
|
+
await cognee.prune.prune_system(metadata=True)
|
|
59
|
+
|
|
60
|
+
dataset_name = "feedback_enrichment_test"
|
|
61
|
+
|
|
62
|
+
await cognee.add("Cognee turns documents into AI memory.", dataset_name)
|
|
63
|
+
await cognee.cognify([dataset_name])
|
|
64
|
+
|
|
65
|
+
question_text = "Say something."
|
|
66
|
+
result = await cognee.search(
|
|
67
|
+
query_type=SearchType.GRAPH_COMPLETION,
|
|
68
|
+
query_text=question_text,
|
|
69
|
+
save_interaction=True,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
assert len(result) > 0, "Search should return non-empty results"
|
|
73
|
+
|
|
74
|
+
feedback_text = "This answer was completely useless, my feedback is definitely negative."
|
|
75
|
+
await cognee.search(
|
|
76
|
+
query_type=SearchType.FEEDBACK,
|
|
77
|
+
query_text=feedback_text,
|
|
78
|
+
last_k=1,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
graph_engine = await get_graph_engine()
|
|
82
|
+
nodes_before, edges_before = await graph_engine.get_graph_data()
|
|
83
|
+
|
|
84
|
+
interaction_nodes_before = [
|
|
85
|
+
(node_id, props)
|
|
86
|
+
for node_id, props in nodes_before
|
|
87
|
+
if props.get("type") == "CogneeUserInteraction"
|
|
88
|
+
]
|
|
89
|
+
feedback_nodes_before = [
|
|
90
|
+
(node_id, props)
|
|
91
|
+
for node_id, props in nodes_before
|
|
92
|
+
if props.get("type") == "CogneeUserFeedback"
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
edge_types_before = Counter(edge[2] for edge in edges_before)
|
|
96
|
+
|
|
97
|
+
assert len(interaction_nodes_before) >= 1, (
|
|
98
|
+
f"Expected at least 1 CogneeUserInteraction node, found {len(interaction_nodes_before)}"
|
|
99
|
+
)
|
|
100
|
+
assert len(feedback_nodes_before) >= 1, (
|
|
101
|
+
f"Expected at least 1 CogneeUserFeedback node, found {len(feedback_nodes_before)}"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
for node_id, props in feedback_nodes_before:
|
|
105
|
+
sentiment = props.get("sentiment", "")
|
|
106
|
+
score = props.get("score", 0)
|
|
107
|
+
feedback_text = props.get("feedback", "")
|
|
108
|
+
logger.info(
|
|
109
|
+
"Feedback node created",
|
|
110
|
+
feedback=feedback_text,
|
|
111
|
+
sentiment=sentiment,
|
|
112
|
+
score=score,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
assert edge_types_before.get("gives_feedback_to", 0) >= 1, (
|
|
116
|
+
f"Expected at least 1 'gives_feedback_to' edge, found {edge_types_before.get('gives_feedback_to', 0)}"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
extraction_tasks = [Task(extract_feedback_interactions, last_n=5)]
|
|
120
|
+
enrichment_tasks = [
|
|
121
|
+
Task(generate_improved_answers, top_k=20),
|
|
122
|
+
Task(create_enrichments),
|
|
123
|
+
Task(
|
|
124
|
+
extract_graph_from_data,
|
|
125
|
+
graph_model=KnowledgeGraph,
|
|
126
|
+
task_config={"batch_size": 10},
|
|
127
|
+
),
|
|
128
|
+
Task(add_data_points, task_config={"batch_size": 10}),
|
|
129
|
+
Task(link_enrichments_to_feedback),
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
await cognee.memify(
|
|
133
|
+
extraction_tasks=extraction_tasks,
|
|
134
|
+
enrichment_tasks=enrichment_tasks,
|
|
135
|
+
data=[{}],
|
|
136
|
+
dataset="feedback_enrichment_test_memify",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
nodes_after, edges_after = await graph_engine.get_graph_data()
|
|
140
|
+
|
|
141
|
+
enrichment_nodes = [
|
|
142
|
+
(node_id, props)
|
|
143
|
+
for node_id, props in nodes_after
|
|
144
|
+
if props.get("type") == "FeedbackEnrichment"
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
assert len(enrichment_nodes) >= 1, (
|
|
148
|
+
f"Expected at least 1 FeedbackEnrichment node, found {len(enrichment_nodes)}"
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
for node_id, props in enrichment_nodes:
|
|
152
|
+
assert "text" in props, f"FeedbackEnrichment node {node_id} missing 'text' property"
|
|
153
|
+
|
|
154
|
+
enrichment_node_ids = {node_id for node_id, _ in enrichment_nodes}
|
|
155
|
+
edges_with_enrichments = [
|
|
156
|
+
edge
|
|
157
|
+
for edge in edges_after
|
|
158
|
+
if edge[0] in enrichment_node_ids or edge[1] in enrichment_node_ids
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
assert len(edges_with_enrichments) >= 1, (
|
|
162
|
+
f"Expected enrichment nodes to have at least 1 edge, found {len(edges_with_enrichments)}"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
await cognee.prune.prune_data()
|
|
166
|
+
await cognee.prune.prune_system(metadata=True)
|
|
167
|
+
|
|
168
|
+
logger.info("All feedback enrichment tests passed successfully")
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
import asyncio
|
|
173
|
+
|
|
174
|
+
asyncio.run(main())
|
cognee/tests/test_kuzu.py
CHANGED
|
@@ -38,22 +38,35 @@ async def main():
|
|
|
38
38
|
|
|
39
39
|
dataset_name = "cs_explanations"
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
explanation_file_path_nlp = os.path.join(
|
|
42
42
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
43
43
|
)
|
|
44
|
-
await cognee.add([
|
|
44
|
+
await cognee.add([explanation_file_path_nlp], dataset_name)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
explanation_file_path_quantum = os.path.join(
|
|
47
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
51
|
+
|
|
52
|
+
graph_engine = await get_graph_engine()
|
|
53
|
+
|
|
54
|
+
is_empty = await graph_engine.is_empty()
|
|
55
|
+
|
|
56
|
+
assert is_empty, "Kuzu graph database is not empty"
|
|
57
|
+
|
|
58
|
+
await cognee.add([explanation_file_path_quantum], dataset_name)
|
|
59
|
+
|
|
60
|
+
is_empty = await graph_engine.is_empty()
|
|
61
|
+
|
|
62
|
+
assert is_empty, "Kuzu graph database should be empty before cognify"
|
|
54
63
|
|
|
55
64
|
await cognee.cognify([dataset_name])
|
|
56
65
|
|
|
66
|
+
is_empty = await graph_engine.is_empty()
|
|
67
|
+
|
|
68
|
+
assert not is_empty, "Kuzu graph database should not be empty"
|
|
69
|
+
|
|
57
70
|
from cognee.infrastructure.databases.vector import get_vector_engine
|
|
58
71
|
|
|
59
72
|
vector_engine = get_vector_engine()
|
|
@@ -61,7 +74,7 @@ async def main():
|
|
|
61
74
|
random_node_name = random_node.payload["text"]
|
|
62
75
|
|
|
63
76
|
search_results = await cognee.search(
|
|
64
|
-
query_type=SearchType.
|
|
77
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
65
78
|
)
|
|
66
79
|
assert len(search_results) != 0, "The search results list is empty."
|
|
67
80
|
print("\n\nExtracted sentences are:\n")
|
|
@@ -117,11 +130,10 @@ async def main():
|
|
|
117
130
|
assert not os.path.isdir(data_root_directory), "Local data files are not deleted"
|
|
118
131
|
|
|
119
132
|
await cognee.prune.prune_system(metadata=True)
|
|
120
|
-
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
assert
|
|
134
|
+
is_empty = await graph_engine.is_empty()
|
|
135
|
+
|
|
136
|
+
assert is_empty, "Kuzu graph database is not empty"
|
|
125
137
|
|
|
126
138
|
finally:
|
|
127
139
|
# Ensure cleanup even if tests fail
|
cognee/tests/test_lancedb.py
CHANGED
|
@@ -131,20 +131,16 @@ async def main():
|
|
|
131
131
|
dataset_name_1 = "natural_language"
|
|
132
132
|
dataset_name_2 = "quantum"
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
explanation_file_path_nlp = os.path.join(
|
|
135
135
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
136
136
|
)
|
|
137
|
-
await cognee.add([
|
|
137
|
+
await cognee.add([explanation_file_path_nlp], dataset_name_1)
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two "basis" states. When measuring a qubit, the result is a probabilistic output of a classical bit, therefore making quantum computers nondeterministic in general. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently and quickly.
|
|
143
|
-
Physically engineering high-quality qubits has proven challenging. If a physical qubit is not sufficiently isolated from its environment, it suffers from quantum decoherence, introducing noise into calculations. Paradoxically, perfectly isolating qubits is also undesirable because quantum computations typically need to initialize qubits, perform controlled qubit interactions, and measure the resulting quantum states. Each of those operations introduces errors and suffers from noise, and such inaccuracies accumulate.
|
|
144
|
-
In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.
|
|
145
|
-
"""
|
|
139
|
+
explanation_file_path_quantum = os.path.join(
|
|
140
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
141
|
+
)
|
|
146
142
|
|
|
147
|
-
await cognee.add([
|
|
143
|
+
await cognee.add([explanation_file_path_quantum], dataset_name_2)
|
|
148
144
|
|
|
149
145
|
await cognee.cognify([dataset_name_2, dataset_name_1])
|
|
150
146
|
|
|
@@ -157,7 +153,7 @@ async def main():
|
|
|
157
153
|
random_node_name = random_node.payload["text"]
|
|
158
154
|
|
|
159
155
|
search_results = await cognee.search(
|
|
160
|
-
query_type=SearchType.
|
|
156
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
161
157
|
)
|
|
162
158
|
assert len(search_results) != 0, "The search results list is empty."
|
|
163
159
|
print("\n\nExtracted sentences are:\n")
|
cognee/tests/test_library.py
CHANGED
|
@@ -6,6 +6,7 @@ from cognee.modules.search.operations import get_history
|
|
|
6
6
|
from cognee.modules.users.methods import get_default_user
|
|
7
7
|
from cognee.shared.logging_utils import get_logger
|
|
8
8
|
from cognee.modules.search.types import SearchType
|
|
9
|
+
from cognee import update
|
|
9
10
|
|
|
10
11
|
logger = get_logger()
|
|
11
12
|
|
|
@@ -42,7 +43,7 @@ async def main():
|
|
|
42
43
|
|
|
43
44
|
await cognee.add([text], dataset_name)
|
|
44
45
|
|
|
45
|
-
await cognee.cognify([dataset_name])
|
|
46
|
+
cognify_run_info = await cognee.cognify([dataset_name])
|
|
46
47
|
|
|
47
48
|
from cognee.infrastructure.databases.vector import get_vector_engine
|
|
48
49
|
|
|
@@ -51,7 +52,7 @@ async def main():
|
|
|
51
52
|
random_node_name = random_node.payload["text"]
|
|
52
53
|
|
|
53
54
|
search_results = await cognee.search(
|
|
54
|
-
query_type=SearchType.
|
|
55
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
55
56
|
)
|
|
56
57
|
assert len(search_results) != 0, "The search results list is empty."
|
|
57
58
|
print("\n\nExtracted sentences are:\n")
|
|
@@ -77,6 +78,35 @@ async def main():
|
|
|
77
78
|
|
|
78
79
|
assert len(history) == 6, "Search history is not correct."
|
|
79
80
|
|
|
81
|
+
# Test updating of documents
|
|
82
|
+
# Get Pipeline Run object
|
|
83
|
+
pipeline_run_obj = list(cognify_run_info.values())[0]
|
|
84
|
+
for data_item in pipeline_run_obj.data_ingestion_info:
|
|
85
|
+
# Update all documents in dataset to only contain Mark and Cindy information
|
|
86
|
+
await update(
|
|
87
|
+
dataset_id=pipeline_run_obj.dataset_id,
|
|
88
|
+
data_id=data_item["data_id"],
|
|
89
|
+
data="Mark met with Cindy at a cafe.",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
search_results = await cognee.search(
|
|
93
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text="What information do you contain?"
|
|
94
|
+
)
|
|
95
|
+
assert "Mark" in search_results[0], (
|
|
96
|
+
"Failed to update document, no mention of Mark in search results"
|
|
97
|
+
)
|
|
98
|
+
assert "Cindy" in search_results[0], (
|
|
99
|
+
"Failed to update document, no mention of Cindy in search results"
|
|
100
|
+
)
|
|
101
|
+
assert "Artificial intelligence" not in search_results[0], (
|
|
102
|
+
"Failed to update document, Artificial intelligence still mentioned in search results"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Test visualization
|
|
106
|
+
from cognee import visualize_graph
|
|
107
|
+
|
|
108
|
+
await visualize_graph()
|
|
109
|
+
|
|
80
110
|
# Assert local data files are cleaned properly
|
|
81
111
|
await cognee.prune.prune_data()
|
|
82
112
|
data_root_directory = get_storage_config()["data_root_directory"]
|
cognee/tests/test_neo4j.py
CHANGED
|
@@ -32,23 +32,34 @@ async def main():
|
|
|
32
32
|
|
|
33
33
|
dataset_name = "cs_explanations"
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
explanation_file_path_nlp = os.path.join(
|
|
36
36
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
37
37
|
)
|
|
38
|
-
|
|
38
|
+
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
39
|
+
|
|
40
|
+
graph_engine = await get_graph_engine()
|
|
41
|
+
|
|
42
|
+
is_empty = await graph_engine.is_empty()
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
assert is_empty, "Graph has to be empty"
|
|
45
|
+
|
|
46
|
+
await cognee.add([explanation_file_path_nlp], dataset_name)
|
|
47
|
+
|
|
48
|
+
explanation_file_path_quantum = os.path.join(
|
|
49
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
50
|
+
)
|
|
47
51
|
|
|
48
|
-
await cognee.add([
|
|
52
|
+
await cognee.add([explanation_file_path_quantum], dataset_name)
|
|
53
|
+
is_empty = await graph_engine.is_empty()
|
|
54
|
+
|
|
55
|
+
assert is_empty, "Graph has to be empty before cognify"
|
|
49
56
|
|
|
50
57
|
await cognee.cognify([dataset_name])
|
|
51
58
|
|
|
59
|
+
is_empty = await graph_engine.is_empty()
|
|
60
|
+
|
|
61
|
+
assert not is_empty, "Graph shouldn't be empty"
|
|
62
|
+
|
|
52
63
|
from cognee.infrastructure.databases.vector import get_vector_engine
|
|
53
64
|
|
|
54
65
|
vector_engine = get_vector_engine()
|
|
@@ -56,7 +67,7 @@ async def main():
|
|
|
56
67
|
random_node_name = random_node.payload["text"]
|
|
57
68
|
|
|
58
69
|
search_results = await cognee.search(
|
|
59
|
-
query_type=SearchType.
|
|
70
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
60
71
|
)
|
|
61
72
|
assert len(search_results) != 0, "The search results list is empty."
|
|
62
73
|
print("\n\nExtracted sentences are:\n")
|
|
@@ -121,11 +132,8 @@ async def main():
|
|
|
121
132
|
assert not os.path.isdir(data_root_directory), "Local data files are not deleted"
|
|
122
133
|
|
|
123
134
|
await cognee.prune.prune_system(metadata=True)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
graph_engine = await get_graph_engine()
|
|
127
|
-
nodes, edges = await graph_engine.get_graph_data()
|
|
128
|
-
assert len(nodes) == 0 and len(edges) == 0, "Neo4j graph database is not empty"
|
|
135
|
+
is_empty = await graph_engine.is_empty()
|
|
136
|
+
assert is_empty, "Neo4j graph database is not empty"
|
|
129
137
|
|
|
130
138
|
|
|
131
139
|
if __name__ == "__main__":
|
|
@@ -38,20 +38,16 @@ async def main():
|
|
|
38
38
|
|
|
39
39
|
dataset_name = "cs_explanations"
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
explanation_file_path_nlp = os.path.join(
|
|
42
42
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
43
43
|
)
|
|
44
|
-
await cognee.add([
|
|
44
|
+
await cognee.add([explanation_file_path_nlp], dataset_name)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two "basis" states. When measuring a qubit, the result is a probabilistic output of a classical bit, therefore making quantum computers nondeterministic in general. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently and quickly.
|
|
50
|
-
Physically engineering high-quality qubits has proven challenging. If a physical qubit is not sufficiently isolated from its environment, it suffers from quantum decoherence, introducing noise into calculations. Paradoxically, perfectly isolating qubits is also undesirable because quantum computations typically need to initialize qubits, perform controlled qubit interactions, and measure the resulting quantum states. Each of those operations introduces errors and suffers from noise, and such inaccuracies accumulate.
|
|
51
|
-
In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.
|
|
52
|
-
"""
|
|
46
|
+
explanation_file_path_quantum = os.path.join(
|
|
47
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
48
|
+
)
|
|
53
49
|
|
|
54
|
-
await cognee.add([
|
|
50
|
+
await cognee.add([explanation_file_path_quantum], dataset_name)
|
|
55
51
|
|
|
56
52
|
await cognee.cognify([dataset_name])
|
|
57
53
|
|
|
@@ -60,7 +56,7 @@ async def main():
|
|
|
60
56
|
random_node_name = random_node.payload["text"]
|
|
61
57
|
|
|
62
58
|
search_results = await cognee.search(
|
|
63
|
-
query_type=SearchType.
|
|
59
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
64
60
|
)
|
|
65
61
|
assert len(search_results) != 0, "The search results list is empty."
|
|
66
62
|
print("\n\nExtracted sentences are:\n")
|
cognee/tests/test_permissions.py
CHANGED
|
@@ -34,25 +34,21 @@ async def main():
|
|
|
34
34
|
await cognee.prune.prune_data()
|
|
35
35
|
await cognee.prune.prune_system(metadata=True)
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
explanation_file_path_nlp = os.path.join(
|
|
38
38
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
39
39
|
)
|
|
40
40
|
|
|
41
41
|
# Add document for default user
|
|
42
|
-
await cognee.add([
|
|
42
|
+
await cognee.add([explanation_file_path_nlp], dataset_name="NLP")
|
|
43
43
|
default_user = await get_default_user()
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two "basis" states. When measuring a qubit, the result is a probabilistic output of a classical bit, therefore making quantum computers nondeterministic in general. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently and quickly.
|
|
49
|
-
Physically engineering high-quality qubits has proven challenging. If a physical qubit is not sufficiently isolated from its environment, it suffers from quantum decoherence, introducing noise into calculations. Paradoxically, perfectly isolating qubits is also undesirable because quantum computations typically need to initialize qubits, perform controlled qubit interactions, and measure the resulting quantum states. Each of those operations introduces errors and suffers from noise, and such inaccuracies accumulate.
|
|
50
|
-
In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.
|
|
51
|
-
"""
|
|
45
|
+
explanation_file_path_quantum = os.path.join(
|
|
46
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
47
|
+
)
|
|
52
48
|
|
|
53
49
|
# Add document for test user
|
|
54
50
|
test_user = await create_user("user@example.com", "example")
|
|
55
|
-
await cognee.add([
|
|
51
|
+
await cognee.add([explanation_file_path_quantum], dataset_name="QUANTUM", user=test_user)
|
|
56
52
|
|
|
57
53
|
nlp_cognify_result = await cognee.cognify(["NLP"], user=default_user)
|
|
58
54
|
quantum_cognify_result = await cognee.cognify(["QUANTUM"], user=test_user)
|
|
@@ -101,7 +97,7 @@ async def main():
|
|
|
101
97
|
add_error = False
|
|
102
98
|
try:
|
|
103
99
|
await cognee.add(
|
|
104
|
-
[
|
|
100
|
+
[explanation_file_path_nlp],
|
|
105
101
|
dataset_name="QUANTUM",
|
|
106
102
|
dataset_id=test_user_dataset_id,
|
|
107
103
|
user=default_user,
|
|
@@ -143,7 +139,7 @@ async def main():
|
|
|
143
139
|
|
|
144
140
|
# Add new data to test_users dataset from default_user
|
|
145
141
|
await cognee.add(
|
|
146
|
-
[
|
|
142
|
+
[explanation_file_path_nlp],
|
|
147
143
|
dataset_name="QUANTUM",
|
|
148
144
|
dataset_id=test_user_dataset_id,
|
|
149
145
|
user=default_user,
|
|
@@ -216,7 +212,7 @@ async def main():
|
|
|
216
212
|
)
|
|
217
213
|
|
|
218
214
|
# Try deleting data from test_user dataset with default_user after getting delete permission
|
|
219
|
-
# Get the dataset data to find the ID of the remaining data item (
|
|
215
|
+
# Get the dataset data to find the ID of the remaining data item (explanation_file_path_nlp)
|
|
220
216
|
test_user_dataset_data = await get_dataset_data(test_user_dataset_id)
|
|
221
217
|
explanation_file_data_id = test_user_dataset_data[0].id
|
|
222
218
|
|
cognee/tests/test_pgvector.py
CHANGED
|
@@ -141,10 +141,10 @@ async def main():
|
|
|
141
141
|
dataset_name_1 = "natural_language"
|
|
142
142
|
dataset_name_2 = "quantum"
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
explanation_file_path_nlp = os.path.join(
|
|
145
145
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
146
146
|
)
|
|
147
|
-
await cognee.add([
|
|
147
|
+
await cognee.add([explanation_file_path_nlp], dataset_name_1)
|
|
148
148
|
|
|
149
149
|
text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
|
|
150
150
|
At small scales, physical matter exhibits properties of both particles and waves, and quantum computing leverages this behavior, specifically quantum superposition and entanglement, using specialized hardware that supports the preparation and manipulation of quantum states.
|
|
@@ -167,7 +167,7 @@ async def main():
|
|
|
167
167
|
random_node_name = random_node.payload["text"]
|
|
168
168
|
|
|
169
169
|
search_results = await cognee.search(
|
|
170
|
-
query_type=SearchType.
|
|
170
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
171
171
|
)
|
|
172
172
|
assert len(search_results) != 0, "The search results list is empty."
|
|
173
173
|
print("\n\nExtracted sentences are:\n")
|
|
@@ -202,7 +202,7 @@ async def main():
|
|
|
202
202
|
history = await get_history(user.id)
|
|
203
203
|
assert len(history) == 8, "Search history is not correct."
|
|
204
204
|
|
|
205
|
-
await test_local_file_deletion(text,
|
|
205
|
+
await test_local_file_deletion(text, explanation_file_path_nlp)
|
|
206
206
|
|
|
207
207
|
await cognee.prune.prune_data()
|
|
208
208
|
data_root_directory = get_storage_config()["data_root_directory"]
|
cognee/tests/test_remote_kuzu.py
CHANGED
|
@@ -42,19 +42,16 @@ async def main():
|
|
|
42
42
|
|
|
43
43
|
dataset_name = "cs_explanations"
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
explanation_file_path_nlp = os.path.join(
|
|
46
46
|
pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
|
|
47
47
|
)
|
|
48
|
-
await cognee.add([
|
|
48
|
+
await cognee.add([explanation_file_path_nlp], dataset_name)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.
|
|
56
|
-
"""
|
|
57
|
-
await cognee.add([text], dataset_name)
|
|
50
|
+
explanation_file_path_quantum = os.path.join(
|
|
51
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
await cognee.add([explanation_file_path_quantum], dataset_name)
|
|
58
55
|
|
|
59
56
|
await cognee.cognify([dataset_name])
|
|
60
57
|
|
|
@@ -65,7 +62,7 @@ async def main():
|
|
|
65
62
|
random_node_name = random_node.payload["text"]
|
|
66
63
|
|
|
67
64
|
search_results = await cognee.search(
|
|
68
|
-
query_type=SearchType.
|
|
65
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
69
66
|
)
|
|
70
67
|
assert len(search_results) != 0, "The search results list is empty."
|
|
71
68
|
print("\n\nExtracted sentences are:\n")
|
|
@@ -47,7 +47,7 @@ async def main():
|
|
|
47
47
|
random_node_name = random_node.payload["text"]
|
|
48
48
|
|
|
49
49
|
search_results = await cognee.search(
|
|
50
|
-
query_type=SearchType.
|
|
50
|
+
query_type=SearchType.GRAPH_COMPLETION, query_text=random_node_name
|
|
51
51
|
)
|
|
52
52
|
assert len(search_results) != 0, "The search results list is empty."
|
|
53
53
|
print("\n\nExtracted sentences are:\n")
|
cognee/tests/test_search_db.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
1
3
|
import cognee
|
|
2
4
|
from cognee.infrastructure.databases.graph import get_graph_engine
|
|
3
5
|
from cognee.modules.graph.cognee_graph.CogneeGraphElements import Edge
|
|
@@ -27,15 +29,11 @@ async def main():
|
|
|
27
29
|
text_1 = """Germany is located in europe right next to the Netherlands"""
|
|
28
30
|
await cognee.add(text_1, dataset_name)
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two "basis" states. When measuring a qubit, the result is a probabilistic output of a classical bit, therefore making quantum computers nondeterministic in general. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently and quickly.
|
|
34
|
-
Physically engineering high-quality qubits has proven challenging. If a physical qubit is not sufficiently isolated from its environment, it suffers from quantum decoherence, introducing noise into calculations. Paradoxically, perfectly isolating qubits is also undesirable because quantum computations typically need to initialize qubits, perform controlled qubit interactions, and measure the resulting quantum states. Each of those operations introduces errors and suffers from noise, and such inaccuracies accumulate.
|
|
35
|
-
In principle, a non-quantum (classical) computer can solve the same computational problems as a quantum computer, given enough time. Quantum advantage comes in the form of time complexity rather than computability, and quantum complexity theory shows that some quantum algorithms for carefully selected tasks require exponentially fewer computational steps than the best known non-quantum algorithms. Such tasks can in theory be solved on a large-scale quantum computer whereas classical computers would not finish computations in any reasonable amount of time. However, quantum speedup is not universal or even typical across computational tasks, since basic tasks such as sorting are proven to not allow any asymptotic quantum speedup. Claims of quantum supremacy have drawn significant attention to the discipline, but are demonstrated on contrived tasks, while near-term practical use cases remain limited.
|
|
36
|
-
"""
|
|
32
|
+
explanation_file_path_quantum = os.path.join(
|
|
33
|
+
pathlib.Path(__file__).parent, "test_data/Quantum_computers.txt"
|
|
34
|
+
)
|
|
37
35
|
|
|
38
|
-
await cognee.add([
|
|
36
|
+
await cognee.add([explanation_file_path_quantum], dataset_name)
|
|
39
37
|
|
|
40
38
|
await cognee.cognify([dataset_name])
|
|
41
39
|
|