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.
Files changed (182) hide show
  1. cognee/__init__.py +1 -0
  2. cognee/api/health.py +2 -12
  3. cognee/api/v1/add/add.py +46 -6
  4. cognee/api/v1/add/routers/get_add_router.py +11 -2
  5. cognee/api/v1/cognify/cognify.py +29 -9
  6. cognee/api/v1/cognify/routers/get_cognify_router.py +2 -1
  7. cognee/api/v1/datasets/datasets.py +11 -0
  8. cognee/api/v1/datasets/routers/get_datasets_router.py +8 -0
  9. cognee/api/v1/delete/routers/get_delete_router.py +2 -0
  10. cognee/api/v1/memify/routers/get_memify_router.py +2 -1
  11. cognee/api/v1/permissions/routers/get_permissions_router.py +6 -0
  12. cognee/api/v1/responses/default_tools.py +0 -1
  13. cognee/api/v1/responses/dispatch_function.py +1 -1
  14. cognee/api/v1/responses/routers/default_tools.py +0 -1
  15. cognee/api/v1/search/routers/get_search_router.py +3 -3
  16. cognee/api/v1/search/search.py +11 -9
  17. cognee/api/v1/settings/routers/get_settings_router.py +7 -1
  18. cognee/api/v1/sync/routers/get_sync_router.py +3 -0
  19. cognee/api/v1/ui/ui.py +45 -16
  20. cognee/api/v1/update/routers/get_update_router.py +3 -1
  21. cognee/api/v1/update/update.py +3 -3
  22. cognee/api/v1/users/routers/get_visualize_router.py +2 -0
  23. cognee/cli/_cognee.py +61 -10
  24. cognee/cli/commands/add_command.py +3 -3
  25. cognee/cli/commands/cognify_command.py +3 -3
  26. cognee/cli/commands/config_command.py +9 -7
  27. cognee/cli/commands/delete_command.py +3 -3
  28. cognee/cli/commands/search_command.py +3 -7
  29. cognee/cli/config.py +0 -1
  30. cognee/context_global_variables.py +5 -0
  31. cognee/exceptions/exceptions.py +1 -1
  32. cognee/infrastructure/databases/cache/__init__.py +2 -0
  33. cognee/infrastructure/databases/cache/cache_db_interface.py +79 -0
  34. cognee/infrastructure/databases/cache/config.py +44 -0
  35. cognee/infrastructure/databases/cache/get_cache_engine.py +67 -0
  36. cognee/infrastructure/databases/cache/redis/RedisAdapter.py +243 -0
  37. cognee/infrastructure/databases/exceptions/__init__.py +1 -0
  38. cognee/infrastructure/databases/exceptions/exceptions.py +18 -2
  39. cognee/infrastructure/databases/graph/get_graph_engine.py +1 -1
  40. cognee/infrastructure/databases/graph/graph_db_interface.py +5 -0
  41. cognee/infrastructure/databases/graph/kuzu/adapter.py +76 -47
  42. cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +13 -3
  43. cognee/infrastructure/databases/graph/neo4j_driver/deadlock_retry.py +1 -1
  44. cognee/infrastructure/databases/graph/neptune_driver/neptune_utils.py +1 -1
  45. cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +1 -1
  46. cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +21 -3
  47. cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +17 -10
  48. cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +17 -4
  49. cognee/infrastructure/databases/vector/embeddings/config.py +2 -3
  50. cognee/infrastructure/databases/vector/exceptions/exceptions.py +1 -1
  51. cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +0 -1
  52. cognee/infrastructure/files/exceptions.py +1 -1
  53. cognee/infrastructure/files/storage/LocalFileStorage.py +9 -9
  54. cognee/infrastructure/files/storage/S3FileStorage.py +11 -11
  55. cognee/infrastructure/files/utils/guess_file_type.py +6 -0
  56. cognee/infrastructure/llm/prompts/feedback_reaction_prompt.txt +14 -0
  57. cognee/infrastructure/llm/prompts/feedback_report_prompt.txt +13 -0
  58. cognee/infrastructure/llm/prompts/feedback_user_context_prompt.txt +5 -0
  59. cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt +0 -5
  60. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +19 -9
  61. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +17 -5
  62. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +17 -5
  63. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +32 -0
  64. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/mistral/__init__.py +0 -0
  65. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/mistral/adapter.py +109 -0
  66. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/ollama/adapter.py +33 -8
  67. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +40 -18
  68. cognee/infrastructure/loaders/LoaderEngine.py +27 -7
  69. cognee/infrastructure/loaders/external/__init__.py +7 -0
  70. cognee/infrastructure/loaders/external/advanced_pdf_loader.py +2 -8
  71. cognee/infrastructure/loaders/external/beautiful_soup_loader.py +310 -0
  72. cognee/infrastructure/loaders/supported_loaders.py +7 -0
  73. cognee/modules/data/exceptions/exceptions.py +1 -1
  74. cognee/modules/data/methods/__init__.py +3 -0
  75. cognee/modules/data/methods/get_dataset_data.py +4 -1
  76. cognee/modules/data/methods/has_dataset_data.py +21 -0
  77. cognee/modules/engine/models/TableRow.py +0 -1
  78. cognee/modules/ingestion/save_data_to_file.py +9 -2
  79. cognee/modules/pipelines/exceptions/exceptions.py +1 -1
  80. cognee/modules/pipelines/operations/pipeline.py +12 -1
  81. cognee/modules/pipelines/operations/run_tasks.py +25 -197
  82. cognee/modules/pipelines/operations/run_tasks_base.py +7 -0
  83. cognee/modules/pipelines/operations/run_tasks_data_item.py +260 -0
  84. cognee/modules/pipelines/operations/run_tasks_distributed.py +121 -38
  85. cognee/modules/pipelines/operations/run_tasks_with_telemetry.py +9 -1
  86. cognee/modules/retrieval/EntityCompletionRetriever.py +48 -8
  87. cognee/modules/retrieval/base_graph_retriever.py +3 -1
  88. cognee/modules/retrieval/base_retriever.py +3 -1
  89. cognee/modules/retrieval/chunks_retriever.py +5 -1
  90. cognee/modules/retrieval/code_retriever.py +20 -2
  91. cognee/modules/retrieval/completion_retriever.py +50 -9
  92. cognee/modules/retrieval/cypher_search_retriever.py +11 -1
  93. cognee/modules/retrieval/graph_completion_context_extension_retriever.py +47 -8
  94. cognee/modules/retrieval/graph_completion_cot_retriever.py +152 -22
  95. cognee/modules/retrieval/graph_completion_retriever.py +54 -10
  96. cognee/modules/retrieval/lexical_retriever.py +20 -2
  97. cognee/modules/retrieval/natural_language_retriever.py +10 -1
  98. cognee/modules/retrieval/summaries_retriever.py +5 -1
  99. cognee/modules/retrieval/temporal_retriever.py +62 -10
  100. cognee/modules/retrieval/user_qa_feedback.py +3 -2
  101. cognee/modules/retrieval/utils/completion.py +30 -4
  102. cognee/modules/retrieval/utils/description_to_codepart_search.py +1 -1
  103. cognee/modules/retrieval/utils/session_cache.py +156 -0
  104. cognee/modules/search/methods/get_search_type_tools.py +0 -5
  105. cognee/modules/search/methods/no_access_control_search.py +12 -1
  106. cognee/modules/search/methods/search.py +51 -5
  107. cognee/modules/search/types/SearchType.py +0 -1
  108. cognee/modules/settings/get_settings.py +23 -0
  109. cognee/modules/users/methods/get_authenticated_user.py +3 -1
  110. cognee/modules/users/methods/get_default_user.py +1 -6
  111. cognee/modules/users/roles/methods/create_role.py +2 -2
  112. cognee/modules/users/tenants/methods/create_tenant.py +2 -2
  113. cognee/shared/exceptions/exceptions.py +1 -1
  114. cognee/shared/logging_utils.py +18 -11
  115. cognee/shared/utils.py +24 -2
  116. cognee/tasks/codingagents/coding_rule_associations.py +1 -2
  117. cognee/tasks/documents/exceptions/exceptions.py +1 -1
  118. cognee/tasks/feedback/__init__.py +13 -0
  119. cognee/tasks/feedback/create_enrichments.py +84 -0
  120. cognee/tasks/feedback/extract_feedback_interactions.py +230 -0
  121. cognee/tasks/feedback/generate_improved_answers.py +130 -0
  122. cognee/tasks/feedback/link_enrichments_to_feedback.py +67 -0
  123. cognee/tasks/feedback/models.py +26 -0
  124. cognee/tasks/graph/extract_graph_from_data.py +2 -0
  125. cognee/tasks/ingestion/data_item_to_text_file.py +3 -3
  126. cognee/tasks/ingestion/ingest_data.py +11 -5
  127. cognee/tasks/ingestion/save_data_item_to_storage.py +12 -1
  128. cognee/tasks/storage/add_data_points.py +3 -10
  129. cognee/tasks/storage/index_data_points.py +19 -14
  130. cognee/tasks/storage/index_graph_edges.py +25 -11
  131. cognee/tasks/web_scraper/__init__.py +34 -0
  132. cognee/tasks/web_scraper/config.py +26 -0
  133. cognee/tasks/web_scraper/default_url_crawler.py +446 -0
  134. cognee/tasks/web_scraper/models.py +46 -0
  135. cognee/tasks/web_scraper/types.py +4 -0
  136. cognee/tasks/web_scraper/utils.py +142 -0
  137. cognee/tasks/web_scraper/web_scraper_task.py +396 -0
  138. cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py +0 -1
  139. cognee/tests/integration/web_url_crawler/test_default_url_crawler.py +13 -0
  140. cognee/tests/integration/web_url_crawler/test_tavily_crawler.py +19 -0
  141. cognee/tests/integration/web_url_crawler/test_url_adding_e2e.py +344 -0
  142. cognee/tests/subprocesses/reader.py +25 -0
  143. cognee/tests/subprocesses/simple_cognify_1.py +31 -0
  144. cognee/tests/subprocesses/simple_cognify_2.py +31 -0
  145. cognee/tests/subprocesses/writer.py +32 -0
  146. cognee/tests/tasks/descriptive_metrics/metrics_test_utils.py +0 -2
  147. cognee/tests/tasks/descriptive_metrics/neo4j_metrics_test.py +8 -3
  148. cognee/tests/tasks/entity_extraction/entity_extraction_test.py +89 -0
  149. cognee/tests/tasks/web_scraping/web_scraping_test.py +172 -0
  150. cognee/tests/test_add_docling_document.py +56 -0
  151. cognee/tests/test_chromadb.py +7 -11
  152. cognee/tests/test_concurrent_subprocess_access.py +76 -0
  153. cognee/tests/test_conversation_history.py +240 -0
  154. cognee/tests/test_feedback_enrichment.py +174 -0
  155. cognee/tests/test_kuzu.py +27 -15
  156. cognee/tests/test_lancedb.py +7 -11
  157. cognee/tests/test_library.py +32 -2
  158. cognee/tests/test_neo4j.py +24 -16
  159. cognee/tests/test_neptune_analytics_vector.py +7 -11
  160. cognee/tests/test_permissions.py +9 -13
  161. cognee/tests/test_pgvector.py +4 -4
  162. cognee/tests/test_remote_kuzu.py +8 -11
  163. cognee/tests/test_s3_file_storage.py +1 -1
  164. cognee/tests/test_search_db.py +6 -8
  165. cognee/tests/unit/infrastructure/databases/cache/test_cache_config.py +89 -0
  166. cognee/tests/unit/modules/retrieval/conversation_history_test.py +154 -0
  167. cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +51 -0
  168. {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/METADATA +21 -6
  169. {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/RECORD +178 -139
  170. {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/entry_points.txt +1 -0
  171. distributed/Dockerfile +0 -3
  172. distributed/entrypoint.py +21 -9
  173. distributed/signal.py +5 -0
  174. distributed/workers/data_point_saving_worker.py +64 -34
  175. distributed/workers/graph_saving_worker.py +71 -47
  176. cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py +0 -1116
  177. cognee/modules/retrieval/insights_retriever.py +0 -133
  178. cognee/tests/test_memgraph.py +0 -109
  179. cognee/tests/unit/modules/retrieval/insights_retriever_test.py +0 -251
  180. {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/WHEEL +0 -0
  181. {cognee-0.3.6.dist-info → cognee-0.3.7.dev1.dist-info}/licenses/LICENSE +0 -0
  182. {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
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name)
44
+ await cognee.add([explanation_file_path_nlp], dataset_name)
45
45
 
46
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
47
- 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.
48
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
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
- """
53
- await cognee.add([text], dataset_name)
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.INSIGHTS, query_text=random_node_name
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
- graph_engine = await get_graph_engine()
123
- nodes, edges = await graph_engine.get_graph_data()
124
- assert len(nodes) == 0 and len(edges) == 0, "Kuzu graph database is not empty"
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
@@ -131,20 +131,16 @@ async def main():
131
131
  dataset_name_1 = "natural_language"
132
132
  dataset_name_2 = "quantum"
133
133
 
134
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name_1)
137
+ await cognee.add([explanation_file_path_nlp], dataset_name_1)
138
138
 
139
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
140
- 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.
141
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
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([text], dataset_name_2)
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.INSIGHTS, query_text=random_node_name
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")
@@ -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.INSIGHTS, query_text=random_node_name
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"]
@@ -32,23 +32,34 @@ async def main():
32
32
 
33
33
  dataset_name = "cs_explanations"
34
34
 
35
- explanation_file_path = os.path.join(
35
+ explanation_file_path_nlp = os.path.join(
36
36
  pathlib.Path(__file__).parent, "test_data/Natural_language_processing.txt"
37
37
  )
38
- await cognee.add([explanation_file_path], dataset_name)
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
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
41
- 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.
42
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
43
- 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.
44
- 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.
45
- 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.
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([text], dataset_name)
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.INSIGHTS, query_text=random_node_name
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
- from cognee.infrastructure.databases.graph import get_graph_engine
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
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name)
44
+ await cognee.add([explanation_file_path_nlp], dataset_name)
45
45
 
46
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
47
- 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.
48
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
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([text], dataset_name)
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.INSIGHTS, query_text=random_node_name
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")
@@ -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
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name="NLP")
42
+ await cognee.add([explanation_file_path_nlp], dataset_name="NLP")
43
43
  default_user = await get_default_user()
44
44
 
45
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
46
- 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.
47
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
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([text], dataset_name="QUANTUM", user=test_user)
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
- [explanation_file_path],
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
- [explanation_file_path],
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 (explanation_file_path)
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
 
@@ -141,10 +141,10 @@ async def main():
141
141
  dataset_name_1 = "natural_language"
142
142
  dataset_name_2 = "quantum"
143
143
 
144
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name_1)
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.INSIGHTS, query_text=random_node_name
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, explanation_file_path)
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"]
@@ -42,19 +42,16 @@ async def main():
42
42
 
43
43
  dataset_name = "cs_explanations"
44
44
 
45
- explanation_file_path = os.path.join(
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([explanation_file_path], dataset_name)
48
+ await cognee.add([explanation_file_path_nlp], dataset_name)
49
49
 
50
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
51
- 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.
52
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
53
- 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.
54
- 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.
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.INSIGHTS, query_text=random_node_name
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.INSIGHTS, query_text=random_node_name
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")
@@ -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
- text = """A quantum computer is a computer that takes advantage of quantum mechanical phenomena.
31
- 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.
32
- Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster (with respect to input size scaling) than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the technology is largely experimental and impractical, with several obstacles to useful applications. Moreover, scalable quantum computers do not hold promise for many practical tasks, and for many important tasks quantum speedups are proven impossible.
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([text], dataset_name)
36
+ await cognee.add([explanation_file_path_quantum], dataset_name)
39
37
 
40
38
  await cognee.cognify([dataset_name])
41
39