Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
reliability: Disable tools for last LLM retry
Clémence Lesné13b79900efe8
diff --git a/main.py b/main.pyindex ac85715..59f416a 100644--- a/main.py+++ b/main.py@@ -533,7 +533,8 @@ async def load_llm_chat(background_tasks: BackgroundTasks,call: CallModel,client: CallConnectionClient,- _retry_remaining: int = 3,+ _backup_model: bool = False,+ _iterations_remaining: int = 3,) -> CallModel:"""Handle the intelligence of the call, including: LLM chat, TTS, and media play.@@ -567,17 +568,16 @@ async def load_llm_chat(text=text,)- # Enable backup model if two retries are left, to maximize the chance of success- backup_model = _retry_remaining < 2- if backup_model:+ if _backup_model:_logger.warn("Using backup model")chat_task = asyncio.create_task(execute_llm_chat(background_tasks=background_tasks,- backup_model=backup_model,+ backup_model=_backup_model,call=call,client=client,+ use_tools=_iterations_remaining > 0,user_callback=_tts_callback,))@@ -644,7 +644,7 @@ async def load_llm_chat(_logger.warn("Error loading intelligence", exc_info=True)if is_error: # Error during chat- if not continue_chat or _retry_remaining < 1: # Maximum retries reached+ if not continue_chat or _iterations_remaining < 1: # Maximum retries reached_logger.warn("Maximum retries reached, stopping chat")should_user_answer = Truecontent = await CONFIG.prompts.tts.error(call)@@ -659,21 +659,25 @@ async def load_llm_chat()else: # Retry chat after an error- _logger.info(f"Retrying chat, {_retry_remaining - 1} remaining")+ _logger.info(f"Retrying chat, {_iterations_remaining - 1} remaining")return await load_llm_chat(background_tasks=background_tasks,call=call,client=client,- _retry_remaining=_retry_remaining - 1,+ _backup_model=(+ _iterations_remaining < 2+ ), # Enable backup model if two retries are left, to maximize the chance of success+ _iterations_remaining=_iterations_remaining - 1,)elif continue_chat: # Contiue chat- _logger.info(f"Continuing chat")+ _logger.info(f"Continuing chat, {_iterations_remaining - 1} remaining")return await load_llm_chat(background_tasks=background_tasks,call=call,client=client,- _retry_remaining=_retry_remaining,+ _backup_model=_backup_model,+ _iterations_remaining=_iterations_remaining - 1,)if should_user_answer:@@ -770,6 +774,7 @@ async def execute_llm_chat(backup_model: bool,call: CallModel,client: CallConnectionClient,+ use_tools: bool,user_callback: Callable[[str, MessageStyleEnum], Awaitable],) -> Tuple[bool, bool, bool, CallModel]:"""@@ -871,8 +876,13 @@ async def execute_llm_chat(search=search,user_callback=user_callback,)- tools = plugins.to_openai()- _logger.debug(f"Tools: {tools}")++ tools = []+ if not use_tools:+ _logger.warn("Tools disabled for this chat")+ else:+ tools = plugins.to_openai()+ _logger.debug(f"Tools: {tools}")# Execute LLM inferencecontent_buffer_pointer = 0