Skip to content

Commit

Permalink
Merge branch 'main' into feat/COG-341-log-interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
borisarzentar authored Nov 17, 2024
2 parents e1a3241 + a63490b commit 0e14b0c
Show file tree
Hide file tree
Showing 19 changed files with 738 additions and 563 deletions.
5 changes: 5 additions & 0 deletions cognee/infrastructure/databases/graph/graph_db_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ async def add_edges(
async def delete_graph(
self,
): raise NotImplementedError

@abstractmethod
async def get_graph_data(
self
): raise NotImplementedError
3 changes: 0 additions & 3 deletions cognee/infrastructure/databases/graph/neo4j_driver/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ def __init__(
max_connection_lifetime = 120
)

async def close(self) -> None:
await self.driver.close()

@asynccontextmanager
async def get_session(self) -> AsyncSession:
async with self.driver.session() as session:
Expand Down
16 changes: 12 additions & 4 deletions cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,18 @@ def create_lance_data_point(data_point: DataPoint, vector: list[float]) -> Lance
for (data_point_index, data_point) in enumerate(data_points)
]

await collection.merge_insert("id") \
.when_matched_update_all() \
.when_not_matched_insert_all() \
.execute(lance_data_points)
# TODO: This enables us to work with pydantic version but shouldn't
# stay like this, existing rows should be updated

await collection.delete("id IS NOT NULL")

original_size = await collection.count_rows()
await collection.add(lance_data_points)
new_size = await collection.count_rows()

if new_size <= original_size:
raise ValueError(
"LanceDB create_datapoints error: data points did not get added.")


async def retrieve(self, collection_name: str, data_point_ids: list[str]):
Expand Down
1 change: 1 addition & 0 deletions cognee/modules/chunking/TextChunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, document, get_text: callable, chunk_size: int = 1024):
self.get_text = get_text

def read(self):
self.paragraph_chunks = []
for content_text in self.get_text():
for chunk_data in chunk_by_paragraph(
content_text,
Expand Down
84 changes: 0 additions & 84 deletions cognee/modules/cognify/dataset.py

This file was deleted.

65 changes: 0 additions & 65 deletions cognee/modules/cognify/evaluate.py

This file was deleted.

89 changes: 0 additions & 89 deletions cognee/modules/cognify/test.py

This file was deleted.

68 changes: 0 additions & 68 deletions cognee/modules/cognify/train.py

This file was deleted.

35 changes: 35 additions & 0 deletions cognee/modules/graph/cognee_graph/CogneeAbstractGraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from abc import ABC, abstractmethod
from typing import List, Dict, Union
from cognee.modules.graph.cognee_graph.CogneeGraphElements import Node, Edge
from cognee.infrastructure.databases.graph.graph_db_interface import GraphDBInterface

class CogneeAbstractGraph(ABC):
"""
Abstract base class for representing a graph structure.
"""

@abstractmethod
def add_node(self, node: Node) -> None:
"""Add a node to the graph."""
pass

@abstractmethod
def add_edge(self, edge: Edge) -> None:
"""Add an edge to the graph."""
pass

@abstractmethod
def get_node(self, node_id: str) -> Node:
"""Retrieve a node by its ID."""
pass

@abstractmethod
def get_edges(self, node_id: str) -> List[Edge]:
"""Retrieve edges connected to a specific node."""
pass

@abstractmethod
async def project_graph_from_db(self, adapter: GraphDBInterface, directed: bool, dimension: int) -> None:
"""Project the graph structure from a database using the provided adapter."""
pass
Loading

0 comments on commit 0e14b0c

Please sign in to comment.