<!-- .github/pull_request_template.md --> ## Description <!-- Provide a clear description of the changes in this PR --> ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** • Graph visualizations now allow exporting to a user-specified file path for more flexible output management. • The text embedding process has been enhanced with an additional tokenizer option for improved performance. • A new `ExtendableDataPoint` class has been introduced for future extensions. • New JSON files for companies and individuals have been added to facilitate testing and data processing. - **Improvements** • Search functionality now uses updated identifiers for more reliable content retrieval. • Metadata handling has been streamlined across various classes by removing unnecessary type specifications. • Enhanced serialization of properties in the Neo4j adapter for improved handling of complex structures. • The setup process for databases has been improved with a new asynchronous setup function. - **Chores** • Dependency and configuration updates improve overall stability and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
24 lines
622 B
Python
24 lines
622 B
Python
from cognee.infrastructure.engine import DataPoint
|
|
|
|
|
|
def convert_node_to_data_point(node_data: dict) -> DataPoint:
|
|
subclass = find_subclass_by_name(DataPoint, node_data["type"])
|
|
|
|
return subclass(**node_data)
|
|
|
|
|
|
def get_all_subclasses(cls):
|
|
subclasses = []
|
|
for subclass in cls.__subclasses__():
|
|
subclasses.append(subclass)
|
|
subclasses.extend(get_all_subclasses(subclass)) # Recursively get subclasses
|
|
|
|
return subclasses
|
|
|
|
|
|
def find_subclass_by_name(cls, name):
|
|
for subclass in get_all_subclasses(cls):
|
|
if subclass.__name__ == name:
|
|
return subclass
|
|
|
|
return None
|