
Explanation:


To detect hateful content with Azure AI Foundry Content Safety - Text, you should read the category analysis results returned by the analyze_text call. The response exposes a collection named categories_analysis, where each item contains the analyzed category (e.g., TextCategory.HATE) and its severity level.
Hence:
* Iterate over response.categories_analysis, filter the item where item.category == TextCategory.HATE.
* Print the severity using hate_result.severity.
This uses category analysis (not blocklist matches), which is the correct mechanism for detecting hate content with a severity score.
Microsoft References
* Azure AI Content Safety - Analyze text (Python quickstart/samples): iterate response.
categories_analysis, check TextCategory.HATE, read item.severity.
* Azure AI Content Safety - Text categories and severity levels: explains categories (Hate, Violence, Sexual, Self-harm) and severity output.