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.
Python ai-agentsai-memoryknowledge-graphknowledge-managementknowledge-representationreccomendation-system
feat(mongo): handled managed instance
Christianad9836dd0b61
diff --git a/Dockerfile b/Dockerfileindex 825a6a3..d47311a 100644--- a/Dockerfile+++ b/Dockerfile@@ -19,7 +19,8 @@ RUN pip install poetry==1.8.3# Configure PoetryENV POETRY_NO_INTERACTION=1 \POETRY_VENV_IN_PROJECT=1 \- POETRY_CACHE_DIR=/tmp/poetry_cache+ POETRY_CACHE_DIR=/tmp/poetry_cache \+ POETRY_VENV_PATH=/app/.venv# Set work directoryWORKDIR /app@@ -28,7 +29,8 @@ WORKDIR /appCOPY pyproject.toml poetry.lock ./# Install dependencies-RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR+RUN poetry config virtualenvs.in-project true && \+ poetry lock && poetry install --no-root --sync && rm -rf $POETRY_CACHE_DIR# Production stageFROM python:3.11-slim AS productiondiff --git a/Makefile b/Makefileindex 781ac21..2dc461d 100644--- a/Makefile+++ b/Makefile@@ -83,7 +83,16 @@ clear-all-volumes:VERSION := $(shell poetry version -s)container-build:- docker build -t ghcr.io/lumen-labs/brainapi:v$(VERSION) ./+ docker build --platform linux/amd64 -t ghcr.io/lumen-labs/brainapi:v$(VERSION) ./+ docker tag ghcr.io/lumen-labs/brainapi:v$(VERSION) ghcr.io/lumen-labs/brainapi:latestcontainer-push:- docker push ghcr.io/lumen-labs/brainapi:v$(VERSION)\ No newline at end of file+ docker push ghcr.io/lumen-labs/brainapi:v$(VERSION)+ docker push ghcr.io/lumen-labs/brainapi:latest++container-release:+ VERSION=$$(poetry version -s)+ docker build --platform linux/amd64 -t ghcr.io/lumen-labs/brainapi:v$$VERSION ./+ docker tag ghcr.io/lumen-labs/brainapi:v$$VERSION ghcr.io/lumen-labs/brainapi:latest+ docker push ghcr.io/lumen-labs/brainapi:v$$VERSION+ docker push ghcr.io/lumen-labs/brainapi:latest\ No newline at end of filediff --git a/src/config.py b/src/config.pyindex 925c8aa..6dc79fd 100644--- a/src/config.py+++ b/src/config.py@@ -104,7 +104,11 @@ class MongoConfig:self.username = os.getenv("MONGO_USERNAME")self.password = os.getenv("MONGO_PASSWORD")- if [self.host, self.port, self.username, self.password].count(None) > 0:+ self.connection_string = os.getenv("MONGO_CONNECTION_STRING")++ if [self.host, self.port, self.username, self.password].count(+ None+ ) > 0 and not self.connection_string:raise ValueError("Mongo configuration is not complete")diff --git a/src/lib/mongo/client.py b/src/lib/mongo/client.pyindex 1e5291e..081781d 100644--- a/src/lib/mongo/client.py+++ b/src/lib/mongo/client.py@@ -23,13 +23,19 @@ class MongoClient(DataClient):"""def __init__(self):- self.client = PyMongoClient(- config.mongo.host,- config.mongo.port,- username=config.mongo.username,- password=config.mongo.password,- authSource="admin",- )+ if (+ hasattr(config.mongo, "connection_string")+ and config.mongo.connection_string+ ):+ self.client = PyMongoClient(config.mongo.connection_string)+ else:+ self.client = PyMongoClient(+ config.mongo.host,+ config.mongo.port,+ username=config.mongo.username,+ password=config.mongo.password,+ authSource="admin",+ )def get_database(self, database: str = "data") -> Database:return self.client[database]