Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
feat: Tool to notify emergencies
Clémence Lesnéb1fbc93c3575
diff --git a/helpers/llm_tools.py b/helpers/llm_tools.pyindex 6583bdd..cd5242a 100644--- a/helpers/llm_tools.py+++ b/helpers/llm_tools.py@@ -3,6 +3,7 @@ from fastapi import BackgroundTasksfrom helpers.call import ContextEnum as CallContextEnum, handle_playfrom helpers.config import CONFIGfrom helpers.llm_utils import function_schema+from helpers.logging import build_loggerfrom inspect import getmembers, isfunctionfrom models.call import CallModelfrom models.claim import ClaimModel@@ -11,10 +12,13 @@ from models.reminder import ReminderModelfrom openai.types.chat import ChatCompletionToolParamfrom persistence.ai_search import AiSearchSearchfrom pydantic import ValidationError-from typing import Awaitable, Callable, Annotated, List+from typing import Awaitable, Callable, Annotated, List, Literalimport asyncio+_logger = build_logger(__name__)++class LlmPlugins:background_tasks: BackgroundTaskscall: CallModel@@ -204,6 +208,36 @@ class LlmPlugins:return res+ async def notify_emergencies(+ self,+ customer_response: Annotated[+ str,+ "Sentence to be said to the customer to confirm the update. Only speak about this action. Use an imperative sentence. Example: 'I am notifying the emergency services', 'I am notifying the police'.",+ ],+ reason: Annotated[+ str,+ "The reason to notify the emergency services. Should be detailed enough to be understood by anyone. Example: 'A person is having a heart attack', 'A child is being attacked by a dog'.",+ ],+ location: Annotated[+ str,+ "The location of the emergency. Should be detailed enough to be understood by anyone. Should contains details like the floor, the building, the code to enter, etc. Example: '123 rue de la paix 75000 Paris, Building A, 3rd floor, code 1234', '12 avenue de la manivelle 13000 Marseille, behind the red door'.",+ ],+ contact: Annotated[+ str,+ "The local contact of a person on site. Should be detailed enough to be understood by anyone. Should contains details like the name, the phone number, etc. Example: 'Marie-Jeanne, +33735119775', 'Jean-Pierre, wear a red hat'.",+ ],+ service: Annotated[+ Literal["police", "firefighters", "pharmacy", "veterinarian", "hospital"],+ "The emergency service to notify.",+ ],+ ) -> str:+ await self.user_callback(customer_response, self.style)+ # TODO: Implement notification to emergency services for production usage+ _logger.info(+ f"Notifying {service}, location {location}, contact {contact}, reason {reason}."+ )+ return f"Notifying {service} for {reason}."+@staticmethoddef to_openai() -> List[ChatCompletionToolParam]:return [