Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
quality: Avoid followed entries with assistant
Clémence Lesné19f34f02b0c4
diff --git a/helpers/call.py b/helpers/call.pyindex d3d4286..010477f 100644--- a/helpers/call.py+++ b/helpers/call.py@@ -140,13 +140,18 @@ async def handle_play(See: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts"""if store:- call.messages.append(- MessageModel(- content=text,- persona=MessagePersonaEnum.ASSISTANT,- style=style,+ if (+ call.messages[-1].persona == MessagePersonaEnum.ASSISTANT+ ): # If the last message was from the assistant, append to it+ call.messages[-1].content += f" {text}"+ else: # Otherwise, create a new message+ call.messages.append(+ MessageModel(+ content=text,+ persona=MessagePersonaEnum.ASSISTANT,+ style=style,+ ))- )# Split text in chunks of max 400 characters, separated by sentencechunks = []diff --git a/main.py b/main.pyindex 7a5fb55..cb21b8a 100644--- a/main.py+++ b/main.py@@ -792,9 +792,15 @@ async def execute_llm_chat(4. `CallModel`, the updated model"""_logger.debug("Running LLM chat")+ content_full = ""should_user_answer = True- async def _buffer_user_callback(+ async def _tools_callback(text: str, style: MessageStyleEnum) -> None:+ nonlocal content_full+ content_full += f" {text}"+ await user_callback(text, style)++ async def _content_callback(buffer: str, style: MessageStyleEnum) -> MessageStyleEnum:# Remove tool calls from buffer content and detect style@@ -850,7 +856,7 @@ async def execute_llm_chat(post_call_next=post_call_next,post_call_synthesis=post_call_synthesis,search=search,- user_callback=user_callback,+ user_callback=_tools_callback,)tools = []@@ -862,7 +868,6 @@ async def execute_llm_chat(# Execute LLM inferencecontent_buffer_pointer = 0- content_full = ""tool_calls_buffer: dict[int, MessageToolModel] = {}try:async for delta in completion_stream(@@ -885,7 +890,7 @@ async def execute_llm_chat(content_full[content_buffer_pointer:], False):content_buffer_pointer += len(sentence)- plugins.style = await _buffer_user_callback(sentence, plugins.style)+ plugins.style = await _content_callback(sentence, plugins.style)except ReadError:_logger.warn("Network error", exc_info=True)return True, True, should_user_answer, call@@ -895,7 +900,7 @@ async def execute_llm_chat(# Flush the remaining bufferif content_buffer_pointer < len(content_full):- plugins.style = await _buffer_user_callback(+ plugins.style = await _content_callback(content_full[content_buffer_pointer:], plugins.style)