cognee 0.3.4.dev0__py3-none-any.whl → 0.3.4.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.
@@ -3,6 +3,7 @@ import asyncio
3
3
  from uuid import UUID
4
4
  from pydantic import Field
5
5
  from typing import List, Optional
6
+ from fastapi.encoders import jsonable_encoder
6
7
  from fastapi.responses import JSONResponse
7
8
  from fastapi import APIRouter, WebSocket, Depends, WebSocketDisconnect
8
9
  from starlette.status import WS_1000_NORMAL_CLOSURE, WS_1008_POLICY_VIOLATION
@@ -119,7 +120,7 @@ def get_cognify_router() -> APIRouter:
119
120
 
120
121
  # If any cognify run errored return JSONResponse with proper error status code
121
122
  if any(isinstance(v, PipelineRunErrored) for v in cognify_run.values()):
122
- return JSONResponse(status_code=420, content=cognify_run)
123
+ return JSONResponse(status_code=420, content=jsonable_encoder(cognify_run))
123
124
  return cognify_run
124
125
  except Exception as error:
125
126
  return JSONResponse(status_code=409, content={"error": str(error)})
@@ -1,7 +1,8 @@
1
1
  from sqlalchemy.orm import DeclarativeBase
2
+ from sqlalchemy.ext.asyncio import AsyncAttrs
2
3
 
3
4
 
