Skip to content

BrainAPI is a knowledge graph–powered AI memory layer that transforms unstructured data into structured knowledge, enabling intelligent search, recommendations, and contextual memory for AI agents and applications.

fix(graph): neo4j query str format

Christian33a7fb093b52
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..8efa7da
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,87 @@
+# Multi-stage build for brainapi2
+FROM python:3.11-slim AS builder
+
+ARG BUILD_DATE
+ARG BUILD_SHA
+ARG CACHE_BUST
+
+# Set environment variables
+ENV PYTHONUNBUFFERED=1 \
+ PYTHONDONTWRITEBYTECODE=1 \
+ PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1
+
+# Install system dependencies
+RUN apt-get update && apt-get install -y \
+ build-essential \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install Poetry
+RUN pip install poetry==1.8.3
+
+# Configure Poetry
+ENV POETRY_NO_INTERACTION=1 \
+ POETRY_VENV_IN_PROJECT=1 \
+ POETRY_CACHE_DIR=/tmp/poetry_cache \
+ POETRY_VENV_PATH=/app/.venv
+
+# Set work directory
+WORKDIR /app
+
+# Copy Poetry files
+COPY pyproject.toml poetry.lock ./
+
+# Install dependencies
+RUN poetry config virtualenvs.in-project true && \
+ poetry lock && poetry install --no-root --sync && rm -rf $POETRY_CACHE_DIR
+
+# Production stage
+FROM python:3.11-slim AS production
+
+ARG BUILD_DATE
+ARG BUILD_SHA
+ARG CACHE_BUST
+
+LABEL build_date="${BUILD_DATE}" \
+ build_sha="${BUILD_SHA}" \
+ cache_bust="${CACHE_BUST}"
+
+# Set environment variables
+ENV PYTHONUNBUFFERED=1 \
+ PYTHONDONTWRITEBYTECODE=1 \
+ PATH="/app/.venv/bin:$PATH"
+
+# Install runtime dependencies
+RUN apt-get update && apt-get install -y \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Create non-root user
+RUN groupadd -r appuser && useradd -r -g appuser appuser
+
+# Set work directory
+WORKDIR /app
+
+# Copy virtual environment from builder stage
+COPY --from=builder /app/.venv /app/.venv
+
+# Copy application code
+COPY src/ ./src/
+
+# Change ownership to non-root user
+RUN chown -R appuser:appuser /app
+USER appuser
+
+# Switch to non-root user
+USER root
+
+# Expose port
+EXPOSE 8000
+
+# Health check
+HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
+ CMD curl -f http://localhost:8000/docs || exit 1
+
+# Default command
+CMD ["/app/.venv/bin/python", "-m", "uvicorn", "src.services.api.app:app", "--host", "0.0.0.0", "--port", "8000"]
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index b727703..12ae6f9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "brainapi2"
-version = "1.5.1"
+version = "1.5.1-dev"
description = "Version 1.x.x of the BrainAPI memory layer."
authors = [
{name = "Christian",email = "[email protected]"}
diff --git a/src/lib/neo4j/client.py b/src/lib/neo4j/client.py
index 1538981..e78b2fe 100644
--- a/src/lib/neo4j/client.py
+++ b/src/lib/neo4j/client.py
@@ -720,7 +720,7 @@ class Neo4jClient(GraphClient):
SKIP {skip}
LIMIT {limit}
"""
- cypher_count = """
+ cypher_count = f"""
MATCH (n)-[r]-(m)
{"WHERE " + " AND ".join(filters) if filters else ""}
RETURN count(r) AS total