Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created February 13, 2025 21:01
Show Gist options
  • Save pamelafox/578eec13bcf1f2e10d360dbc4b66147b to your computer and use it in GitHub Desktop.
Save pamelafox/578eec13bcf1f2e10d360dbc4b66147b to your computer and use it in GitHub Desktop.
Prompty with Content Safety Error Handling
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