Merge branch 'dev' into check-permissions-on-dataset-fix
This commit is contained in:
commit
3d7318e9ab
16 changed files with 3926 additions and 3874 deletions
6
.github/workflows/db_examples_tests.yml
vendored
6
.github/workflows/db_examples_tests.yml
vendored
|
|
@ -99,7 +99,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install Kuzu extra
|
- name: Install Kuzu extra
|
||||||
run: |
|
run: |
|
||||||
poetry install -E kuzu
|
poetry install
|
||||||
|
|
||||||
- name: Run Kuzu Example
|
- name: Run Kuzu Example
|
||||||
env:
|
env:
|
||||||
|
|
@ -188,7 +188,7 @@ jobs:
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out
|
- name: Check out
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
@ -265,5 +265,3 @@ jobs:
|
||||||
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
|
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
|
||||||
run: |
|
run: |
|
||||||
poetry run python examples/database_examples/pgvector_example.py
|
poetry run python examples/database_examples/pgvector_example.py
|
||||||
|
|
||||||
|
|
||||||
2
.github/workflows/e2e_tests.yml
vendored
2
.github/workflows/e2e_tests.yml
vendored
|
|
@ -234,7 +234,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install specific graph db dependency
|
- name: Install specific graph db dependency
|
||||||
run: |
|
run: |
|
||||||
poetry install -E kuzu
|
poetry install
|
||||||
|
|
||||||
- name: Run parallel databases test
|
- name: Run parallel databases test
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
2
.github/workflows/graph_db_tests.yml
vendored
2
.github/workflows/graph_db_tests.yml
vendored
|
|
@ -35,7 +35,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install specific db dependency
|
- name: Install specific db dependency
|
||||||
run: |
|
run: |
|
||||||
poetry install -E kuzu
|
poetry install
|
||||||
|
|
||||||
- name: Run Kuzu Tests
|
- name: Run Kuzu Tests
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install specific db dependency
|
- name: Install specific db dependency
|
||||||
run: |
|
run: |
|
||||||
poetry install -E postgres -E kuzu
|
poetry install -E postgres
|
||||||
|
|
||||||
- name: Run PostgreSQL Script to create test data (Chinook_PostgreSql.sql)
|
- name: Run PostgreSQL Script to create test data (Chinook_PostgreSql.sql)
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
4
.github/workflows/search_db_tests.yml
vendored
4
.github/workflows/search_db_tests.yml
vendored
|
|
@ -35,7 +35,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install specific db dependency
|
- name: Install specific db dependency
|
||||||
run: |
|
run: |
|
||||||
poetry install -E kuzu
|
poetry install
|
||||||
|
|
||||||
- name: Run Kuzu search Tests
|
- name: Run Kuzu search Tests
|
||||||
env:
|
env:
|
||||||
|
|
@ -136,7 +136,7 @@ jobs:
|
||||||
python-version: ${{ inputs.python-version }}
|
python-version: ${{ inputs.python-version }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: poetry install -E kuzu -E postgres
|
run: poetry install -E postgres
|
||||||
|
|
||||||
- name: Run Kuzu/PGVector/Postgres Tests
|
- name: Run Kuzu/PGVector/Postgres Tests
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ COPY README.md pyproject.toml uv.lock entrypoint.sh ./
|
||||||
|
|
||||||
# Install the project's dependencies using the lockfile and settings
|
# Install the project's dependencies using the lockfile and settings
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
uv sync --extra debug --extra api --extra postgres --extra weaviate --extra qdrant --extra neo4j --extra kuzu --extra llama-index --extra gemini --extra ollama --extra mistral --extra groq --extra anthropic --frozen --no-install-project --no-dev --no-editable
|
uv sync --extra debug --extra api --extra postgres --extra weaviate --extra qdrant --extra neo4j --extra llama-index --extra gemini --extra ollama --extra mistral --extra groq --extra anthropic --frozen --no-install-project --no-dev --no-editable
|
||||||
|
|
||||||
# Copy Alembic configuration
|
# Copy Alembic configuration
|
||||||
COPY alembic.ini /app/alembic.ini
|
COPY alembic.ini /app/alembic.ini
|
||||||
|
|
@ -41,7 +41,7 @@ COPY alembic/ /app/alembic
|
||||||
# Installing separately from its dependencies allows optimal layer caching
|
# Installing separately from its dependencies allows optimal layer caching
|
||||||
COPY ./cognee /app/cognee
|
COPY ./cognee /app/cognee
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
uv sync --extra debug --extra api --extra postgres --extra weaviate --extra qdrant --extra neo4j --extra kuzu --extra llama-index --extra gemini --extra ollama --extra mistral --extra groq --extra anthropic --frozen --no-dev --no-editable
|
uv sync --extra debug --extra api --extra postgres --extra weaviate --extra qdrant --extra neo4j --extra llama-index --extra gemini --extra ollama --extra mistral --extra groq --extra anthropic --frozen --no-dev --no-editable
|
||||||
|
|
||||||
FROM python:3.12-slim-bookworm
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
<a href="https://trendshift.io/repositories/13955" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13955" alt="topoteretes%2Fcognee | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/13955" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13955" alt="topoteretes%2Fcognee | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
|
|
||||||
|
**🚀 We are launching Cognee SaaS: Sign up [here](https://www.cognee.ai/waitlist) for the hosted beta!**
|
||||||
|
|
||||||
Build dynamic memory for Agents and replace RAG using scalable, modular ECL (Extract, Cognify, Load) pipelines.
|
Build dynamic memory for Agents and replace RAG using scalable, modular ECL (Extract, Cognify, Load) pipelines.
|
||||||
|
|
||||||
More on [use-cases](https://docs.cognee.ai/use-cases) and [evals](https://github.com/topoteretes/cognee/tree/main/evals)
|
More on [use-cases](https://docs.cognee.ai/use-cases) and [evals](https://github.com/topoteretes/cognee/tree/main/evals)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ class config:
|
||||||
LocalStorage.ensure_directory_exists(databases_directory_path)
|
LocalStorage.ensure_directory_exists(databases_directory_path)
|
||||||
|
|
||||||
graph_config = get_graph_config()
|
graph_config = get_graph_config()
|
||||||
graph_config.graph_file_path = os.path.join(databases_directory_path, "cognee.graph")
|
graph_file_name = graph_config.graph_filename
|
||||||
|
graph_config.graph_file_path = os.path.join(databases_directory_path, graph_file_name)
|
||||||
|
|
||||||
vector_config = get_vectordb_config()
|
vector_config = get_vectordb_config()
|
||||||
if vector_config.vector_db_provider == "lancedb":
|
if vector_config.vector_db_provider == "lancedb":
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ class GraphConfig(BaseSettings):
|
||||||
- model_config
|
- model_config
|
||||||
"""
|
"""
|
||||||
|
|
||||||
graph_filename: str = "cognee_graph.pkl"
|
graph_filename: str = "cognee_graph"
|
||||||
graph_database_provider: str = "NETWORKX"
|
graph_database_provider: str = "kuzu"
|
||||||
graph_database_url: str = ""
|
graph_database_url: str = ""
|
||||||
graph_database_username: str = ""
|
graph_database_username: str = ""
|
||||||
graph_database_password: str = ""
|
graph_database_password: str = ""
|
||||||
|
|
|
||||||
|
|
@ -1421,16 +1421,25 @@ class KuzuAdapter(GraphDBInterface):
|
||||||
|
|
||||||
async def delete_graph(self) -> None:
|
async def delete_graph(self) -> None:
|
||||||
"""
|
"""
|
||||||
Delete all data from the graph while preserving the database structure.
|
Delete all data from the graph directory.
|
||||||
|
|
||||||
This method removes all nodes and relationships from the graph but maintains the
|
This method deletes all nodes and relationships from the graph directory
|
||||||
underlying database for future use. It raises exceptions for failures occurring during
|
It raises exceptions for failures occurring during deletion processes.
|
||||||
deletion processes.
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Use DETACH DELETE to remove both nodes and their relationships in one operation
|
# Use DETACH DELETE to remove both nodes and their relationships in one operation
|
||||||
await self.query("MATCH (n:Node) DETACH DELETE n")
|
await self.query("MATCH (n:Node) DETACH DELETE n")
|
||||||
logger.info("Cleared all data from graph while preserving structure")
|
logger.info("Cleared all data from graph while preserving structure")
|
||||||
|
|
||||||
|
if self.connection:
|
||||||
|
self.connection = None
|
||||||
|
if self.db:
|
||||||
|
self.db.close()
|
||||||
|
self.db = None
|
||||||
|
if os.path.exists(self.db_path):
|
||||||
|
shutil.rmtree(self.db_path)
|
||||||
|
logger.info(f"Deleted Kuzu database files at {self.db_path}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to delete graph data: {e}")
|
logger.error(f"Failed to delete graph data: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,9 @@ async def main():
|
||||||
from cognee.infrastructure.databases.graph import get_graph_config
|
from cognee.infrastructure.databases.graph import get_graph_config
|
||||||
|
|
||||||
graph_config = get_graph_config()
|
graph_config = get_graph_config()
|
||||||
assert not os.path.exists(graph_config.graph_file_path), "Networkx graph database is not empty"
|
assert not os.path.exists(graph_config.graph_file_path) or not os.listdir(
|
||||||
|
graph_config.graph_file_path
|
||||||
|
), "Kuzu graph directory is not empty"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,14 @@ async def main():
|
||||||
await cognee.cognify()
|
await cognee.cognify()
|
||||||
|
|
||||||
graph_engine = await get_graph_engine()
|
graph_engine = await get_graph_engine()
|
||||||
graph = await graph_engine.get_graph()
|
graph = await graph_engine.get_graph_data()
|
||||||
|
|
||||||
type_counts = Counter(
|
type_counts = Counter(node_data[1].get("type", {}) for node_data in graph[0])
|
||||||
node_data["type"] for _, node_data in graph.nodes(data=True) if "type" in node_data
|
|
||||||
)
|
|
||||||
|
|
||||||
edge_type_counts = Counter(edge_type for _, _, edge_type in graph.edges(keys=True))
|
edge_type_counts = Counter(edge_type[2] for edge_type in graph[1])
|
||||||
|
|
||||||
logging.info(type_counts)
|
logging.info(type_counts)
|
||||||
|
logging.info(edge_type_counts)
|
||||||
|
|
||||||
# Assert there is exactly one PdfDocument.
|
# Assert there is exactly one PdfDocument.
|
||||||
assert type_counts.get("PdfDocument", 0) == 1, (
|
assert type_counts.get("PdfDocument", 0) == 1, (
|
||||||
|
|
|
||||||
|
|
@ -165,11 +165,56 @@ class TestInsightsRetriever:
|
||||||
|
|
||||||
await graph_engine.add_edges(
|
await graph_engine.add_edges(
|
||||||
[
|
[
|
||||||
(person1.id, company1.id, "works_for"),
|
(
|
||||||
(person2.id, company2.id, "works_for"),
|
(str)(person1.id),
|
||||||
(person3.id, company3.id, "works_for"),
|
(str)(company1.id),
|
||||||
(person4.id, company1.id, "works_for"),
|
"works_for",
|
||||||
(person5.id, company1.id, "works_for"),
|
dict(
|
||||||
|
relationship_name="works_for",
|
||||||
|
source_node_id=person1.id,
|
||||||
|
target_node_id=company1.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(str)(person2.id),
|
||||||
|
(str)(company2.id),
|
||||||
|
"works_for",
|
||||||
|
dict(
|
||||||
|
relationship_name="works_for",
|
||||||
|
source_node_id=person2.id,
|
||||||
|
target_node_id=company2.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(str)(person3.id),
|
||||||
|
(str)(company3.id),
|
||||||
|
"works_for",
|
||||||
|
dict(
|
||||||
|
relationship_name="works_for",
|
||||||
|
source_node_id=person3.id,
|
||||||
|
target_node_id=company3.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(str)(person4.id),
|
||||||
|
(str)(company1.id),
|
||||||
|
"works_for",
|
||||||
|
dict(
|
||||||
|
relationship_name="works_for",
|
||||||
|
source_node_id=person4.id,
|
||||||
|
target_node_id=company1.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(str)(person5.id),
|
||||||
|
(str)(company1.id),
|
||||||
|
"works_for",
|
||||||
|
dict(
|
||||||
|
relationship_name="works_for",
|
||||||
|
source_node_id=person5.id,
|
||||||
|
target_node_id=company1.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
11
poetry.lock
generated
11
poetry.lock
generated
|
|
@ -1,4 +1,4 @@
|
||||||
# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aiobotocore"
|
name = "aiobotocore"
|
||||||
|
|
@ -4395,10 +4395,9 @@ files = [
|
||||||
name = "kuzu"
|
name = "kuzu"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
description = "Highly scalable, extremely fast, easy-to-use embeddable graph database"
|
description = "Highly scalable, extremely fast, easy-to-use embeddable graph database"
|
||||||
optional = true
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = "*"
|
||||||
groups = ["main"]
|
groups = ["main"]
|
||||||
markers = "extra == \"api\" or extra == \"kuzu\""
|
|
||||||
files = [
|
files = [
|
||||||
{file = "kuzu-0.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ec9f216d67c092ea52086c99cf4b1deabe0f8daaf47c80cf1892b3b41c57d58a"},
|
{file = "kuzu-0.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ec9f216d67c092ea52086c99cf4b1deabe0f8daaf47c80cf1892b3b41c57d58a"},
|
||||||
{file = "kuzu-0.9.0-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:bda6d845bf1c7da204ffa7730573118f2d43fe6b14b1a5d0d2845ec3d3481362"},
|
{file = "kuzu-0.9.0-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:bda6d845bf1c7da204ffa7730573118f2d43fe6b14b1a5d0d2845ec3d3481362"},
|
||||||
|
|
@ -7613,6 +7612,7 @@ files = [
|
||||||
{file = "psycopg2-2.9.10-cp311-cp311-win_amd64.whl", hash = "sha256:0435034157049f6846e95103bd8f5a668788dd913a7c30162ca9503fdf542cb4"},
|
{file = "psycopg2-2.9.10-cp311-cp311-win_amd64.whl", hash = "sha256:0435034157049f6846e95103bd8f5a668788dd913a7c30162ca9503fdf542cb4"},
|
||||||
{file = "psycopg2-2.9.10-cp312-cp312-win32.whl", hash = "sha256:65a63d7ab0e067e2cdb3cf266de39663203d38d6a8ed97f5ca0cb315c73fe067"},
|
{file = "psycopg2-2.9.10-cp312-cp312-win32.whl", hash = "sha256:65a63d7ab0e067e2cdb3cf266de39663203d38d6a8ed97f5ca0cb315c73fe067"},
|
||||||
{file = "psycopg2-2.9.10-cp312-cp312-win_amd64.whl", hash = "sha256:4a579d6243da40a7b3182e0430493dbd55950c493d8c68f4eec0b302f6bbf20e"},
|
{file = "psycopg2-2.9.10-cp312-cp312-win_amd64.whl", hash = "sha256:4a579d6243da40a7b3182e0430493dbd55950c493d8c68f4eec0b302f6bbf20e"},
|
||||||
|
{file = "psycopg2-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:91fd603a2155da8d0cfcdbf8ab24a2d54bca72795b90d2a3ed2b6da8d979dee2"},
|
||||||
{file = "psycopg2-2.9.10-cp39-cp39-win32.whl", hash = "sha256:9d5b3b94b79a844a986d029eee38998232451119ad653aea42bb9220a8c5066b"},
|
{file = "psycopg2-2.9.10-cp39-cp39-win32.whl", hash = "sha256:9d5b3b94b79a844a986d029eee38998232451119ad653aea42bb9220a8c5066b"},
|
||||||
{file = "psycopg2-2.9.10-cp39-cp39-win_amd64.whl", hash = "sha256:88138c8dedcbfa96408023ea2b0c369eda40fe5d75002c0964c78f46f11fa442"},
|
{file = "psycopg2-2.9.10-cp39-cp39-win_amd64.whl", hash = "sha256:88138c8dedcbfa96408023ea2b0c369eda40fe5d75002c0964c78f46f11fa442"},
|
||||||
{file = "psycopg2-2.9.10.tar.gz", hash = "sha256:12ec0b40b0273f95296233e8750441339298e6a572f7039da5b260e3c8b60e11"},
|
{file = "psycopg2-2.9.10.tar.gz", hash = "sha256:12ec0b40b0273f95296233e8750441339298e6a572f7039da5b260e3c8b60e11"},
|
||||||
|
|
@ -12027,7 +12027,7 @@ cffi = ["cffi (>=1.11)"]
|
||||||
|
|
||||||
[extras]
|
[extras]
|
||||||
anthropic = ["anthropic"]
|
anthropic = ["anthropic"]
|
||||||
api = ["gunicorn", "kuzu", "uvicorn", "websockets"]
|
api = ["gunicorn", "uvicorn", "websockets"]
|
||||||
aws = ["s3fs"]
|
aws = ["s3fs"]
|
||||||
chromadb = ["chromadb", "pypika"]
|
chromadb = ["chromadb", "pypika"]
|
||||||
codegraph = ["fastembed", "transformers", "tree-sitter", "tree-sitter-python"]
|
codegraph = ["fastembed", "transformers", "tree-sitter", "tree-sitter-python"]
|
||||||
|
|
@ -12042,7 +12042,6 @@ graphiti = ["graphiti-core"]
|
||||||
groq = ["groq"]
|
groq = ["groq"]
|
||||||
gui = ["pyside6", "qasync"]
|
gui = ["pyside6", "qasync"]
|
||||||
huggingface = ["transformers"]
|
huggingface = ["transformers"]
|
||||||
kuzu = ["kuzu"]
|
|
||||||
langchain = ["langchain_text_splitters", "langsmith"]
|
langchain = ["langchain_text_splitters", "langsmith"]
|
||||||
llama-index = ["llama-index-core"]
|
llama-index = ["llama-index-core"]
|
||||||
milvus = ["pymilvus"]
|
milvus = ["pymilvus"]
|
||||||
|
|
@ -12059,4 +12058,4 @@ weaviate = ["weaviate-client"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.1"
|
lock-version = "2.1"
|
||||||
python-versions = ">=3.10,<=3.13"
|
python-versions = ">=3.10,<=3.13"
|
||||||
content-hash = "a7477a8e1c24cf477043625c926c7ebacd0b4dc66e76630e900f703a93c90986"
|
content-hash = "de20ef3dd7b184575facc5954017e974ad0171d628ec87dc852391c0d7b2b38b"
|
||||||
|
|
|
||||||
|
|
@ -55,14 +55,14 @@ dependencies = [
|
||||||
"structlog>=25.2.0,<26",
|
"structlog>=25.2.0,<26",
|
||||||
"onnxruntime<=1.21.1",
|
"onnxruntime<=1.21.1",
|
||||||
"pylance==0.22.0",
|
"pylance==0.22.0",
|
||||||
|
"kuzu==0.9.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
api = [
|
api = [
|
||||||
"uvicorn==0.34.0",
|
"uvicorn==0.34.0",
|
||||||
"gunicorn>=20.1.0,<24",
|
"gunicorn>=20.1.0,<24",
|
||||||
"websockets>=15.0.1",
|
"websockets>=15.0.1"
|
||||||
"kuzu==0.9.0",
|
|
||||||
]
|
]
|
||||||
weaviate = ["weaviate-client==4.9.6"]
|
weaviate = ["weaviate-client==4.9.6"]
|
||||||
qdrant = ["qdrant-client>=1.14.2,<2"]
|
qdrant = ["qdrant-client>=1.14.2,<2"]
|
||||||
|
|
@ -92,7 +92,6 @@ anthropic = ["anthropic>=0.26.1,<0.27"]
|
||||||
deepeval = ["deepeval>=2.0.1,<3"]
|
deepeval = ["deepeval>=2.0.1,<3"]
|
||||||
posthog = ["posthog>=3.5.0,<4"]
|
posthog = ["posthog>=3.5.0,<4"]
|
||||||
falkordb = ["falkordb==1.0.9"]
|
falkordb = ["falkordb==1.0.9"]
|
||||||
kuzu = ["kuzu==0.9.0"]
|
|
||||||
groq = ["groq==0.8.0"]
|
groq = ["groq==0.8.0"]
|
||||||
milvus = ["pymilvus>=2.5.0,<3"]
|
milvus = ["pymilvus>=2.5.0,<3"]
|
||||||
chromadb = [
|
chromadb = [
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue