Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
quality: Code quality
Clémence Lesnéecbccc05de08
diff --git a/Makefile b/Makefileindex 8830f7d..3926058 100644--- a/Makefile+++ b/Makefile@@ -34,21 +34,19 @@ install:@echo "➡️ Installing Twilio CLI..."twilio --version || brew tap twilio/brew && brew install twilio- @echo "➡️ Installing Python app dependencies..."- python3 -m pip install -r requirements.txt-- @echo "➡️ Installing Python dev dependencies..."- python3 -m pip install -r requirements-dev.txt+ @for f in $$(find . -name "requirements*.txt"); do \+ echo "➡️ Installing Python dependencies in $$f..."; \+ python3 -m pip install -r $$f; \+ doneupgrade:@echo "➡️ Upgrading pip..."python3 -m pip install --upgrade pip- @echo "➡️ Upgrading Python app dependencies..."- python3 -m pur -r requirements.txt-- @echo "➡️ Upgrading Python dev dependencies..."- python3 -m pur -r requirements-dev.txt+ @for f in $$(find . -name "requirements*.txt"); do \+ echo "➡️ Upgrading Python dependencies in $$f..."; \+ python3 -m pip install --upgrade -r $$f; \+ done@echo "➡️ Upgrading Bicep CLI..."az bicep upgradediff --git a/function_app.py b/function_app.pyindex 25dd3cf..02392ec 100644--- a/function_app.py+++ b/function_app.py@@ -705,7 +705,7 @@ async def _use_automation_client() -> CallAutomationClient:global _automation_clientif not isinstance(_automation_client, CallAutomationClient):_automation_client = CallAutomationClient(- # Azure deployment+ # Deploymentendpoint=CONFIG.communication_services.endpoint,# Performancetransport=await azure_transport(),diff --git a/helpers/call_events.py b/helpers/call_events.pyindex a8aa8c6..7129802 100644--- a/helpers/call_events.py+++ b/helpers/call_events.py@@ -368,9 +368,7 @@ async def on_sms_received(persona=MessagePersonaEnum.HUMAN,))- await _db.call_aset(- call- ) # save in DB allowing SMS answers to be more "in-sync"+ await _db.call_aset(call) # save in DB allowing SMS answers to be more "in-sync"if not call.in_progress:logger.info("Call not in progress, answering with SMS")else:diff --git a/helpers/config_models/llm.py b/helpers/config_models/llm.pyindex c50aaca..4ece3c1 100644--- a/helpers/config_models/llm.py+++ b/helpers/config_models/llm.py@@ -40,7 +40,7 @@ class AzureOpenaiPlatformModel(AbstractPlatformModel):)self._client = AsyncAzureOpenAI(**self._client_kwargs,- # Azure deployment+ # Deploymentapi_version="2023-12-01-preview",azure_deployment=self.deployment,azure_endpoint=self.endpoint,diff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex 949ab30..bd81e3f 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -12,8 +12,9 @@ from models.message import (StyleEnum as MessageStyleEnum,)from models.reminder import ReminderModel+from models.training import TrainingModelfrom openai.types.chat import ChatCompletionToolParam-from pydantic import ValidationError+from pydantic import TypeAdapter, ValidationErrorfrom typing import Awaitable, Callable, Annotated, Literalfrom typing_extensions import TypedDictimport asyncio@@ -336,8 +337,7 @@ class LlmPlugins:trainings = sorted(set(training for task in tasks for training in task or []))# Format resultsres = "# Search results"- for training in trainings:- res += f"\n- {training.title}: {training.content}"+ res += f"\n{TypeAdapter(list[TrainingModel]).dump_json(trainings).decode()}"return resasync def notify_emergencies(diff --git a/helpers/llm_worker.py b/helpers/llm_worker.pyindex d37e10d..197060c 100644--- a/helpers/llm_worker.py+++ b/helpers/llm_worker.py@@ -555,7 +555,7 @@ async def _use_contentsafety() -> ContentSafetyClient:global _contentsafety_clientif not isinstance(_contentsafety_client, ContentSafetyClient):_contentsafety_client = ContentSafetyClient(- # Azure deployment+ # Deploymentendpoint=CONFIG.content_safety.endpoint,# Performancetransport=await azure_transport(),diff --git a/helpers/translation.py b/helpers/translation.pyindex 34f2c5a..27b88ce 100644--- a/helpers/translation.py+++ b/helpers/translation.py@@ -68,7 +68,7 @@ async def _use_client() -> TextTranslationClient:_client = TextTranslationClient(# Performancetransport=await azure_transport(),- # Azure deployment+ # Deploymentendpoint=CONFIG.ai_translation.endpoint,# Authenticationcredential=AzureKeyCredential(diff --git a/host.json b/host.jsonindex 2c2391f..c835365 100644--- a/host.json+++ b/host.json@@ -2,7 +2,7 @@"version": "2.0","extensionBundle": {"id": "Microsoft.Azure.Functions.ExtensionBundle",- "version": "[4.0.0, 5.0.0)"+ "version": "[4.*, 5.0.0)"},"functionTimeout": "00:03:00","logging": {diff --git a/persistence/ai_search.py b/persistence/ai_search.pyindex 95478e9..6193cbe 100644--- a/persistence/ai_search.py+++ b/persistence/ai_search.py@@ -142,7 +142,7 @@ class AiSearchSearch(ISearch):async def _use_client(self) -> SearchClient:if not self._client:self._client = SearchClient(- # Azure deployment+ # Deploymentendpoint=self._config.endpoint,index_name=self._config.index,# Performancediff --git a/persistence/communication_services.py b/persistence/communication_services.pyindex e834236..f864d72 100644--- a/persistence/communication_services.py+++ b/persistence/communication_services.py@@ -57,7 +57,7 @@ class CommunicationServicesSms(ISms):async def _use_client(self) -> SmsClient:if not self._client:self._client = SmsClient(- # Azure deployment+ # Deploymentendpoint=self._config.endpoint,# Performancetransport=await azure_transport(),diff --git a/persistence/cosmos_db.py b/persistence/cosmos_db.pyindex b9f2d4c..6bfd1da 100644--- a/persistence/cosmos_db.py+++ b/persistence/cosmos_db.py@@ -277,7 +277,7 @@ class CosmosDbStore(IStore):retry_total=3,# Performancetransport=await azure_transport(),- # Azure deployment+ # Deploymenturl=self._config.endpoint,# Authenticationcredential=self._config.access_key.get_secret_value(),diff --git a/persistence/redis.py b/persistence/redis.pyindex cd6f3d3..c6ed82e 100644--- a/persistence/redis.py+++ b/persistence/redis.py@@ -32,9 +32,9 @@ class RedisCache(ICache):retry_on_error=[BusyLoadingError, ConnectionError],retry_on_timeout=True,retry=_retry,- socket_connect_timeout=1, # Timeout for connection, we want it to fail fast, that's cache- socket_timeout=10, # Timeout for queries- # Azure deployment+ socket_connect_timeout=1, # 1 second, timeout for connection, we want it to fail fast, that's cache+ socket_timeout=10, # 10 seconds, timeout for queries+ # Deploymenthost=config.host,port=config.port,ssl=config.ssl,diff --git a/requirements.txt b/requirements.txtindex 7d9a1a4..bb10c31 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,4 +1,4 @@-aiohttp==3.9.5 # Required for azure-search-documents, azure-ai-contentsafety, azure-cosmos+aiohttp==3.9.5 # Required for all Azure SDKsaiosqlite==0.20.0azure-ai-contentsafety==1.0.0azure-ai-translation-text==1.0.0diff --git a/tests/conftest.py b/tests/conftest.pyindex ead5b41..a4defe2 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -108,7 +108,7 @@ class DeepEvalAzureOpenAI(GPTModel):"seed": 42,},"temperature": 0,- # Azure deployment+ # Deployment"api_version": "2023-12-01-preview","azure_deployment": platform.deployment,"azure_endpoint": platform.endpoint,