Last active
May 7, 2024 19:23
-
-
Save aprilspeight/130fba14b351152ae995be78de2df01a to your computer and use it in GitHub Desktop.
Groundedness
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
# -------------------- | |
# Groundedness Q&A | |
# -------------------- | |
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:detectGroundedness?api-version=2024-02-15-preview' | |
subscription_key = key | |
headers = { | |
'Ocp-Apim-Subscription-Key': subscription_key, | |
'Content-Type': 'application/json' | |
} | |
data = { | |
"domain": "Generic", | |
"task": "QnA", | |
"qna": { | |
"query": "<Your query>" | |
}, | |
"text": "<Your text>", | |
"groundingSources": [ | |
"<Your grounding source>" | |
], | |
"reasoning": False | |
} | |
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