File tree Expand file tree Collapse file tree
libraries/python/content-safety/content_safety/evaluators/azure_content_safety Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,13 +100,21 @@ async def _evaluate_batch(self, text: str) -> ContentSafetyEvaluation:
100100 Evaluate a batch of content for safety using the Azure Content Safety service.
101101 """
102102
103+ if not text .strip ():
104+ # if the text is empty, return a pass result
105+ return ContentSafetyEvaluation (
106+ result = ContentSafetyEvaluationResult .Pass ,
107+ note = "Empty content." ,
108+ )
109+
103110 # send the text to the Azure Content Safety service for evaluation
104111 try :
105112 response = ContentSafetyClient (
106113 endpoint = str (self .config .azure_content_safety_endpoint ),
107114 credential = self .config ._get_azure_credentials (),
108115 ).analyze_text (AnalyzeTextOptions (text = text ))
109116 except Exception as e :
117+ logger .exception ("azure content safety check failed" )
110118 # if there is an error, return a fail result with the error message
111119 return ContentSafetyEvaluation (
112120 result = ContentSafetyEvaluationResult .Fail ,
You can’t perform that action at this time.
0 commit comments