Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
security: Enable Content Safety indirect attacks rule
Clémence Lesnée7f431de0a52
diff --git a/bicep/app.bicep b/bicep/app.bicepindex 5754ab3..ae78a1e 100644--- a/bicep/app.bicep+++ b/bicep/app.bicep@@ -540,6 +540,13 @@ resource contentfilter 'Microsoft.CognitiveServices/accounts/raiPolicies@2024-04basePolicyName: 'Microsoft.Default'mode: 'Default'contentFilters: [+ // Indirect attacks+ {+ blocking: true+ enabled: true+ name: 'indirect_attack'+ source: 'Prompt'+ }// Jailbreak{blocking: truediff --git a/helpers/config_models/prompts.py b/helpers/config_models/prompts.pyindex 2e4ce9e..3d4d244 100644--- a/helpers/config_models/prompts.py+++ b/helpers/config_models/prompts.py@@ -1,6 +1,7 @@from azure.core.exceptions import HttpResponseErrorfrom datetime import datetime, UTCfrom functools import cached_property+from html import escapefrom logging import Loggerfrom models.call import CallStateModelfrom models.message import MessageModel@@ -464,10 +465,13 @@ class LlmModel(BaseModel):# Format trainings, if anyif trainings:- trainings_str = (- TypeAdapter(list[TrainingModel])- .dump_json(trainings, exclude=TrainingModel.excluded_fields_for_llm())- .decode()+ # Format documents for Content Safety scan compatibility+ # See: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cpython-new#embedding-documents-in-your-prompt+ trainings_str = "\n".join(+ [+ f"<documents>{escape(training.model_dump_json(exclude=TrainingModel.excluded_fields_for_llm()))}</documents>"+ for training in trainings+ ])res += "\n\n# Trusted data you can use"res += f"\n{trainings_str}"diff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex ea15da9..096b962 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -11,10 +11,11 @@ from models.message import (PersonaEnum as MessagePersonaEnum,StyleEnum as MessageStyleEnum,)+from html import escapefrom models.reminder import ReminderModelfrom models.training import TrainingModelfrom openai.types.chat import ChatCompletionToolParam-from pydantic import TypeAdapter, ValidationError+from pydantic import ValidationErrorfrom typing import Awaitable, Callable, Annotated, Literalfrom typing_extensions import TypedDictimport asyncio@@ -335,10 +336,13 @@ class LlmPlugins:)# Flatten, remove duplicates, and sort by scoretrainings = sorted(set(training for task in tasks for training in task or []))- trainings_str = (- TypeAdapter(list[TrainingModel])- .dump_json(trainings, exclude=TrainingModel.excluded_fields_for_llm())- .decode()+ # Format documents for Content Safety scan compatibility+ # See: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cpython-new#embedding-documents-in-your-prompt+ trainings_str = "\n".join(+ [+ f"<documents>{escape(training.model_dump_json(exclude=TrainingModel.excluded_fields_for_llm()))}</documents>"+ for training in trainings+ ])# Format resultsres = "# Search results"