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
chore(readme): added discord
Christian617d174d6705
diff --git a/README.md b/README.mdindex 466ff5e..4f5234f 100644--- a/README.md+++ b/README.md@@ -1,4 +1,5 @@<p align="center">+ <a href="https://discord.gg/VTngQTaeDf"><img src="https://img.shields.io/badge/Discord-Join%20Lumen%20Brain-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord"/></a><img src="https://img.shields.io/badge/version-2.4.4--dev-blue?style=for-the-badge" alt="Version"/><img src="https://img.shields.io/badge/python-3.11+-green?style=for-the-badge&logo=python&logoColor=white" alt="Python"/><img src="https://img.shields.io/badge/license-AGPLv3%20%2B%20Commons%20Clause-purple?style=for-the-badge" alt="License"/>diff --git a/src/services/api/constants/requests.py b/src/services/api/constants/requests.pyindex 1d12dcb..062d65e 100644--- a/src/services/api/constants/requests.py+++ b/src/services/api/constants/requests.py@@ -3,7 +3,7 @@ File: /requests.pyCreated Date: Monday October 20th 2025Author: Christian Nonis <[email protected]>------Last Modified: Monday January 12th 2026 8:26:26 pm+Last Modified: Monday February 2nd 2026 10:04:06 pmModified By: Christian Nonis <[email protected]>-----"""@@ -276,3 +276,16 @@ class GetEntityStatusResponse(BaseModel):has_relationships: boolrelationships: List[Tuple[Predicate, Node]]observations: List[Observation]+++class GetContextRequestBody(BaseModel):+ """Request body for the get context endpoint."""++ text: str+ brain_id: str = "default"+++class GetContextResponse(BaseModel):+ """Response for the get context endpoint."""++ text_context: strdiff --git a/src/services/api/controllers/retrieve.py b/src/services/api/controllers/retrieve.pyindex 96b38bc..aa4c6b9 100644--- a/src/services/api/controllers/retrieve.py+++ b/src/services/api/controllers/retrieve.py@@ -3,7 +3,7 @@ File: /retrieve.pyCreated Date: Sunday October 26th 2025Author: Christian Nonis <[email protected]>------Last Modified: Monday January 12th 2026 8:26:26 pm+Last Modified: Thursday January 29th 2026 8:43:59 pmModified By: Christian Nonis <[email protected]>-----"""@@ -100,25 +100,26 @@ async def retrieve_neighbors() -> RetrieveNeighborsRequestResponse:"""Retrieve neighboring nodes related to a specified main node.-+If `uuid` is provided it is used to locate the main node; otherwise `identification_params` is used. Optionally filters first-degree neighbors by semantic similarity to `look_for`, expands those matches to similar nodes, and returns a deduplicated list of neighbor nodes (up to `limit`) with their relationship and the most common matching similar node.-+Parameters:uuid (Optional[str]): UUID of the main node to retrieve neighbors for. If omitted, `identification_params` must be provided.look_for (Optional[str]): Text used to filter first-degree neighbors by embedding similarity before expanding to similar nodes.identification_params (Optional[IdentificationParams]): Identification parameters used to find the main node when `uuid` is not provided.limit (int): Maximum number of neighbor results to include in the response.brain_id (str): Identifier of the brain / dataset to query.-+Returns:RetrieveNeighborsRequestResponse: Object containing:- count: total number of unique neighbors found,- main_node: the resolved main Node,- neighbors: list of RetrievedNeighborNode objects (neighbor, relationship, most_common) limited to `limit`.-+Raises:HTTPException: 404 if the main node cannot be found."""+async def _get_neighbors():# ---------------------------------------------------------@@ -362,4 +363,11 @@ async def get_entities("entities": [e.model_dump(mode="json") for e in entities.results],"total": entities.total,}- )\ No newline at end of file+ )+++async def get_context(request):+ """+ Retrieve contextual information for an entity identified by `target`.+ """+ return JSONResponse(content={"message": "Context retrieved successfully"})diff --git a/src/services/api/routes/retrieve.py b/src/services/api/routes/retrieve.pyindex 04d96e8..882f0bb 100644--- a/src/services/api/routes/retrieve.py+++ b/src/services/api/routes/retrieve.py@@ -3,7 +3,7 @@ File: /retrieve.pyCreated Date: Saturday October 25th 2025Author: Christian Nonis <[email protected]>------Last Modified: Thursday January 29th 2026 8:43:59 pm+Last Modified: Monday February 2nd 2026 10:04:06 pmModified By: Christian Nonis <[email protected]>-----"""@@ -11,6 +11,8 @@ Modified By: Christian Nonis <[email protected]>from typing import List, Literal, Optionalfrom fastapi import APIRouter, Body, Queryfrom src.services.api.constants.requests import (+ GetContextRequestBody,+ GetContextResponse,RetrieveNeighborsAiModeRequestBody,RetrieveNeighborsWithIdentificationParamsRequestBody,RetrieveRequestResponse,@@ -21,6 +23,7 @@ from src.services.api.controllers.retrieve import (retrieve_neighbors_ai_mode as retrieve_neighbors_ai_mode_controller,get_relationships as retrieve_get_relationships_controller,get_entities as retrieve_get_entities_controller,+ get_context as retrieve_get_context_controller,)from src.services.api.controllers.kg import get_hops as get_hops_controllerfrom src.services.api.controllers.retrieve import (@@ -128,18 +131,22 @@ async def get_neighbors_ai_mode()-@retrieve_router.get("/context")-async def get_context(request):+@retrieve_router.post("/context")+async def get_context(request: GetContextRequestBody) -> GetContextResponse:"""Handle an HTTP request to retrieve an entity's contextual information.Parameters:- request: The incoming FastAPI request containing the parameters (query string or body) used to identify the target entity and any context options.+ request (GetContextRequestBody): Request body containing:+ - text: The text to search context for.+ - brain_id: The brain/workspace identifier to query.Returns:- The HTTP response payload to be returned to the client containing the entity context.+ GetContextResponse: Response containing the context information."""+ return await retrieve_get_context_controller(request)+@retrieve_router.get(path="/relationships")async def get_relationships(