Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
perf: Enable Content Safety async moderation
Clémence Lesné30e506805c85
diff --git a/bicep/app.bicep b/bicep/app.bicepindex ae78a1e..8f63308 100644--- a/bicep/app.bicep+++ b/bicep/app.bicep@@ -538,7 +538,7 @@ resource contentfilter 'Microsoft.CognitiveServices/accounts/raiPolicies@2024-04tags: tagsproperties: {basePolicyName: 'Microsoft.Default'- mode: 'Default'+ mode: 'Deferred' // Async moderationcontentFilters: [// Indirect attacks{diff --git a/helpers/llm_worker.py b/helpers/llm_worker.pyindex c996872..99acc4d 100644--- a/helpers/llm_worker.py+++ b/helpers/llm_worker.py@@ -188,19 +188,18 @@ async def _completion_stream_worker(): # Skip empty choices, happens sometimes with GPT-4 Turbocontinuechoice = choices[0]+ delta = choice.deltaif (choice.finish_reason == "content_filter"): # Azure OpenAI content filter- raise SafetyCheckError(- f"Issue detected in text: {choice.delta.content}"- )+ raise SafetyCheckError(f"Issue detected in text: {delta.content}")if choice.finish_reason == "length":logger.warning(f"Maximum tokens reached {max_tokens}, should be fixed")maximum_tokens_reached = True- delta = choice.delta- yield delta+ if delta:+ yield deltaelse: # Non-streaming, emulate streaming with a single completioncompletion: ChatCompletion = await client.chat.completions.create(