From 279c7a07899ca2c5b994996c1d4ab3453162bcf5 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:49:52 +0100 Subject: [PATCH] Added graph intefrace, added neo4j + networkx structure and updates to the notebook --- Demo_graph.ipynb | 2 - .../databases/graph/__init__.py | 0 .../databases/graph/graph_db_interface.py | 69 +++++++++++++++++++ .../databases/graph/neo4j/__init__.py | 0 .../databases/graph/neo4j/adapter.py | 7 ++ .../databases/graph/networkx/__init__.py | 0 .../databases/graph/networkx/adapter.py | 5 ++ 7 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 cognitive_architecture/infrastructure/databases/graph/__init__.py create mode 100644 cognitive_architecture/infrastructure/databases/graph/graph_db_interface.py create mode 100644 cognitive_architecture/infrastructure/databases/graph/neo4j/__init__.py create mode 100644 cognitive_architecture/infrastructure/databases/graph/neo4j/adapter.py create mode 100644 cognitive_architecture/infrastructure/databases/graph/networkx/__init__.py create mode 100644 cognitive_architecture/infrastructure/databases/graph/networkx/adapter.py diff --git a/Demo_graph.ipynb b/Demo_graph.ipynb index b6b053977..a2356a53a 100644 --- a/Demo_graph.ipynb +++ b/Demo_graph.ipynb @@ -4556,8 +4556,6 @@ "def find_relevant_chunks(query,unique_layer_uuids):\n", " out = []\n", " for id in unique_layer_uuids:\n", - " print(id)\n", - " print(query)\n", " result = qdrant_search(id, query)\n", "\n", " if result:\n", diff --git a/cognitive_architecture/infrastructure/databases/graph/__init__.py b/cognitive_architecture/infrastructure/databases/graph/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cognitive_architecture/infrastructure/databases/graph/graph_db_interface.py b/cognitive_architecture/infrastructure/databases/graph/graph_db_interface.py new file mode 100644 index 000000000..a7be7acad --- /dev/null +++ b/cognitive_architecture/infrastructure/databases/graph/graph_db_interface.py @@ -0,0 +1,69 @@ +from typing import List +from abc import abstractmethod +from typing import Protocol + +class GraphDBInterface(Protocol): + """ Graphs """ + @abstractmethod + async def create_graph( + self, + graph_name: str, + graph_config: object + ): raise NotImplementedError + + @abstractmethod + async def update_graph( + self, + collection_name: str, + collection_config: object + ): raise NotImplementedError + + # @abstractmethod + # async def delete_collection( + # self, + # collection_name: str + # ): raise NotImplementedError + + # @abstractmethod + # async def create_vector_index( + # self, + # collection_name: str, + # vector_index_config: object + # ): raise NotImplementedError + + # @abstractmethod + # async def create_data_index( + # self, + # collection_name: str, + # vector_index_config: object + # ): raise NotImplementedError + + """ Data points """ + @abstractmethod + async def create_data_points( + self, + collection_name: str, + data_points: List[any] + ): raise NotImplementedError + + # @abstractmethod + # async def get_data_point( + # self, + # collection_name: str, + # data_point_id: str + # ): raise NotImplementedError + + # @abstractmethod + # async def update_data_point( + # self, + # collection_name: str, + # data_point_id: str, + # payload: object + # ): raise NotImplementedError + + # @abstractmethod + # async def delete_data_point( + # self, + # collection_name: str, + # data_point_id: str + # ): raise NotImplementedError diff --git a/cognitive_architecture/infrastructure/databases/graph/neo4j/__init__.py b/cognitive_architecture/infrastructure/databases/graph/neo4j/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cognitive_architecture/infrastructure/databases/graph/neo4j/adapter.py b/cognitive_architecture/infrastructure/databases/graph/neo4j/adapter.py new file mode 100644 index 000000000..878939a58 --- /dev/null +++ b/cognitive_architecture/infrastructure/databases/graph/neo4j/adapter.py @@ -0,0 +1,7 @@ +from databases.graph.graph_db_interface import GraphDBInterface + + + + +class Neo4jDB(GraphDBInterface): + pass \ No newline at end of file diff --git a/cognitive_architecture/infrastructure/databases/graph/networkx/__init__.py b/cognitive_architecture/infrastructure/databases/graph/networkx/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cognitive_architecture/infrastructure/databases/graph/networkx/adapter.py b/cognitive_architecture/infrastructure/databases/graph/networkx/adapter.py new file mode 100644 index 000000000..f0d8c6428 --- /dev/null +++ b/cognitive_architecture/infrastructure/databases/graph/networkx/adapter.py @@ -0,0 +1,5 @@ +from databases.graph.graph_db_interface import GraphDBInterface + + +class NetworXDB(GraphDBInterface): + pass \ No newline at end of file