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é6e9c60879533
diff --git a/function_app.py b/function_app.pyindex c956df1..bb05385 100644--- a/function_app.py+++ b/function_app.py@@ -457,10 +457,10 @@ async def _communicationservices_event_worker(await on_speech_recognized(call=call,client=automation_client,- text=speech_text,post_callback=lambda _call: _trigger_post_event(call=_call, post=post),+ text=speech_text,trainings_callback=lambda _call: _trigger_trainings_event(call=_call, trainings=trainings),@@ -649,16 +649,19 @@ async def twilio_sms_post(except Exception as e:return _validation_error(e)call = await _db.call_asearch_one(phone_number)+if not call:logger.warning(f"Call for phone number {phone_number} not found")+else:trace.get_current_span().set_attribute(SpanAttributes.ENDUSER_ID, call.initiate.phone_number)+event_status = await on_sms_received(call=call,- message=message,client=await _use_automation_client(),+ message=message,post_callback=lambda _call: _trigger_post_event(call=_call, post=post),trainings_callback=lambda _call: _trigger_trainings_event(call=_call, trainings=trainings@@ -666,6 +669,7 @@ async def twilio_sms_post()if not event_status:return func.HttpResponse(status_code=HTTPStatus.INTERNAL_SERVER_ERROR)+return func.HttpResponse(body=str(MessagingResponse()), # Twilio expects an empty response everytimemimetype="application/xml",diff --git a/helpers/call_llm.py b/helpers/call_llm.pyindex 9de2d41..fa00b88 100644--- a/helpers/call_llm.py+++ b/helpers/call_llm.py@@ -316,7 +316,7 @@ async def _execute_llm_chat(call: CallStateModel,client: CallAutomationClient,post_callback: Callable[[CallStateModel], None],- tts_callback: Callable[[str, MessageStyleEnum], Awaitable],+ tts_callback: Callable[[str, MessageStyleEnum], Awaitable[None]],use_tools: bool,) -> Tuple[bool, bool, CallStateModel]:"""diff --git a/helpers/config_models/prompts.py b/helpers/config_models/prompts.pyindex 3d4d244..cef78cd 100644--- a/helpers/config_models/prompts.py+++ b/helpers/config_models/prompts.py@@ -1,5 +1,5 @@from azure.core.exceptions import HttpResponseError-from datetime import datetime, UTC+from datetime import datetimefrom functools import cached_propertyfrom html import escapefrom logging import Loggerdiff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex 096b962..3b22b65 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -35,14 +35,14 @@ class LlmPlugins:client: CallAutomationClientpost_callback: Callable[[CallStateModel], None]style: MessageStyleEnum = MessageStyleEnum.NONE- tts_callback: Callable[[str, MessageStyleEnum], Awaitable]+ tts_callback: Callable[[str, MessageStyleEnum], Awaitable[None]]def __init__(self,call: CallStateModel,client: CallAutomationClient,post_callback: Callable[[CallStateModel], None],- tts_callback: Callable[[str, MessageStyleEnum], Awaitable],+ tts_callback: Callable[[str, MessageStyleEnum], Awaitable[None]],):self.call = callself.client = clientdiff --git a/tests/llm.py b/tests/llm.pyindex c5f1212..2e189f6 100644--- a/tests/llm.py+++ b/tests/llm.py@@ -14,7 +14,7 @@ from helpers.call_events import (on_speech_recognized,)from azure.functions import QueueMessage-from datetime import UTC, datetime+from datetime import datetimefrom deepeval.metrics import BaseMetricfrom function_app import trainings_event, post_eventfrom helpers.logging import logger