-
Notifications
You must be signed in to change notification settings - Fork 961
Add type to DataPoint metadata #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 10 additions & 5 deletions
15
cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 9 additions & 5 deletions
14
cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
cognee/infrastructure/databases/vector/qdrant/QDrantAdapter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,16 @@ | ||
| from cognee.infrastructure.engine import DataPoint | ||
| from uuid import UUID | ||
|
|
||
| from cognee.infrastructure.engine import DataPoint | ||
|
|
||
|
|
||
| class Document(DataPoint): | ||
| type: str | ||
| name: str | ||
| raw_data_location: str | ||
| metadata_id: UUID | ||
| mime_type: str | ||
| _metadata: dict = { | ||
| "type": "Document" | ||
| } | ||
|
|
||
| def read(self, chunk_size: int) -> str: | ||
| pass | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,5 @@ class Entity(DataPoint): | |
|
|
||
| _metadata: dict = { | ||
| "index_fields": ["name"], | ||
| "type": "Entity" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| from cognee.infrastructure.engine import DataPoint | ||
|
|
||
|
|
||
| class EntityType(DataPoint): | ||
| __tablename__ = "entity_type" | ||
| name: str | ||
| type: str | ||
| description: str | ||
|
|
||
| _metadata: dict = { | ||
| "index_fields": ["name"], | ||
| "type": "EntityType" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,14 @@ | ||
| from typing import Optional | ||
|
|
||
| from cognee.infrastructure.engine import DataPoint | ||
|
|
||
|
|
||
| class EdgeType(DataPoint): | ||
| __tablename__ = "edge_type" | ||
| relationship_name: str | ||
| number_of_edges: int | ||
|
|
||
| _metadata: Optional[dict] = { | ||
| "index_fields": ["relationship_name"], | ||
| "type": "EdgeType" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,47 @@ | ||
| from typing import List, Optional | ||
|
|
||
| from cognee.infrastructure.engine import DataPoint | ||
|
|
||
|
|
||
| class Repository(DataPoint): | ||
| __tablename__ = "Repository" | ||
| path: str | ||
| type: Optional[str] = "Repository" | ||
| _metadata: dict = { | ||
| "index_fields": ["source_code"], | ||
| "type": "Repository" | ||
| } | ||
|
|
||
| class CodeFile(DataPoint): | ||
| __tablename__ = "codefile" | ||
| extracted_id: str # actually file path | ||
| type: Optional[str] = "CodeFile" | ||
| source_code: Optional[str] = None | ||
| part_of: Optional[Repository] = None | ||
| depends_on: Optional[List["CodeFile"]] = None | ||
| depends_directly_on: Optional[List["CodeFile"]] = None | ||
| contains: Optional[List["CodePart"]] = None | ||
|
|
||
| _metadata: dict = { | ||
| "index_fields": ["source_code"] | ||
| "index_fields": ["source_code"], | ||
| "type": "CodeFile" | ||
| } | ||
|
|
||
| class CodePart(DataPoint): | ||
| __tablename__ = "codepart" | ||
| # part_of: Optional[CodeFile] | ||
| source_code: str | ||
| type: Optional[str] = "CodePart" | ||
|
|
||
|
|
||
| _metadata: dict = { | ||
| "index_fields": ["source_code"] | ||
| "index_fields": ["source_code"], | ||
| "type": "CodePart" | ||
| } | ||
|
|
||
| class CodeRelationship(DataPoint): | ||
| source_id: str | ||
| target_id: str | ||
| type: str # between files | ||
| relation: str # depends on or depends directly | ||
| _metadata: dict = { | ||
| "type": "CodeRelationship" | ||
| } | ||
|
|
||
| CodeFile.model_rebuild() | ||
| CodePart.model_rebuild() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure
node_datahas_metadataattribute with"type"keyThe change accesses
node_data._metadata["type"]instead ofnode_data["type"]. Verify thatnode_datais an object with an_metadataattribute containing the"type"key. Ifnode_datais a dictionary, this change may cause anAttributeError.Consider adding a check to ensure that
_metadataexists and handle cases wherenode_datamight not have this attribute.