chatgraph 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chatgraph might be problematic. Click here for more details.
- chatgraph/bot/chatbot_model.py +8 -2
- chatgraph/messages/test_message_consumer.py +17 -0
- chatgraph/types/output_state.py +57 -0
- chatgraph/types/user_state.py +20 -0
- {chatgraph-0.1.3.dist-info → chatgraph-0.1.4.dist-info}/METADATA +1 -1
- {chatgraph-0.1.3.dist-info → chatgraph-0.1.4.dist-info}/RECORD +8 -7
- {chatgraph-0.1.3.dist-info → chatgraph-0.1.4.dist-info}/LICENSE +0 -0
- {chatgraph-0.1.3.dist-info → chatgraph-0.1.4.dist-info}/WHEEL +0 -0
chatgraph/bot/chatbot_model.py
CHANGED
|
@@ -6,7 +6,7 @@ from logging import debug
|
|
|
6
6
|
from ..error.chatbot_error import ChatbotError, ChatbotMessageError
|
|
7
7
|
from ..messages.base_message_consumer import MessageConsumer
|
|
8
8
|
from ..types.message_types import Message
|
|
9
|
-
from ..types.output_state import ChatbotResponse, RedirectResponse
|
|
9
|
+
from ..types.output_state import ChatbotResponse, RedirectResponse, EndChatResponse, TransferToHuman
|
|
10
10
|
from ..types.route import Route
|
|
11
11
|
from ..types.user_state import UserState
|
|
12
12
|
from .chatbot_router import ChatbotRouter
|
|
@@ -143,11 +143,17 @@ class ChatbotApp(ABC):
|
|
|
143
143
|
elif type(message_response) == ChatbotResponse:
|
|
144
144
|
route = self.__adjust_route(message_response.route, menu)
|
|
145
145
|
self.__user_state.set_menu(customer_id, route)
|
|
146
|
-
return message_response.
|
|
146
|
+
return message_response.json()
|
|
147
147
|
elif type(message_response) == RedirectResponse:
|
|
148
148
|
route = self.__adjust_route(message_response.route, menu)
|
|
149
149
|
self.__user_state.set_menu(customer_id, route)
|
|
150
150
|
return self.process_message(message)
|
|
151
|
+
elif type(message_response) == EndChatResponse:
|
|
152
|
+
self.__user_state.delete_menu(customer_id)
|
|
153
|
+
return message_response.json()
|
|
154
|
+
elif type(message_response) == TransferToHuman:
|
|
155
|
+
self.__user_state.delete_menu(customer_id)
|
|
156
|
+
return message_response.json()
|
|
151
157
|
else:
|
|
152
158
|
raise ChatbotError('Tipo de retorno inválido!')
|
|
153
159
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Any, Callable
|
|
2
|
+
from .base_message_consumer import MessageConsumer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestMessageConsumer(MessageConsumer):
|
|
6
|
+
"""
|
|
7
|
+
Classe de consumidor de mensagens de teste para uso em testes unitários.
|
|
8
|
+
"""
|
|
9
|
+
def __init__(self) -> None:
|
|
10
|
+
super().__init__()
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def load_dotenv(cls) -> 'TestMessageConsumer':
|
|
14
|
+
return cls()
|
|
15
|
+
|
|
16
|
+
def start_consume(self, process_message: Callable) -> Any:
|
|
17
|
+
return super().start_consume(process_message)
|
chatgraph/types/output_state.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from typing import Union
|
|
2
|
+
import json
|
|
2
3
|
|
|
3
4
|
messageTypes = Union[str, float, int, None]
|
|
4
5
|
|
|
@@ -22,6 +23,15 @@ class ChatbotResponse:
|
|
|
22
23
|
"""
|
|
23
24
|
self.message = message
|
|
24
25
|
self.route = route
|
|
26
|
+
|
|
27
|
+
def json(self):
|
|
28
|
+
'''
|
|
29
|
+
Retorna o objeto em formato json.
|
|
30
|
+
'''
|
|
31
|
+
return json.dumps({
|
|
32
|
+
'type': 'message',
|
|
33
|
+
'message': self.message,
|
|
34
|
+
})
|
|
25
35
|
|
|
26
36
|
|
|
27
37
|
class RedirectResponse:
|
|
@@ -40,3 +50,50 @@ class RedirectResponse:
|
|
|
40
50
|
route (str): A rota para a qual o chatbot deve redirecionar.
|
|
41
51
|
"""
|
|
42
52
|
self.route = route
|
|
53
|
+
|
|
54
|
+
class EndChatResponse:
|
|
55
|
+
"""
|
|
56
|
+
Representa uma resposta que indica o fim do chatbot.
|
|
57
|
+
|
|
58
|
+
Atributos:
|
|
59
|
+
tabulation_id (str): O ID da tabulação do chatbot.
|
|
60
|
+
observations (str): As observações finais do chatbot.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
def __init__(self, tabulation_id: str, observations:str) -> None:
|
|
64
|
+
'''
|
|
65
|
+
Finzaliza e tabula as informações do chatbot.
|
|
66
|
+
'''
|
|
67
|
+
self.tabulation_id = tabulation_id
|
|
68
|
+
self.observations = observations
|
|
69
|
+
|
|
70
|
+
def json(self):
|
|
71
|
+
'''
|
|
72
|
+
Retorna o objeto em formato json.
|
|
73
|
+
'''
|
|
74
|
+
return json.dumps({
|
|
75
|
+
'type': 'tabulate',
|
|
76
|
+
'tabulation_id': self.tabulation_id,
|
|
77
|
+
'observations': self.observations,
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
class TransferToHuman:
|
|
81
|
+
"""
|
|
82
|
+
Representa uma transferencia para um atendente humano.
|
|
83
|
+
"""
|
|
84
|
+
def __init__(self, campaign_id: str, observations:str) -> None:
|
|
85
|
+
'''
|
|
86
|
+
Finzaliza e tabula as informações do chatbot.
|
|
87
|
+
'''
|
|
88
|
+
self.campaign_id = campaign_id
|
|
89
|
+
self.observations = observations
|
|
90
|
+
|
|
91
|
+
def json(self):
|
|
92
|
+
'''
|
|
93
|
+
Retorna o objeto em formato json.
|
|
94
|
+
'''
|
|
95
|
+
return json.dumps({
|
|
96
|
+
'type': 'transfer',
|
|
97
|
+
'campaign_id': self.campaign_id,
|
|
98
|
+
'observations': self.observations,
|
|
99
|
+
})
|
chatgraph/types/user_state.py
CHANGED
|
@@ -31,6 +31,16 @@ class UserState(ABC):
|
|
|
31
31
|
menu (str): O menu a ser definido para o cliente.
|
|
32
32
|
"""
|
|
33
33
|
pass
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def delete_menu(self, customer_id: str) -> None:
|
|
37
|
+
"""
|
|
38
|
+
Deleta o menu atual para o ID de cliente fornecido.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
customer_id (str): O ID do cliente.
|
|
42
|
+
"""
|
|
43
|
+
pass
|
|
34
44
|
|
|
35
45
|
|
|
36
46
|
class SimpleUserState(UserState):
|
|
@@ -72,3 +82,13 @@ class SimpleUserState(UserState):
|
|
|
72
82
|
"""
|
|
73
83
|
if menu:
|
|
74
84
|
self.states[customer_id] = menu.lower()
|
|
85
|
+
|
|
86
|
+
def delete_menu(self, customer_id: str) -> None:
|
|
87
|
+
"""
|
|
88
|
+
Deleta o menu atual para o ID de cliente fornecido.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
customer_id (str): O ID do cliente.
|
|
92
|
+
"""
|
|
93
|
+
if customer_id in self.states:
|
|
94
|
+
self.states.pop(customer_id)
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
chatgraph/__init__.py,sha256=qPA9Vw2SZivqVUlB19D-YrRuequMThR6kgO2XsZcwDc,602
|
|
2
2
|
chatgraph/auth/credentials.py,sha256=xsMEpLQnc66novPjL6upocMcnUnvFJ7yxINzUenkxmc,2388
|
|
3
|
-
chatgraph/bot/chatbot_model.py,sha256=
|
|
3
|
+
chatgraph/bot/chatbot_model.py,sha256=6tPoplS9nPHMYK0gSKFGq6cQr3dA2jOiBJTmQVuOb0I,6643
|
|
4
4
|
chatgraph/bot/chatbot_router.py,sha256=kZ_4X5AhhE2mntx4tcHiapaSKC1T4K1jqIVjLp1Pjg0,2817
|
|
5
5
|
chatgraph/error/chatbot_error.py,sha256=4sEcW8vz0eQk2QDmDygucVM4caHliZW5iH7XJvmLBuk,1897
|
|
6
6
|
chatgraph/error/route_error.py,sha256=CY8m82ap7-Sr-DXPsolltRW50TqD__5RyXBmNNJCWr8,793
|
|
7
7
|
chatgraph/messages/base_message_consumer.py,sha256=OSdTT4dHIzawLDOCZ-4hZ06T8UBxoJIosqvXl7gxpM0,1099
|
|
8
8
|
chatgraph/messages/rabbitMQ_message_consumer.py,sha256=mRcJ1Hbd5wPFxC3v6Tj3pYvjd9yAc398Ys6cUox-CTY,7005
|
|
9
|
+
chatgraph/messages/test_message_consumer.py,sha256=9XIkbCHd1S6S8pINRT-SLEvUT0TQWBCsdPhYN6PpZ2s,518
|
|
9
10
|
chatgraph/types/message_types.py,sha256=NBuebmpO2e9ilspBoFgs9O3rY_VQ2AP_Z8Q_nC70nyM,965
|
|
10
|
-
chatgraph/types/output_state.py,sha256=
|
|
11
|
+
chatgraph/types/output_state.py,sha256=fpJ_hGO4aZ3wr6DV4i9ctnkHytWhK6ZDpKpJ3vSwRyY,3064
|
|
11
12
|
chatgraph/types/route.py,sha256=nKTqzwGl7d_Bu8G6Sr0EmmhuuiZWKEoSozITRrdyi1g,2587
|
|
12
|
-
chatgraph/types/user_state.py,sha256=
|
|
13
|
-
chatgraph-0.1.
|
|
14
|
-
chatgraph-0.1.
|
|
15
|
-
chatgraph-0.1.
|
|
16
|
-
chatgraph-0.1.
|
|
13
|
+
chatgraph/types/user_state.py,sha256=B17bN300RW_9-WUbI7pWK_BUCvMbdpm6gLQHPqdGly4,2858
|
|
14
|
+
chatgraph-0.1.4.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
|
|
15
|
+
chatgraph-0.1.4.dist-info/METADATA,sha256=KQyN7GDztKsyFwUM4F_kF9eFE--Bi44ajc7AsaI6-Mg,5829
|
|
16
|
+
chatgraph-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
17
|
+
chatgraph-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|