What is Container Playground?

Container Playground is a containerized web application that allows the user to interact with our container without the need for writing code. Currently, this application supports PII redaction in text and files, and it can also generate sample code for the user if they choose to interact with Private AI's REST API.

It aims to be a self-hosted version of the Private AI Plaground that is available on our Customer Portal.

Getting the Container Playground

The Container Playground image is hosted on the same container registry as our main container.

If you already have a customer portal account with us and have a license to deploy Private AI's containers locally, then you can use the Docker credentials that are present in the portal to gain access to the Private AI Container Playground image.

Where to find the licenses on Private AI's Customer Portal

If you wish to host Private AI locally, please contact us to get a license.

If you prefer to use our Cloud API, you can get started right away by getting an API key through our portal.

Once you have the credentials ready, you can simply login with the following command:

Copy
Copied
docker login -u <username> -p  <password> crprivateaiprod.azurecr.io

Once you are logged in, you can simply run the following command to download the image:

Copy
Copied
docker pull crprivateaiprod.azurecr.io/playground:<version>

Setting up the Container Playground

There are various different ways to setup the Container Playground image. However, we will be focusing on 2 main ones in the guide. These 2 ways are:

  1. Setting up the Container Playground as a standalone app
  2. Setting up the Container Playground together with the Private AI container

1. Setting up the Container Playground as a standalone app

This setup covers the cases where the main container is already deployed separately or the plan is to deploy the Container Playground and the Private AI container separately for better scalability.

Container Playground running together with the main container on the same machine

In this case, we are assuming that the Container Playground will be running on the same machine as the Private AI container. Currently, this configuration is the default one, so you can just simply start up the container with the following command:

Copy
Copied
docker run --network host -it crprivateaiprod.azurecr.io/playground:<version>

You can access the app using the http://localhost:3000 address.

This setup assumes that the Private AI container is running and accessible at the http://localhost:8080 address.

Container Playground running on a different machine

In this case, we are assuming that there is a Private AI container deployed somewhere and the Container Playground is being set up separately to interact with it.

First, if the Private AI container endpoints are not protected (i.e. no authentication required), then you can simply use the following command to set up the Container Playground:

Copy
Copied
docker run \
    -p 3000:3000 \
    -e PAI_API_TEXT_ENDPOINT=<the URL to the /process/text endpoint> \
    -e PAI_API_FILE_ENDPOINT=<the URL to the /process/files/base64 endpoint> \
    -it crprivateaiprod.azurecr.io/playground:<version>

Here, we are simply pointing the setup to the correct address so it can successfully communicate with the deidentification service.

However, if the deidentification service endpoints are protected, then you can set up the Container Playground in the following way:

Copy
Copied
docker run \
    -p 3000:3000 \
    -e PAI_API_TEXT_AUTH=1 \
    -e PAI_API_FILE_AUTH=1 \
    -e PAI_API_TEXT_AUTH_HEADER=<text endpoint authentication header name, e.g. "x-api-key"> \
    -e PAI_API_FILE_AUTH_HEADER=<file endpoint authentication header name, e.g. "x-api-key"> \
    -e PAI_API_TEXT_KEY=<text endpoint API key> \
    -e PAI_API_FILE_KEY=<file endpoint API key> \
    -e PAI_API_TEXT_ENDPOINT=<the URL to the /process/text endpoint> \
    -e PAI_API_FILE_ENDPOINT=<the URL to the /process/files/base64 endpoint> \
    -it crprivateaiprod.azurecr.io/playground:<version>

NOTE: Currently, the Container Playground only supports the API key authentication where the credentials are passed in the request header.

2. Setting up the Container Playground together with the Private AI container

This setup covers the use case where the Contaier Playground is setup / deployed together with the Private AI container on the same machine. It assumes that docker compose is used for this setup.

In this case, the most important point is to correctly set up the communication between the Container Playground and the Private AI container. Following is an example compose.yml file that demonstrates how to achieve this:

Copy
Copied
services:
    container_playground:
        container_name: container_playground
        image: crprivateaiprod.azurecr.io/playground:<version>
        ports:
            - 3000:3000
        networks:
            - deid
        environment:
            - PAI_API_TEXT_ENDPOINT=http://deid:8080/process/text
            - PAI_API_FILE_ENDPOINT=http://deid:8080/process/files/base64
    
    deid:
        container_name: deid
        image: crprivateaiprod.azurecr.io/deid:<version>
        ports:
            - 8080:8080
        volumes:
            - </path/to/your/license/file.json>:/app/license/license.json
        networks:
            - deid

networks:
    deid:
        network_name: deid

One important thing to note here is the endpoints. Instead of using localhost, we are passing the name of the container (i.e. deid), which is an important step to make sure that both contaienrs can communicate.

Configuration Options

Currently, the Container Playground application can be configured using the following environment variables:

Environment Variable Description
PORT The port that the application is listening on in the container. Defaults to 3000.
PAI_API_TEXT_ENDPOINT The URL of the /process/text endpoint of the Private AI container. Defaults to `http://localhost:8080/process/text
PAI_API_FILE_ENDPOINT The URL of the /process/files/base64 endpoint of the Private AI container. Defaults to http://localhost:8080/process/files/base64.
PAI_API_TEXT_AUTH Determines whether API authentication is required for the /process/text endpoint. Defaults to 0, which means that it is turned off. If your /process/text endpoint requires authentication, please set this to 1.
PAI_API_FILE_AUTH Determines whether API authentication is required for the /process/files/base64 endpoint. Defaults to 0, which means that it is turned off. If your /process/files/base64 endpoint requires authentication, please set this to 1.
PAI_API_TEXT_AUTH_HEADER This is used if PAI_API_TEXT_AUTH is set to 1. This is the request header that the API key is sent with.
PAI_API_FILE_AUTH_HEADER This is used if PAI_API_FILE_AUTH is set to 1. This is the request header that the API key is sent with.
PAI_API_TEXT_KEY This is used if PAI_API_TEXT_AUTH is set to 1. This is the API key that is used for the /process/text endpoint
PAI_API_FILE_KEY This is used if PAI_API_FILE_AUTH is set to 1. This is the API key that is used for the /process/files/base64 endpoint

Container Playground - Text Processing with Automatic Updates

If you wish to enable the "Auto Update Mode" of the text redaction component on the Container Playground, you can do so by adding the auto=true query parameter at the end of the URL. Here is an example:

Copy
Copied
http://localhost:3000/text?auto=true

This will enable the feature where the text is redacted automatically as you type.

© Copyright 2024 Private AI.