chatgraph 0.2.0__py3-none-any.whl → 0.2.3__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 +13 -4
- chatgraph/types/output_state.py +6 -6
- {chatgraph-0.2.0.dist-info → chatgraph-0.2.3.dist-info}/METADATA +1 -1
- {chatgraph-0.2.0.dist-info → chatgraph-0.2.3.dist-info}/RECORD +6 -6
- {chatgraph-0.2.0.dist-info → chatgraph-0.2.3.dist-info}/LICENSE +0 -0
- {chatgraph-0.2.0.dist-info → chatgraph-0.2.3.dist-info}/WHEEL +0 -0
chatgraph/bot/chatbot_model.py
CHANGED
|
@@ -2,6 +2,7 @@ import inspect
|
|
|
2
2
|
from abc import ABC
|
|
3
3
|
from functools import wraps
|
|
4
4
|
from logging import debug
|
|
5
|
+
import json
|
|
5
6
|
|
|
6
7
|
from ..error.chatbot_error import ChatbotError, ChatbotMessageError
|
|
7
8
|
from ..messages.base_message_consumer import MessageConsumer
|
|
@@ -113,8 +114,8 @@ class ChatbotApp(ABC):
|
|
|
113
114
|
Returns:
|
|
114
115
|
str: A resposta gerada pela função da rota, que pode ser uma mensagem ou o resultado de uma redireção.
|
|
115
116
|
"""
|
|
116
|
-
customer_id = message.customer_id
|
|
117
|
-
|
|
117
|
+
customer_id = message.user_state.customer_id
|
|
118
|
+
user_state = message.user_state
|
|
118
119
|
menu = message.user_state.menu
|
|
119
120
|
menu = menu.lower()
|
|
120
121
|
handler = self.__routes.get(menu, None)
|
|
@@ -138,9 +139,17 @@ class ChatbotApp(ABC):
|
|
|
138
139
|
if type(message_response) in (str, float, int):
|
|
139
140
|
response = ChatbotResponse(message_response)
|
|
140
141
|
return response.json()
|
|
142
|
+
elif type(message_response) == ChatbotResponse:
|
|
143
|
+
route = self.__adjust_route(message_response.route, menu)
|
|
144
|
+
response = message_response.json()
|
|
145
|
+
response['user_state'] = {
|
|
146
|
+
'customer_id': customer_id,
|
|
147
|
+
'menu': route,
|
|
148
|
+
'obs': user_state.obs,
|
|
149
|
+
}
|
|
150
|
+
return json.dumps(response)
|
|
141
151
|
elif type(message_response) in (ChatbotResponse, EndChatResponse, TransferToHuman):
|
|
142
|
-
|
|
143
|
-
return message_response.json()
|
|
152
|
+
return json.dumps(message_response.json())
|
|
144
153
|
elif type(message_response) == RedirectResponse:
|
|
145
154
|
route = self.__adjust_route(message_response.route, menu)
|
|
146
155
|
message.user_state.menu = route
|
chatgraph/types/output_state.py
CHANGED
|
@@ -28,10 +28,10 @@ class ChatbotResponse:
|
|
|
28
28
|
'''
|
|
29
29
|
Retorna o objeto em formato json.
|
|
30
30
|
'''
|
|
31
|
-
return
|
|
31
|
+
return {
|
|
32
32
|
'type': 'message',
|
|
33
33
|
'message': self.message,
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class RedirectResponse:
|
|
@@ -71,11 +71,11 @@ class EndChatResponse:
|
|
|
71
71
|
'''
|
|
72
72
|
Retorna o objeto em formato json.
|
|
73
73
|
'''
|
|
74
|
-
return
|
|
74
|
+
return {
|
|
75
75
|
'type': 'tabulate',
|
|
76
76
|
'tabulation_id': self.tabulation_id,
|
|
77
77
|
'observations': self.observations,
|
|
78
|
-
}
|
|
78
|
+
}
|
|
79
79
|
|
|
80
80
|
class TransferToHuman:
|
|
81
81
|
"""
|
|
@@ -92,8 +92,8 @@ class TransferToHuman:
|
|
|
92
92
|
'''
|
|
93
93
|
Retorna o objeto em formato json.
|
|
94
94
|
'''
|
|
95
|
-
return
|
|
95
|
+
return {
|
|
96
96
|
'type': 'transfer',
|
|
97
97
|
'campaign_id': self.campaign_id,
|
|
98
98
|
'observations': self.observations,
|
|
99
|
-
}
|
|
99
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
chatgraph/__init__.py,sha256=6pDNMUOLR8iFK_3mWula1IJQcIoE8io-65mS_QheXXE,642
|
|
2
2
|
chatgraph/auth/credentials.py,sha256=xsMEpLQnc66novPjL6upocMcnUnvFJ7yxINzUenkxmc,2388
|
|
3
|
-
chatgraph/bot/chatbot_model.py,sha256=
|
|
3
|
+
chatgraph/bot/chatbot_model.py,sha256=9EPl6XJKNlu5eZHTnZylSXHu_ANyeUkeSsksSkWyAyI,6498
|
|
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
|
|
@@ -8,10 +8,10 @@ chatgraph/messages/base_message_consumer.py,sha256=OSdTT4dHIzawLDOCZ-4hZ06T8UBxo
|
|
|
8
8
|
chatgraph/messages/rabbitMQ_message_consumer.py,sha256=HoVS79PMXfkh0QHsZ7Zj7XuPLwEMnDXpR_9NJU78lqc,7222
|
|
9
9
|
chatgraph/messages/test_message_consumer.py,sha256=9XIkbCHd1S6S8pINRT-SLEvUT0TQWBCsdPhYN6PpZ2s,518
|
|
10
10
|
chatgraph/types/message_types.py,sha256=7eB45hrlbYKV1Lp9vysR6V7OXNsySpeKYbGBc2Ux6xE,1363
|
|
11
|
-
chatgraph/types/output_state.py,sha256=
|
|
11
|
+
chatgraph/types/output_state.py,sha256=C8kNy3bqSKBW3jAF-37Jrph-1Kqw08cY5dS3_bo3czA,3028
|
|
12
12
|
chatgraph/types/route.py,sha256=nKTqzwGl7d_Bu8G6Sr0EmmhuuiZWKEoSozITRrdyi1g,2587
|
|
13
13
|
chatgraph/types/user_state.py,sha256=nliV-kC_yOmYoFh8CQSfT92DbOv4BLF0vvn8kotnDog,2884
|
|
14
|
-
chatgraph-0.2.
|
|
15
|
-
chatgraph-0.2.
|
|
16
|
-
chatgraph-0.2.
|
|
17
|
-
chatgraph-0.2.
|
|
14
|
+
chatgraph-0.2.3.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
|
|
15
|
+
chatgraph-0.2.3.dist-info/METADATA,sha256=C5mhEHmgEPYBv3opwU6XKObWHwhv0rB6kYMbRJn2DHU,5829
|
|
16
|
+
chatgraph-0.2.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
17
|
+
chatgraph-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|