Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
feat: Option to configure voice speed + LLM tool
Clémence Lesné59a9ff5d4476
diff --git a/helpers/call_utils.py b/helpers/call_utils.pyindex 45e6150..8ae2fe1 100644--- a/helpers/call_utils.py+++ b/helpers/call_utils.py@@ -331,7 +331,7 @@ def _audio_from_text(<lexicon uri="{CONFIG.resources.public_url}/lexicon.xml" /><lang xml:lang="{call.lang.short_code}"><mstts:express-as style="{style.value}" styledegree="0.5">- <prosody rate="0.95">{text}</prosody>+ <prosody rate="{call.initiate.prosody_rate}">{text}</prosody></mstts:express-as></lang></voice>diff --git a/helpers/config_models/conversation.py b/helpers/config_models/conversation.pyindex 9b324c7..72fa3e6 100644--- a/helpers/config_models/conversation.py+++ b/helpers/config_models/conversation.py@@ -123,6 +123,11 @@ class WorkflowInitiateModel(BaseModel):task: str = """Help the customer with their insurance claim. Assistant requires data from the customer to fill the claim. Claim data is located in the customer file. Assistant role is not over until all the relevant data is gathered."""+ prosody_rate: float = Field(+ default=1.0,+ ge=0.75,+ le=1.25,+ )def claim_model(self) -> type[BaseModel]:return _fields_to_pydantic(diff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex 543e1f8..d2ca107 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -451,6 +451,47 @@ class LlmPlugins:)return "SMS sent"+ async def speech_speed(+ self,+ customer_response: Annotated[+ str,+ """+ Phrase used to confirm the update, in the same language as the customer. This phrase will be spoken to the user.++ # Rules+ - Action should be rephrased in the present tense+ - Must be in a single sentence++ # Examples+ - 'I am slowing down the speech.'+ - 'I am speeding up the voice.'+ - 'My voice is now faster.'+ """,+ ],+ speed: Annotated[+ float,+ "The new speed of the voice. Should be between 0.75 and 1.25, where 1.0 is the normal speed.",+ ],+ ) -> str:+ """+ Use this if the customer wants to change the speed of the voice.++ # Behavior+ 1. Update the voice speed+ 2. Return a confirmation message++ # Usage examples+ - Customer has trouble understanding the voice+ - Customer wants to speed up or slow down the voice+ """+ # Update voice+ initial_speed = self.call.initiate.prosody_rate+ self.call.initiate.prosody_rate = speed+ # Customer confirmation (with new speed)+ await self.tts_callback(customer_response, self.style)+ # LLM confirmation+ return f"Voice speed set to {speed} (was {initial_speed})"+@staticmethodasync def to_openai(call: CallStateModel) -> list[ChatCompletionToolParam]:return await asyncio.gather(