For a full reference check out: https://protect.docs.rungalileo.io/

Step 1: Install galileo-protect

pip install galileo-protect

Step 2: Set your Console URL and API Key, create a project and stage.

Example:

import galileo_protect as gp
import os

os.environ['GALILEO_API_KEY']="Your Galileo API key"
os.environ['GALILEO_CONSOLE_URL']="Your Galileo Console Url"

project = gp.create_project('my first protect project')
project_id = project.id

stage = gp.create_stage(name="my first stage", project_id=project_id)
stage_id = stage.id

Step 3: Integrate Galileo Protect with your app

Galileo Protect can be embedded in your production application through gp.invoke() like below:

USER_QUERY = 'What\'s my SSN? Hint: my SSN is 123-45-6789'
MODEL_RESPONSE = 'Your SSN is 123-45-6789'

response = gp.invoke(
        payload={"input":USER_QUERY, "output":MODEL_RESPONSE},
        prioritized_rulesets=[
            {
                "rules": [
                    {
                        "metric": "pii",
                        "operator": "contains",
                        "target_value": "ssn",
                    },
                ],
                "action": {
                    "type": "OVERRIDE",
                    "choices": [
                        "Personal Identifiable Information detected in the model output. Sorry, I cannot answer that question."
                    ],
                },
            },
        ],
        stage_id=stage_id,
        timeout=10,  # number of seconds for timeout
    )

Was this page helpful?