Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
feat: Allow the LLM to create a new claim in the same conversation
Clémence Lesné03aa5ca0de9e
diff --git a/helpers/prompts.py b/helpers/prompts.pyindex f79fe70..521a316 100644--- a/helpers/prompts.py+++ b/helpers/prompts.py@@ -57,6 +57,7 @@ class TTS(str, Enum):ERROR = "Je suis désolé, j'ai rencontré une erreur. Pouvez-vous répéter votre demande ?"GOODBYE = f"Merci de votre appel, j'espère avoir pu vous aider. N'hésitez pas à rappeler, j'ai tout mémorisé. {CONFIG.workflow.bot_company} vous souhaite une excellente journée !"HELLO = f"Bonjour, je suis {CONFIG.workflow.bot_name}, l'assistant {CONFIG.workflow.bot_company} ! Je suis spécialiste des sinistres. Lorsque vous entendrez un bip, c'est que je travaille. Comment puis-je vous aider ?"+ NEW_CLAIM = "Je vais créer un nouveau dossier pour vous..."TIMEOUT_SILENCE = "Je suis désolé, je n'ai rien entendu. Si vous avez besoin d'aide, dites-moi comment je peux vous aider."UPDATED_CLAIM = "Je mets à jour votre dossier..."WELCOME_BACK = f"Bonjour, je suis {CONFIG.workflow.bot_name}, l'assistant {CONFIG.workflow.bot_company} ! Je vois que vous avez déjà appelé il y a moins de {CONFIG.workflow.conversation_timeout_hour} heures. Lorsque vous entendrez un bip, c'est que je travaille. Laissez-moi quelques secondes pour récupérer votre dossier..."diff --git a/main.py b/main.pyindex 3a643d1..1574cfe 100644--- a/main.py+++ b/main.py@@ -423,6 +423,14 @@ async def intelligence()await intelligence(call, client, target_caller)+ elif chat_res.intent == IndentAction.NEW_CLAIM:+ await handle_play(+ call=call,+ client=client,+ text=TTSPrompt.NEW_CLAIM,+ )+ await intelligence(call, client, target_caller)+else:await handle_recognize(call=call,@@ -580,7 +588,19 @@ async def gpt_chat(call: CallModel) -> ActionModel:{"type": "function","function": {- "description": "Use this if the user wants to update a claim field with a new value.",+ "description": "Use this if the user wants to create a new claim. This will reset the claim data. Old is stored but not accessible anymore. Double check with the user before using this.",+ "name": IndentAction.NEW_CLAIM,+ "parameters": {+ "properties": {},+ "required": [],+ "type": "object",+ },+ },+ },+ {+ "type": "function",+ "function": {+ "description": "Use this if the user wants to update a claim field with a new value. Example: 'Update claim explanation to: I was driving on the highway when a car hit me from behind', 'Update policyholder contact info to: 123 rue de la paix 75000 Paris, +33735119775, only call after 6pm'.","name": IndentAction.UPDATE_CLAIM,"parameters": {"properties": {@@ -648,6 +668,10 @@ async def gpt_chat(call: CallModel) -> ActionModel:parameters = json.loads(arguments)setattr(call.claim, parameters["field"], parameters["value"])model.content = f"Udated claim field {parameters['field']} with value {parameters['value']}"+ elif name == IndentAction.NEW_CLAIM:+ intent = IndentAction.NEW_CLAIM+ call.claim = ClaimModel()+ model.content = "New claim created."models.append(model)diff --git a/models/action.py b/models/action.pyindex 21bf79b..0c0d2cf 100644--- a/models/action.py+++ b/models/action.py@@ -6,6 +6,7 @@ from typing import Optionalclass Indent(str, Enum):CONTINUE = "continue"END_CALL = "end_call"+ NEW_CLAIM = "new_claim"TALK_TO_HUMAN = "talk_to_human"UPDATE_CLAIM = "update_claim"