From 5be9d983213aca5d8a04a449c56a40d189f2f4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Mon, 9 Dec 2024 07:36:50 +0100 Subject: [PATCH] fix: New claim tool --- app/helpers/llm_tools.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/helpers/llm_tools.py b/app/helpers/llm_tools.py index e034461b..8cfd0a1e 100644 --- a/app/helpers/llm_tools.py +++ b/app/helpers/llm_tools.py @@ -20,6 +20,7 @@ from app.models.reminder import ReminderModel from app.models.training import TrainingModel +_db = CONFIG.database.instance() _search = CONFIG.ai_search.instance() _sms = CONFIG.sms.instance() @@ -93,20 +94,22 @@ async def new_claim( # Launch post-call intelligence for the current call await self.post_callback(self.call) # Store the last message and use it at first message of the new claim - last_message = self.call.messages[-1] - call = CallStateModel( - initiate=self.call.initiate.model_copy(), - voice_id=self.call.voice_id, + self.call = await _db.call_create( + CallStateModel( + initiate=self.call.initiate.model_copy(), + voice_id=self.call.voice_id, + messages=[ + # Reinsert the call action + MessageModel( + action=MessageActionEnum.CALL, + content="", + persona=MessagePersonaEnum.HUMAN, + ), + # Reinsert the last two messages + self.call.messages[-2], + ], + ) ) - call.messages += [ - MessageModel( - action=MessageActionEnum.CALL, - content="", - persona=MessagePersonaEnum.HUMAN, - ), - last_message, - ] - self.call = call return "Claim, reminders and messages reset" async def new_or_updated_reminder(