Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
dev: Add logging for each client SDK init
Clémence Lesné9e923699e5e0
diff --git a/app/helpers/call_utils.py b/app/helpers/call_utils.pyindex 7b146f5..26dc4e3 100644--- a/app/helpers/call_utils.py+++ b/app/helpers/call_utils.py@@ -517,6 +517,8 @@ async def _use_call_client("""Return the call client for a given call."""+ logger.debug("Using Call client for %s", voice_id)+return client.get_call_connection(call_connection_id=voice_id)diff --git a/app/helpers/features.py b/app/helpers/features.pyindex 3d8c66f..cd9cd3a 100644--- a/app/helpers/features.py+++ b/app/helpers/features.py@@ -84,6 +84,10 @@ async def _use_client() -> AzureAppConfigurationClient:"""Generate the App Configuration client and close it after use."""+ logger.debug(+ "Using App Configuration client for %s", CONFIG.app_configuration.endpoint+ )+return AzureAppConfigurationClient(# Performancetransport=await azure_transport(),diff --git a/app/helpers/translation.py b/app/helpers/translation.pyindex 58d2334..260af05 100644--- a/app/helpers/translation.py+++ b/app/helpers/translation.py@@ -66,6 +66,8 @@ async def _use_client() -> TextTranslationClient:"""Generate the Translation client and close it after use."""+ logger.debug("Using Translation client for %s", CONFIG.ai_translation.endpoint)+return TextTranslationClient(# Performancetransport=await azure_transport(),diff --git a/app/main.py b/app/main.pyindex 71229b1..b188c71 100644--- a/app/main.py+++ b/app/main.py@@ -1086,6 +1086,10 @@ async def _use_automation_client() -> CallAutomationClient:Returns a `CallAutomationClient` instance."""+ logger.debug(+ "Using Automation Client for %s", CONFIG.communication_services.endpoint+ )+return CallAutomationClient(# Deploymentendpoint=CONFIG.communication_services.endpoint,diff --git a/app/persistence/ai_search.py b/app/persistence/ai_search.pyindex 073318d..a5610bb 100644--- a/app/persistence/ai_search.py+++ b/app/persistence/ai_search.py@@ -66,11 +66,6 @@ class AiSearchSearch(ISearch):def __init__(self, cache: ICache, config: AiSearchModel):super().__init__(cache)- logger.info("Using AI Search %s with index %s", config.endpoint, config.index)- logger.info(- "Note: At ~300 chars /doc, each LLM call will use approx %d tokens (without tools)",- 300 * config.top_n_documents * config.expansion_n_messages / 4,- )self._config = configasync def readiness(self) -> ReadinessEnum:@@ -104,7 +99,7 @@ class AiSearchSearch(ISearch):text: str,cache_only: bool = False,) -> list[TrainingModel] | None:- logger.debug('Searching training data for "%s"', text)+ # logger.debug('Searching training data for "%s"', text)if not text:return None@@ -193,6 +188,12 @@ class AiSearchSearch(ISearch):If the index does not exist, it will be created."""+ logger.debug("Using AI Search client for %s", self._config.index)+ logger.debug(+ "Note: At ~300 chars /doc, each LLM call will use approx %d tokens (without tools)",+ 300 * self._config.top_n_documents * self._config.expansion_n_messages / 4,+ )+# Index configurationfields = [# Required field for indexing keydiff --git a/app/persistence/azure_queue_storage.py b/app/persistence/azure_queue_storage.pyindex a060f63..4d7c5b7 100644--- a/app/persistence/azure_queue_storage.py+++ b/app/persistence/azure_queue_storage.py@@ -38,7 +38,6 @@ class AzureQueueStorage:account_url: str,name: str,) -> None:- logger.info('Azure Queue Storage "%s" is configured', name)self._account_url = account_urlself._name = name@@ -106,33 +105,6 @@ class AzureQueueStorage:except (UnicodeDecodeError, BinasciiError):return value- @async_lru_cache()- async def _use_service_client(self) -> QueueServiceClient:- """- Generate a new service client.- """- return QueueServiceClient(- # Performance- transport=await azure_transport(),- # Deployment- account_url=self._account_url,- # Authentication- credential=await credential(),- )-- @asynccontextmanager- async def _use_client(self) -> AsyncGenerator[QueueClient, None]:- """- Generate a queue client.- """- async with await self._use_service_client() as client:- yield client.get_queue_client(- # Performance- transport=await azure_transport(),- # Deployment- queue=self._name,- )-async def trigger(self,arg: str,@@ -186,3 +158,32 @@ class AzureQueueStorage:await func(**kwargs)# Then, delete messageawait self.delete_message(message)++ @async_lru_cache()+ async def _use_service_client(self) -> QueueServiceClient:+ """+ Generate a new service client.+ """+ logger.debug("Using Queue Service client for %s", self._account_url)++ return QueueServiceClient(+ # Performance+ transport=await azure_transport(),+ # Deployment+ account_url=self._account_url,+ # Authentication+ credential=await credential(),+ )++ @asynccontextmanager+ async def _use_client(self) -> AsyncGenerator[QueueClient, None]:+ """+ Generate a queue client.+ """+ async with await self._use_service_client() as client:+ yield client.get_queue_client(+ # Performance+ transport=await azure_transport(),+ # Deployment+ queue=self._name,+ )diff --git a/app/persistence/communication_services.py b/app/persistence/communication_services.pyindex 828d2f1..4a3e6d4 100644--- a/app/persistence/communication_services.py+++ b/app/persistence/communication_services.py@@ -57,6 +57,8 @@ class CommunicationServicesSms(ISms):@async_lru_cache()async def _use_client(self) -> SmsClient:+ logger.debug("Using SMS client for %s", self._config.endpoint)+return SmsClient(# Deploymentendpoint=self._config.endpoint,diff --git a/app/persistence/twilio.py b/app/persistence/twilio.pyindex c26b9fe..b405d9c 100644--- a/app/persistence/twilio.py+++ b/app/persistence/twilio.py@@ -65,6 +65,8 @@ class TwilioSms(ISms):@async_lru_cache()async def _use_client(self) -> Client:+ logger.debug("Using Twilio client for %s", self._config.account_sid)+return Client(# Performancehttp_client=await twilio_http(),