QuestionQ103
VerifiedImplement text analysis solutionsYou are building a Python application that collects customer comments before they are posted to a public forum. You need to send a text comment to Azure AI Content Safety and return the self-harm severity value from the response. How should the code be completed?

Select
def get_self_harm_severity (comment: str) -> int: key = os.environ["CONTENT_SAFETY_KEY"] endpoint = os.environ["CONTENT_SAFETY_ENDPOINT"] client = ContentSafetyClient(endpoint, AzureKeyCredential(key)) request = response = result = next( item for item in response.categories_analysis if item.category == TextCategory.SELF_HARM ) return result.severity
Community Discussion