Skip to content

BESSER-PEARL/BESSER-Ask-Safely

Ask Safely: A Privacy‑Aware Agent for Querying Knowledge Graphs

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


⚙️ Requirements

  • Docker ≥ 20.x
  • Python ≥ 3.9 (for data generation scripts)
  • Access to an existing Neo4j server instance
  • A valid OpenAI API key

🚀 Installation

git clone https://github.com/BESSER-PEARL/BESSER-Ask-Safely.git
cd BESSER-Ask-Safely
docker build -t ask-safely-agent:develop .

🧩 Environment Setup

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

🔄 Updating Training Data

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_PASSWORD

Rebuild the image after updating:

docker build -t ask-safely-agent:develop .

🔁 Refresh Data in an Existing Container)

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_PASSWORD

🧠 Editing Synonyms (Optional)

You can expand or refine entity synonyms manually:

  • Before building: edit CSVs in data/
  • After building: edit files in /opt/besser_agent/data inside the container

Example:

car,automobile,vehicle
house,home,residence

▶️ Starting the Agent

docker 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:develop

Note: 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.


💡 Example Usage

Open the web UI

Contributing

We welcome contributions! Please see the guidelines for instructions on how to contribute to this project.

License

This project is licensed under the MIT License.

Contact Information

For support or questions, please contact the repository maintainers or open an issue on GitHub.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •