Created
February 13, 2025 21:01
-
-
Save pamelafox/578eec13bcf1f2e10d360dbc4b66147b to your computer and use it in GitHub Desktop.
Prompty with Content Safety Error Handling
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
import openai | |
import prompty | |
import prompty.azure | |
# execute the prompt | |
try: | |
response = prompty.execute("approaches/prompts/chat_answer_question.prompty", | |
configuration={ | |
"api_version": "2024-06-01", | |
"azure_endpoint": "https://cog-xxk4qzq3tahic.openai.azure.com", | |
"azure_deployment": "chat", | |
"type": "azure_openai" | |
}) | |
print(response) | |
except openai.APIError as error: | |
if error.code == "content_filter": | |
print("Please remember our code of conduct.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment