{ "answer": "Based on the knowledge graph [1][3], Sarah Jenkins led the PostgreSQL migration as Lead Engineer. She worked alongside Alex Chen (Database Administrator) [2] and the migration was approved by Mark Liu (CTO) [4]. The migration involved moving from MySQL to PostgreSQL for improved JSONB support.", "facts_used": 12}
Field
Type
Description
answer
string
LLM-generated answer grounded in retrieved graph facts. Cites fact numbers.
facts_used
int
Number of graph facts passed to the LLM as context.
from atlas_mem import AtlasMembrain = AtlasMem(api_key="atlas_...", base_url="https://api.bsyncs.com", user_id="user-123")# Ask a multi-hop questionanswer = brain.ask("Which engineers worked on the PostgreSQL migration?")print(answer)# With deeper traversalanswer = brain.ask( "What is the relationship between Sarah Jenkins and the payment infrastructure?", max_hops=4,)print(answer)
from atlas_mem import AtlasMembrain = AtlasMem( api_key="atlas_...", base_url="https://api.bsyncs.com", user_id="user-123",)# First, build up knowledgebrain.add("Sarah Jenkins is the Lead Engineer at Acme Corp.")brain.add("Sarah led the PostgreSQL migration in Q3 2024.")brain.add("The PostgreSQL migration improved query performance by 60%.")brain.add("Alex Chen is the Database Administrator who executed the migration.")brain.add("The migration was approved by Mark Liu, CTO of Acme Corp.")# Now ask relational questions — no LLM key needed on your sideprint(brain.ask("Who approved the database migration?"))# → "The database migration was approved by Mark Liu, the CTO of Acme Corp. [4]"print(brain.ask("What was the outcome of the PostgreSQL migration?"))# → "The PostgreSQL migration improved query performance by 60%. [3]"print(brain.ask("How is Sarah Jenkins connected to the CTO?"))# → "Sarah Jenkins, as Lead Engineer, led the PostgreSQL migration which was approved by Mark Liu (CTO). [1][4][5]"
Graph QA has built-in prompt injection protection:
Facts are numbered and sandboxed — the LLM is instructed to cite by number, not quote
Instructions embedded in stored facts (e.g. “ignore previous instructions”) are stripped before being passed to the LLM
Results are scoped to your user_id — the traversal query includes user_id filters at every hop, so cross-tenant leakage is impossible at the database level
Graph QA requires OPENAI_API_KEY to be set on the server. If it is unavailable, the endpoint returns {"answer": "", "error": "LLM not available"}. In this case, use the retrieve endpoint instead and pass the facts to your own LLM.