Coverage for mindsdb / integrations / libs / realtime_chat_handler.py: 0%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 00:36 +0000

1from typing import Callable 

2 

3from mindsdb.interfaces.chatbot.chatbot_message import ChatBotMessage 

4from mindsdb.interfaces.chatbot.chatbot_response import ChatBotResponse 

5 

6 

7class RealtimeChatHandler: 

8 """Interface to send and receive messages over a chat application (Slack, RocketChat, etc)""" 

9 

10 def __init__(self, name: str, on_message: Callable[[ChatBotMessage], None]): 

11 self.name = name 

12 # Should be called every time a message is received. 

13 self.on_message = on_message 

14 

15 def connect(self): 

16 """Connects to chat application and starts listening for messages.""" 

17 raise NotImplementedError() 

18 

19 def disconnect(self): 

20 """Disconnects from the chat application and stops listening for messages.""" 

21 raise NotImplementedError() 

22 

23 def send_message(self, message: ChatBotMessage) -> ChatBotResponse: 

24 """ 

25 Sends a message through the chat application 

26 

27 Parameters: 

28 message (ChatBotMessage): Message to send 

29 

30 Returns: 

31 response (ChatBotResponse): Response indicating whether the message was sent successfully 

32 """ 

33 raise NotImplementedError()