4
- class Base(DeclarativeBase):
5
+ class Base(AsyncAttrs, DeclarativeBase):
5
6
  """
6
7
  Represents a base class for declarative models using SQLAlchemy.
7
8
 
@@ -56,7 +56,12 @@ async def get_file_metadata(file: BinaryIO) -> FileMetadata:
56
56
  file_type = guess_file_type(file)
57
57
 
58
58
  file_path = getattr(file, "name", None) or getattr(file, "full_name", None)
59
- file_name = Path(file_path).stem if file_path else None
59
+
60
+ if isinstance(file_path, str):
61
+ file_name = Path(file_path).stem if file_path else None
62
+ else:
63
+ # In case file_path does not exist or is a integer return None
64
+ file_name = None
60
65
 
61
66
  # Get file size
62
67
  pos = file.tell() # remember current pointer
@@ -1,6 +1,7 @@
1
- from typing import Any, Optional
1
+ from typing import Any, Optional, List, Union
2
2
  from uuid import UUID
3
3
  from pydantic import BaseModel
4
+ from cognee.modules.data.models.Data import Data
4
5
 
5
6
 
6
7
  class PipelineRunInfo(BaseModel):
@@ -8,11 +9,15 @@ class PipelineRunInfo(BaseModel):
8
9
  pipeline_run_id: UUID
9
10
  dataset_id: UUID
10
11
  dataset_name: str
11
- payload: Optional[Any] = None
12
+ # Data must be mentioned in typing to allow custom encoders for Data to be activated
13
+ payload: Optional[Union[Any, List[Data]]] = None
12
14
  data_ingestion_info: Optional[list] = None
13
15
 
14
16
  model_config = {
15
17
  "arbitrary_types_allowed": True,
18
+ "from_attributes": True,
19
+ # Add custom encoding handler for Data ORM model
20
+ "json_encoders": {Data: lambda d: d.to_json()},
16
21
  }
17
22
 
18
23
 
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from typing import Callable, List, Optional, Type
2
3
 
3
4
  from cognee.modules.engine.models.node_set import NodeSet
@@ -160,6 +161,12 @@ async def get_search_type_tools(
160
161
  if query_type is SearchType.FEELING_LUCKY:
161
162
  query_type = await select_search_type(query_text)
162
163
 
164
+ if (
165
+ query_type in [SearchType.CYPHER, SearchType.NATURAL_LANGUAGE]
166
+ and os.getenv("ALLOW_CYPHER_QUERY", "true").lower() == "false"
167
+ ):
168
+ raise UnsupportedSearchTypeError("Cypher query search types are disabled.")
169
+
163
170
  search_type_tools = search_tasks.get(query_type)
164
171
 
165
172
  if not search_type_tools:
@@ -1,3 +1,5 @@
1
+ from types import SimpleNamespace
2
+
1
3
  from cognee.shared.logging_utils import get_logger
2
4
 
3
5
  from ...models.User import User
@@ -17,9 +19,14 @@ async def get_all_user_permission_datasets(user: User, permission_type: str) ->
17
19
  # Get all datasets all tenants have access to
18
20
  tenant = await get_tenant(user.tenant_id)
19
21
  datasets.extend(await get_principal_datasets(tenant, permission_type))
22
+
20
23
  # Get all datasets Users roles have access to
21
- for role_name in user.roles:
22
- role = await get_role(user.tenant_id, role_name)
24
+ if isinstance(user, SimpleNamespace):
25
+ # If simple namespace use roles defined in user
26
+ roles = user.roles
27
+ else:
28
+ roles = await user.awaitable_attrs.roles
29
+ for role in roles:
23
30
  datasets.extend(await get_principal_datasets(role, permission_type))
24
31
 
25
32
  # Deduplicate datasets with same ID
@@ -48,7 +48,7 @@ class TestCogneeServerStart(unittest.TestCase):
48
48
  """Test that the server is running and can accept connections."""
49
49
  # Test health endpoint
50
50
  health_response = requests.get("http://localhost:8000/health", timeout=15)
51
- self.assertIn(health_response.status_code, [200, 503])
51
+ self.assertIn(health_response.status_code, [200])
52
52
 
53
53
  # Test root endpoint
54
54
  root_response = requests.get("http://localhost:8000/", timeout=15)
@@ -88,7 +88,7 @@ class TestCogneeServerStart(unittest.TestCase):
88
88
  payload = {"datasets": [dataset_name]}
89
89
 
90
90
  add_response = requests.post(url, headers=headers, data=form_data, files=file, timeout=50)
91
- if add_response.status_code not in [200, 201, 409]:
91
+ if add_response.status_code not in [200, 201]:
92
92
  add_response.raise_for_status()
93
93
 
94
94
  # Cognify request
@@ -99,7 +99,7 @@ class TestCogneeServerStart(unittest.TestCase):
99
99
  }
100
100
 
101
101
  cognify_response = requests.post(url, headers=headers, json=payload, timeout=150)
102
- if cognify_response.status_code not in [200, 201, 409]:
102
+ if cognify_response.status_code not in [200, 201]:
103
103
  cognify_response.raise_for_status()
104
104
 
105
105
  # TODO: Add test to verify cognify pipeline is complete before testing search
@@ -115,7 +115,7 @@ class TestCogneeServerStart(unittest.TestCase):
115
115
  payload = {"searchType": "GRAPH_COMPLETION", "query": "What's in the document?"}
116
116
 
117
117
  search_response = requests.post(url, headers=headers, json=payload, timeout=50)
118
- if search_response.status_code not in [200, 201, 409]:
118
+ if search_response.status_code not in [200, 201]:
119
119
  search_response.raise_for_status()
120
120
 
121
121
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognee
3
- Version: 0.3.4.dev0
3
+ Version: 0.3.4.dev1
4
4
  Summary: Cognee - is a library for enriching LLM context with a semantic layer for better understanding and reasoning.
5
5
  Project-URL: Homepage, https://www.cognee.ai
6
6
  Project-URL: Repository, https://github.com/topoteretes/cognee
@@ -316,7 +316,19 @@ You can also cognify your files and query using cognee UI.
316
316
 
317
317
  <img src="assets/cognee-new-ui.webp" width="100%" alt="Cognee UI 2"></a>
318
318
 
319
- Try cognee UI by runnning ``` cognee-cli -ui ``` command on your terminal.
319
+ ### Installation for UI
320
+
321
+ To use the cognee UI with full functionality, you need to install cognee with API dependencies:
322
+
323
+ ```bash
324
+ pip install 'cognee[api]'
325
+ ```
326
+
327
+ The UI requires backend server functionality (uvicorn and other API dependencies) which are not included in the default cognee installation to keep it lightweight.
328
+
329
+ ### Running the UI
330
+
331
+ Try cognee UI by running ``` cognee-cli -ui ``` command on your terminal.
320
332
 
321
333
  ## Understand our architecture
322
334
 
@@ -24,7 +24,7 @@ cognee/api/v1/cognify/code_graph_pipeline.py,sha256=gRU0GSTyYSNg-jT84pDbSH3alkFG
24
24
  cognee/api/v1/cognify/cognify.py,sha256=gLLkcw1WQ1awdfoyZCdV_UzYSIaRHIBP0ltaR2W5y_w,12053
25
25
  cognee/api/v1/cognify/routers/__init__.py,sha256=wiPpOoQbSKje-SfbRQ7HPao0bn8FckRvIv0ipKW5Y90,114
26
26
  cognee/api/v1/cognify/routers/get_code_pipeline_router.py,sha256=uO5KzjXYYkZaxzCYxe8-zKYZwXZLUPsJ5sJY9h7dYtw,2974
27
- cognee/api/v1/cognify/routers/get_cognify_router.py,sha256=m0Ol4qVkammdWSFAW1_ghbASJjPnMSfV4u7qz4GbLJY,8169
27
+ cognee/api/v1/cognify/routers/get_cognify_router.py,sha256=fYsXZZL2gPcFWkngc8_dU3XHDusBwD6QyntyCmGesNk,8233
28
28
  cognee/api/v1/config/__init__.py,sha256=D_bzXVg_vtSAW6U7S3qUDSqHU1Lf-cFpVt2rXrpBdnc,27
29
29
  cognee/api/v1/config/config.py,sha256=ckyX0euGNYNXK0tFq5b_OouE6x4VDKFG3uXgMDNUbfk,6522
30
30
  cognee/api/v1/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -172,7 +172,7 @@ cognee/infrastructure/databases/graph/neptune_driver/neptune_utils.py,sha256=n9i
172
172
  cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py,sha256=C8S81Xz_uWlyWkpZlSE9sYlMizcE6efPwcc1O-L-QSQ,41886
173
173
  cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py,sha256=Y-P1YoajimqIc0T0YoN3xjTbW3zEdlir4zsTAcnBE7A,17617
174
174
  cognee/infrastructure/databases/hybrid/neptune_analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
175
- cognee/infrastructure/databases/relational/ModelBase.py,sha256=YOyt3zsuYBP73PcF2WCN6wgUBrWmgE2qUwsAhXKESes,304
175
+ cognee/infrastructure/databases/relational/ModelBase.py,sha256=-zau90uq4nDbM5GBdlxnU0oOko1NtYpcZdp_2DfEweQ,362
176
176
  cognee/infrastructure/databases/relational/__init__.py,sha256=dkP-wkByc3BpClP1RWRmkxtayOorMrMzRw-pJtDHPkE,400
177
177
  cognee/infrastructure/databases/relational/config.py,sha256=iYIkMBKdZVgpdfwQCU9M0-zz-_ThnhczkUXn9VABaDk,4722
178
178
  cognee/infrastructure/databases/relational/create_db_and_tables.py,sha256=sldlFgE4uFdVBdXGqls6YAYX0QGExO2FHalfH58xiRE,353
@@ -240,7 +240,7 @@ cognee/infrastructure/files/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
240
240
  cognee/infrastructure/files/utils/extract_text_from_file.py,sha256=-v0uvK6nXP6Q2Ia0GjIi97WntPFX6sWZQXO_Fg9TrCc,1112
241
241
  cognee/infrastructure/files/utils/get_data_file_path.py,sha256=Xz9anl6yYxK6wETKhVeK4f3ahjw58Aj8YkyJkJONOvc,1549
242
242
  cognee/infrastructure/files/utils/get_file_content_hash.py,sha256=0L_wgsRF8zqmtisFWcp4agDs7WovvBjiVWNQ_NCPKwo,1338
243
- cognee/infrastructure/files/utils/get_file_metadata.py,sha256=RKV1rsU9USseBV8FjRLElas4Ny4m8pqpPrYkqVT8AfA,2146
243
+ cognee/infrastructure/files/utils/get_file_metadata.py,sha256=WpyOTUf2CPFT8ZlxOWuchg34xu8HVrsMP7cpahsFX7g,2292
244
244
  cognee/infrastructure/files/utils/guess_file_type.py,sha256=5d7qBd23O5BgcxEYan21kTWW7xISNhiH1SLaE4Nx8Co,3120
245
245
  cognee/infrastructure/files/utils/is_text_content.py,sha256=iNZWCECNLMjlQfOQAujVQis7prA1cqsscRRSQsxccZo,1316
246
246
  cognee/infrastructure/files/utils/open_data_file.py,sha256=CO654MXgbDXQFAJzrKXxS7csJGi3BEOR7F5Oljh4x2I,2369
@@ -482,7 +482,6 @@ cognee/modules/metrics/operations/__init__.py,sha256=MZ3xbVdfEKqfLct8WnbyFVyZmkB
482
482
  cognee/modules/metrics/operations/get_pipeline_run_metrics.py,sha256=upIWnzKeJT1_XbL_ABdGxW-Ai7mO3AqMK35BNmItIQQ,2434
483
483
  cognee/modules/notebooks/methods/__init__.py,sha256=IhY4fUVPJbuvS83QESsWzjZRC6oC1I-kJi5gr3kPTLk,215
484
484
  cognee/modules/notebooks/methods/create_notebook.py,sha256=S41H3Rha0pj9dEKFy1nBG9atTGHhUdOmDZgr0ckUA6M,633
485
- cognee/modules/notebooks/methods/create_tutorial_notebook.py,sha256=ZoGilQU993M0j3fFjBicOSsF5TFEq_k8tjbD_90sI7g,4269
486
485
  cognee/modules/notebooks/methods/delete_notebook.py,sha256=BKxoRlPzkwXvTYh5WcF-zo_iVmaXqEiptS42JwB0KQU,309
487
486
  cognee/modules/notebooks/methods/get_notebook.py,sha256=IP4imsdt9X6GYd6i6WF6PlVhotGNH0i7XZpPqbtqMwo,554
488
487
  cognee/modules/notebooks/methods/get_notebooks.py,sha256=ee40ALHvebVORuwZVkQ271qAj260rrYy6eVGxAmfo8c,483
@@ -518,7 +517,7 @@ cognee/modules/pipelines/methods/reset_pipeline_run_status.py,sha256=vHrGf2m9N89
518
517
  cognee/modules/pipelines/models/DataItemStatus.py,sha256=QsWnMvcVE4ZDwTQP7pckg3O0Mlxs2xixqlOySMYPX0s,122
519
518
  cognee/modules/pipelines/models/Pipeline.py,sha256=UOipcAaslLKJOceBQNaqUK-nfiD6wz7h6akwtDWkNA8,803
520
519
  cognee/modules/pipelines/models/PipelineRun.py,sha256=zx714gI16v6OcOmho530Akmz2OdWlvDU5HI4KtqHNFg,949
521
- cognee/modules/pipelines/models/PipelineRunInfo.py,sha256=9EZn0K-dVJKRpNgRCw2BAg1QdsEBAd1XlIbTorhhJa4,840
520
+ cognee/modules/pipelines/models/PipelineRunInfo.py,sha256=6gZKYN-15JNX05IXHLm9sOugBgSqH6jS2s4uiji9Hdc,1156
522
521
  cognee/modules/pipelines/models/PipelineTask.py,sha256=v9HgLxjc9D5mnMU_dospVTUQ_VpyTOL00mUF9ckERSY,481
523
522
  cognee/modules/pipelines/models/Task.py,sha256=SENQAPI5yAXCNdbLxO-hNKnxZ__0ykOCyCN2DSZc_Yw,796
524
523
  cognee/modules/pipelines/models/TaskRun.py,sha256=Efb9ZrYVEYpCb92K_eW_K4Zwjm8thHmZh1vMTkpBMdM,478
@@ -577,7 +576,7 @@ cognee/modules/retrieval/utils/stop_words.py,sha256=HP8l2leoLf6u7tnWHrYhgVMY_TX6
577
576
  cognee/modules/search/exceptions/__init__.py,sha256=7lH9BznC2274FD481U_8hfrxWonzJ8Mcv4oAkFFveqc,172
578
577
  cognee/modules/search/exceptions/exceptions.py,sha256=Zc5Y0M-r-UnSSlpKzHKBplfjZ-Kcvmx912Cuw7wBg9g,431
579
578
  cognee/modules/search/methods/__init__.py,sha256=jGfRvNwM5yIzj025gaVhcx7nCupRSXbUUnFjYVjL_Js,27
580
- cognee/modules/search/methods/get_search_type_tools.py,sha256=wXxOZx3uEnMhRhUO2HGswQ5iVbWvjUj17UT_qdJg6Oo,6837
579
+ cognee/modules/search/methods/get_search_type_tools.py,sha256=omZUt5gJmmxGFizABgnKmGoYOo0tRJBfKdAmYinA9SE,7090
581
580
  cognee/modules/search/methods/no_access_control_search.py,sha256=R08aMgaB8AkD0_XVaX15qLyC9KJ3fSVFv9zeZwuyez4,1566
582
581
  cognee/modules/search/methods/search.py,sha256=JjB9Nhxt_AIDF24z81FWGm7VVJFW90RCXRAU9VhMG34,12430
583
582
  cognee/modules/search/models/Query.py,sha256=9WcF5Z1oCFtA4O-7An37eNAPX3iyygO4B5NSwhx7iIg,558
@@ -649,7 +648,7 @@ cognee/modules/users/permissions/permission_types.py,sha256=6oUwupxBANfEYp9tx7Hc
649
648
  cognee/modules/users/permissions/methods/__init__.py,sha256=0y-DjLFEdJEG_JOy0WoXJnVaiK-Q--LuAvfunl_74s0,861
650
649
  cognee/modules/users/permissions/methods/authorized_give_permission_on_datasets.py,sha256=HSbrnTsb-MWUiZ3e_hAZqUgjYdTcqggJ0fRbPJ1Iaoc,1016
651
650
  cognee/modules/users/permissions/methods/check_permission_on_dataset.py,sha256=mJTv-BSCAzrYEBPs6BL-W6qJhL-ZEq8C8LZ85d7WIPU,522
652
- cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py,sha256=VR0rV8y5S1Yf7E1bd9hOVRb4vg4CVrr6wHwci9Zcgr4,1242
651
+ cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py,sha256=sPv-k-UlpzwBdzFHiUimYvK90na2CNxOHi0CrzYcYD8,1411
653
652
  cognee/modules/users/permissions/methods/get_document_ids_for_user.py,sha256=UDOgHh0p2uGYm-k7LMd3yQChaW8oAL7IBfItMV7cjWM,2604
654
653
  cognee/modules/users/permissions/methods/get_principal.py,sha256=m5VlhZUscAD-Zn1D_ylCi1t-6eIoYZZPSOmaGbzkqRo,485
655
654
  cognee/modules/users/permissions/methods/get_principal_datasets.py,sha256=jsJLfRRFGAat3biHtoz6VE7jNif_uDri5l6SaaodtZ0,917
@@ -766,7 +765,7 @@ cognee/tasks/temporal_graph/extract_knowledge_graph_from_events.py,sha256=biDjIO
766
765
  cognee/tasks/temporal_graph/models.py,sha256=2fBZWqfZfLNh5BHqU8RbW60R1_IZU3PgY8MZJHlF0S0,1390
767
766
  cognee/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
768
767
  cognee/tests/test_chromadb.py,sha256=D9JEN0xbFxNLgp8UJTVAjpwob9S-LOQC-hSaMVvYhR8,9240
769
- cognee/tests/test_cognee_server_start.py,sha256=kcIbzu72ZZUlPZ51c_DpSCCwx3X9mNvYZrVcxHfZaJs,4226
768
+ cognee/tests/test_cognee_server_start.py,sha256=jxFexF_Pir6zWPxpnZ-JTI9HOftqCXc6aaox4U3w1YM,4206
770
769
  cognee/tests/test_custom_model.py,sha256=vypoJkF5YACJ6UAzV7lQFRmtRjVYEoPcUS8Rylgc1Wg,3465
771
770
  cognee/tests/test_deduplication.py,sha256=1wSVq58rwFQOE5JtUcO3T92BBzzGTkC49yiaausjOac,8365
772
771
  cognee/tests/test_delete_by_id.py,sha256=ROCGHYpI9bLBC-6d6F1VUq4kGPr0fzutbcSO3CGKbC8,13175
@@ -890,9 +889,9 @@ distributed/tasks/queued_add_edges.py,sha256=kz1DHE05y-kNHORQJjYWHUi6Q1QWUp_v3Dl
890
889
  distributed/tasks/queued_add_nodes.py,sha256=aqK4Ij--ADwUWknxYpiwbYrpa6CcvFfqHWbUZW4Kh3A,452
891
890
  distributed/workers/data_point_saving_worker.py,sha256=jFmA0-P_0Ru2IUDrSug0wML-5goAKrGtlBm5BA5Ryw4,3229
892
891
  distributed/workers/graph_saving_worker.py,sha256=oUYl99CdhlrPAIsUOHbHnS3d4XhGoV0_OIbCO8wYzRg,3648
893
- cognee-0.3.4.dev0.dist-info/METADATA,sha256=T3Pt0L4t3GKyziXuy4n1Kdlh3OUfPt4pPh4VDrjVkPY,14752
894
- cognee-0.3.4.dev0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
895
- cognee-0.3.4.dev0.dist-info/entry_points.txt,sha256=GCCTsNg8gzOJkolq7dR7OK1VlIAO202dGDnMI8nm8oQ,55
896
- cognee-0.3.4.dev0.dist-info/licenses/LICENSE,sha256=pHHjSQj1DD8SDppW88MMs04TPk7eAanL1c5xj8NY7NQ,11344
897
- cognee-0.3.4.dev0.dist-info/licenses/NOTICE.md,sha256=6L3saP3kSpcingOxDh-SGjMS8GY79Rlh2dBNLaO0o5c,339
898
- cognee-0.3.4.dev0.dist-info/RECORD,,
892
+ cognee-0.3.4.dev1.dist-info/METADATA,sha256=6bowgjMT-6oiTpzQfG_eEjB3vtlxkwyu0bJeUmqbsYU,15097
893
+ cognee-0.3.4.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
894
+ cognee-0.3.4.dev1.dist-info/entry_points.txt,sha256=GCCTsNg8gzOJkolq7dR7OK1VlIAO202dGDnMI8nm8oQ,55
895
+ cognee-0.3.4.dev1.dist-info/licenses/LICENSE,sha256=pHHjSQj1DD8SDppW88MMs04TPk7eAanL1c5xj8NY7NQ,11344
896
+ cognee-0.3.4.dev1.dist-info/licenses/NOTICE.md,sha256=6L3saP3kSpcingOxDh-SGjMS8GY79Rlh2dBNLaO0o5c,339
897
+ cognee-0.3.4.dev1.dist-info/RECORD,,
@@ -1,87 +0,0 @@
1
- from uuid import UUID, uuid4
2
- from sqlalchemy.ext.asyncio import AsyncSession
3
-
4
- from ..models import NotebookCell
5
- from .create_notebook import create_notebook
6
-
7
-
8
- async def create_tutorial_notebook(user_id: UUID, session: AsyncSession):
9
- await create_notebook(
10
- user_id=user_id,
11
- notebook_name="Welcome to cognee 🧠",
12
- cells=[
13
- NotebookCell(
14
- id=uuid4(),
15
- name="Welcome",
16
- content="Cognee is your toolkit for turning text into a structured knowledge graph, optionally enhanced by ontologies, and then querying it with advanced retrieval techniques. This notebook will guide you through a simple example.",
17
- type="markdown",
18
- ),
19
- NotebookCell(
20
- id=uuid4(),
21
- name="Example",
22
- content="",
23
- type="markdown",
24
- ),
25
- ],
26
- deletable=False,
27
- session=session,
28
- )
29
-
30
-
31
- cell_content = [
32
- """
33
- # Using Cognee with Python Development Data
34
-
35
- Unite authoritative Python practice (Guido van Rossum's own contributions!), normative guidance (Zen/PEP 8), and your lived context (rules + conversations) into one *AI memory* that produces answers that are relevant, explainable, and consistent.
36
- """,
37
- """
38
- ## What You'll Learn
39
-
40
- In this comprehensive tutorial, you'll discover how to transform scattered development data into an intelligent knowledge system that enhances your coding workflow. By the end, you'll have:
41
- - Connected disparate data sources (Guido's CPython contributions, mypy development, PEP discussions, your Python projects) into a unified AI memory graph
42
- - Built an memory layer that understands Python design philosophy, best practice coding patterns, and your preferences and experience
43
- - Learn how to use intelligent search capabilities that combine the diverse context
44
- - Integrated everything with your coding environment through MCP (Model Context Protocol)
45
-
46
- This tutorial demonstrates the power of **knowledge graphs** and **retrieval-augmented generation (RAG)** for software development, showing you how to build systems that learn from Python's creator and improve your own Python development.
47
- """,
48
- """
49
- ## Cognee and its core operations
50
-
51
- Before we dive in, let's understand the core Cognee operations we'll be working with:
52
- - `cognee.add()` - Ingests raw data (files, text, APIs) into the system
53
- - `cognee.cognify()` - Processes and structures data into a knowledge graph using AI
54
- - `cognee.search()` - Queries the knowledge graph with natural language or Cypher
55
- - `cognee.memify()` - Cognee's \"secret sauce\" that infers implicit connections and rules from your data
56
- """,
57
- """
58
- ## Data used in this tutorial
59
-
60
- Cognee can ingest many types of sources. In this tutorial, we use a small, concrete set of files that cover different perspectives:
61
- - `guido_contributions.json` — Authoritative exemplars. Real PRs and commits from Guido van Rossum (mypy, CPython). These show how Python's creator solved problems and provide concrete anchors for patterns.
62
- - `pep_style_guide.md` — Norms. Encodes community style and typing conventions (PEP 8 and related). Ensures that search results and inferred rules align with widely accepted standards.
63
- - `zen_principles.md` — Philosophy. The Zen of Python. Grounds design trade-offs (simplicity, explicitness, readability) beyond syntax or mechanics.
64
- - `my_developer_rules.md` — Local constraints. Your house rules, conventions, and project-specific requirements (scope, privacy, Spec.md). Keeps recommendations relevant to your actual workflow.
65
- - `copilot_conversations.json` — Personal history. Transcripts of real assistant conversations, including your questions, code snippets, and discussion topics. Captures "how you code" and connects it to "how Guido codes."
66
- """,
67
- """
68
- # Preliminaries
69
-
70
- To strike the balanace between speed, cost, anc quality, we recommend using OpenAI's `4o-mini` model; make sure your `.env` file contains this line:
71
- `
72
- LLM_MODEL="gpt-4o-mini"
73
- `
74
- """,
75
- """
76
- import cognee
77
-
78
- result = await cognee.add(
79
- "file://data/guido_contributions.json",
80
- node_set=["guido_data"]
81
- )
82
-
83
- await cognee.cognify(temporal_cognify=True)
84
-
85
- results = await cognee.search("Show me commits")
86
- """,
87
- ]