Ask Safely is a BESSER Agentic Framework (BAF)–based agent that helps users safely query Knowledge Graphs (KGs) while preventing potential disclosure of sensitive data to large language models (LLMs).
Ask Safely automatically anonymizes all data in user questions that also appear in the KG.
Additionally, if you want to ensure that a specific term is anonymized, enclose it in brackets — for example:
In which movies [Brad Pitt] acted?
This will be answered without disclosing "Brad Pitt" to the LLM.
The repository includes a preconfigured Neo4j “recommendations” graph
- Docker ≥ 20.x
- Python ≥ 3.9 (for data generation scripts)
- Access to an existing Neo4j server instance
- A valid OpenAI API key
git clone https://github.com/BESSER-PEARL/BESSER-Ask-Safely.git
cd BESSER-Ask-Safely
docker build -t ask-safely-agent:develop .Before running the BAF agent, set up these environment variables:
| Variable | Description |
|---|---|
| OPENAI_API_KEY | Your OpenAI API key |
| NEO4J_URI | URI for Neo4j instance |
| NEO4J_USERNAME | Neo4j username |
| NEO4J_PASSWORD | Neo4j password |
| NEO4J_DATABASE | Database name |
To use your own Knowledge Graph data, regenerate the entries and schema:
python src/generate_entries.py $NEO4J_URI $NEO4J_USERNAME $NEO4J_PASSWORD
python src/generate_schema.py $NEO4J_URI $NEO4J_USERNAME $NEO4J_PASSWORDRebuild the image after updating:
docker build -t ask-safely-agent:develop .Run these commands to renew data without rebuilding:
docker run ask-safely-agent:develop python /opt/besser_agent/generate_entries.py $NEO4J_URI $NEO4J_USERNAME $NEO4J_PASSWORD
docker run ask-safely-agent:develop python /opt/besser_agent/generate_schema.py $NEO4J_URI $NEO4J_USERNAME $NEO4J_PASSWORDYou can expand or refine entity synonyms manually:
- Before building: edit CSVs in
data/ - After building: edit files in
/opt/besser_agent/datainside the container
Example:
car,automobile,vehicle
house,home,residencedocker run --rm -p 5000:5000 -p 8765:8765 -e OPENAI_API_KEY="$OPENAI_API_KEY" -e NEO4J_URI=$NEO4J_URI -e NEO4J_USERNAME=$NEO4J_USERNAME -e NEO4J_PASSWORD=$NEO4J_PASSWORD -e NEO4J_DATABASE=$NEO4J_DATABASE ask-safely-agent:developNote: If you want to test with the default Neo4j recommendations graph, you do not need to provide the Neo4j environment variables — they are preconfigured inside the container.
Open the web UI
- Go to: http://localhost:5000
- Enter your question in the input box and submit.
We welcome contributions! Please see the guidelines for instructions on how to contribute to this project.
This project is licensed under the MIT License.
For support or questions, please contact the repository maintainers or open an issue on GitHub.