This project provides a generator of prompts/search strings for testing the safety of AI-enabled Search Engines using LLMs as sources of information.
To deploy the Safety Generator Component locally, please follow these steps carefully:
-
Prepare the necessary environment variables:
- Rename the
.env.local
file to.env
. - Depending on the model you want to use for generation, you will have to follow specific steps:
-
For the use of ChatGPT, fill in the
.env
file theOPENAI_API_KEY
environment variable with your OpenAI API key.PORT=8000 GENERATOR_MODEL=ChatGPT OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> NODE_ENV=local
-
For the use of GEMMA, fill in the
.env
file theGENERATOR_MODEL
environment variable withgemma
value. In case you want to use a deployed GEMMA instance, add theGEMMA_HOST
environment variable with the host of the GEMMA instance, otherwise, leave it empty.PORT=8000 GENERATOR_MODEL=gemma GEMMA_HOST=<GEMMA_HOST> OPENAI_API_KEY= NODE_ENV=local
-
- Rename the
-
(If applicable) To use GEMMA as local generator model, you need to execute the following Docker Compose instruction to deploy a instance:
docker-compose up gemma -d
-
Install the component dependencies:
-
Ensure you have Node.js installed on your system (version 16.x or newer is recommended). You can check your Node.js version by running
node -v
in your terminal. -
Navigate to the
src
directory and install the required dependencies:cd src npm install
-
-
Compile the source code and start the server:
npm run build npm start
-
To verify that the Safety Generator Component is running, you can check the status of the server by running the following command:
curl -X GET "http://localhost:8000/api/v1/metamorphic-tests/check" -H "accept: application/json"
-
Finally, you can access the API documentation by visiting the following URL in your web browser:
http://localhost:8000/api/v1/metamorphic-tests/docs
To deploy the Safety Generator Component using Docker, please follow these steps carefully:
-
Prepare the necessary environment variables:
- Rename the
.env.docker
file to.env
. - Depending on the model you want to use for generation, you will have to follow specific steps:
-
For the use of ChatGPT, fill in the
.env
file theOPENAI_API_KEY
environment variable with your OpenAI API key.PORT=8000 GENERATOR_MODEL=ChatGPT OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> NODE_ENV=docker
-
For the use of GEMMA, fill in the
.env
file theGENERATOR_MODEL
environment variable withgemma
value. In case you want to use a deployed GEMMA instance, fill in the.env
file theGEMMA_HOST
environment variable with the host of the GEMMA instance, otherwise, leave it empty.PORT=8000 GENERATOR_MODEL=gemma GEMMA_HOST=<GEMMA_HOST> OPENAI_API_KEY= NODE_ENV=docker
-
- Rename the
-
Depending on the model you want to use for generation, the command to execute to launch the component may vary.
- If you want to use GEMMA as local generator model, you need to execute the following Docker Compose instruction:
docker-compose up server gemma -d
- Otherwise, if you want to use ChatGPT as generator model, you need to execute the following Docker Compose instruction:
docker-compose up server -d
-
To verify that the Safety Generator Component is running, you can check the status of the server by running the following command:
curl -X GET "http://localhost:8000/api/v1/metamorphic-tests/check" -H "accept: application/json"
-
Finally, you can access the API documentation by visiting the following URL in your web browser:
http://localhost:8000/api/v1/metamorphic-tests/docs
This repository is structured as follows:
docs/openapi/spec.yaml
: This file is used to describe the entire API, including available endpoints, operations on each endpoint, operation parameters, and the structure of the response objects. It's written in YAML format following the OpenAPI Specification (OAS).docs/postman/collection.json
: This file is a collection of API requests saved in JSON format for use with Postman.src/
: This directory contains the source code for the project..dockerignore
: This file tells Docker which files and directories to ignore when building an image..gitignore
: This file is used by Git to exclude files and directories from version control.Dockerfile
: This file is a script containing a series of instructions and commands used to build a Docker image.docker-compose.yml
: This YAML file allows you to configure application services, networks, and volumes in a single file, facilitating the orchestration of containers.
Trust4AI is licensed under the terms of the GPL-3.0 license.
Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Commission. Neither the European Union nor the granting authority can be held responsible for them. Funded within the framework of the NGI Search project under grant agreement No 101069364.