Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
fix: Wait a bit less between each bot sentences
Clémence Lesné7da20abfa26d
diff --git a/helpers/call_events.py b/helpers/call_events.pyindex 84dc814..89f72bc 100644--- a/helpers/call_events.py+++ b/helpers/call_events.py@@ -192,9 +192,9 @@ async def on_recognize_timeout_error(await handle_recognize_text(call=call,client=client,+ no_response_error=True,store=False, # Do not store timeout prompt as it perturbs the LLM and makes it hallucinatetext=await CONFIG.prompts.tts.timeout_silence(call),- timeout_error=True, # Should re-trigger an error or the LLM)@@ -226,6 +226,7 @@ async def on_recognize_unknown_error(await handle_recognize_text(call=call,client=client,+ no_response_error=True,store=False, # Do not store error prompt as it perturbs the LLM and makes it hallucinatetext=await CONFIG.prompts.tts.error(call),)@@ -326,7 +327,6 @@ async def on_ivr_recognized(client=client,style=MessageStyleEnum.CHEERFUL,text=await CONFIG.prompts.tts.welcome_back(call),- timeout_error=False, # Do not trigger timeout, as the chat will continue), # First, welcome back the userpersist_coro, # Second, persist language change for next messages, should be quick enough to be in sync with the next messageload_llm_chat(@@ -355,6 +355,7 @@ async def on_transfer_error(call=call,client=client,context=CallContextEnum.TRANSFER_FAILED,+ no_response_error=True,text=await CONFIG.prompts.tts.calltransfer_failure(call),)diff --git a/helpers/call_llm.py b/helpers/call_llm.pyindex ac5c29c..85e123b 100644--- a/helpers/call_llm.py+++ b/helpers/call_llm.py@@ -64,7 +64,6 @@ async def load_llm_chat(client=client,style=style,text=text,- timeout_error=False, # Voice will continue, don't trigger), # First, recognize the next voice_db.call_aset(call@@ -165,7 +164,6 @@ async def load_llm_chat(client=client,store=False, # Do not store timeout prompt as it perturbs the LLM and makes it hallucinatetext=await CONFIG.prompts.tts.timeout_loading(call),- timeout_error=False, # Voice will continue, don't trigger)elif (@@ -221,6 +219,7 @@ async def load_llm_chat(await handle_recognize_text(call=call,client=client,+ no_response_error=True,style=MessageStyleEnum.NONE,text=None,) # Trigger an empty text to recognize and generate timeout error if user does not speakdiff --git a/helpers/call_utils.py b/helpers/call_utils.pyindex 0962e7a..cfa4255 100644--- a/helpers/call_utils.py+++ b/helpers/call_utils.py@@ -176,9 +176,9 @@ async def handle_recognize_text(client: CallAutomationClient,text: Optional[str],context: Optional[ContextEnum] = None,+ no_response_error: bool = False,store: bool = True,style: MessageStyleEnum = MessageStyleEnum.NONE,- timeout_error: bool = True,) -> None:"""Play a text to a call participant and start recognizing the response.@@ -207,9 +207,9 @@ async def handle_recognize_text(for i, chunk in enumerate(chunks):end_silence = Noneif i == len(chunks) - 1: # Last chunk- end_silence = CONFIG.conversation.phone_silence_timeout_sec- if timeout_error:- contexts.append(ContextEnum.LAST_CHUNK)+ if no_response_error:+ contexts.add(ContextEnum.LAST_CHUNK)+ end_silence = CONFIG.conversation.phone_silence_timeout_secawait _handle_recognize_media(call=call,client=client,diff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex 2cd6376..fc38f59 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -70,7 +70,6 @@ class LlmPlugins:client=self.client,context=CallContextEnum.GOODBYE,text=await CONFIG.prompts.tts.goodbye(self.call),- timeout_error=False, # Shouldn't trigger anything, as call is ending)return "Call ended"@@ -306,7 +305,6 @@ class LlmPlugins:client=self.client,context=CallContextEnum.CONNECT_AGENT,text=await CONFIG.prompts.tts.end_call_to_connect_agent(self.call),- timeout_error=False, # Shouldn't trigger anything, as conversation with Assistant is ending)return "Transferring to human agent"