Created
May 7, 2024 19:22
-
-
Save aprilspeight/69cd1289f1a928c5db450eadfe34ff1b to your computer and use it in GitHub Desktop.
Prompt Shields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------- | |
# PROMPT AND DOCUMENT ATTACK | |
# -------------------- | |
import os | |
from dotenv import load_dotenv | |
import requests | |
load_dotenv() | |
key = os.environ["CONTENT_SAFETY_KEY"] | |
endpoint = os.environ["CONTENT_SAFETY_ENDPOINT"] | |
url = f'{endpoint}/contentsafety/text:shieldPrompt?api-version=2024-02-15-preview' | |
subscription_key = key | |
headers = { | |
'Ocp-Apim-Subscription-Key': subscription_key, | |
'Content-Type': 'application/json' | |
} | |
data = { | |
"userPrompt": "<Your user prompt>", | |
"documents":["<Your documents>"] | |
} | |
response = requests.post(url, headers=headers, json=data) | |
print(response.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment