chatgraph 0.4.0__py3-none-any.whl → 0.5.0__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/__init__.py +4 -3
- chatgraph/bot/chatbot_model.py +11 -8
- chatgraph/gRPC/gRPCCall.py +61 -145
- chatgraph/messages/message_consumer.py +74 -138
- chatgraph/pb/router.proto +127 -0
- chatgraph/pb/router_pb2.py +77 -0
- chatgraph/pb/router_pb2_grpc.py +669 -0
- chatgraph/types/message_types.py +79 -76
- chatgraph/types/request_types.py +182 -235
- chatgraph/types/route.py +7 -0
- {chatgraph-0.4.0.dist-info → chatgraph-0.5.0.dist-info}/METADATA +1 -1
- chatgraph-0.5.0.dist-info/RECORD +21 -0
- chatgraph/pb/userstate.proto +0 -41
- chatgraph/pb/userstate_pb2.py +0 -47
- chatgraph/pb/userstate_pb2_grpc.py +0 -269
- chatgraph/pb/voll.proto +0 -90
- chatgraph/pb/voll_pb2.py +0 -63
- chatgraph/pb/voll_pb2_grpc.py +0 -470
- chatgraph-0.4.0.dist-info/RECORD +0 -24
- {chatgraph-0.4.0.dist-info → chatgraph-0.5.0.dist-info}/LICENSE +0 -0
- {chatgraph-0.4.0.dist-info → chatgraph-0.5.0.dist-info}/WHEEL +0 -0
- {chatgraph-0.4.0.dist-info → chatgraph-0.5.0.dist-info}/entry_points.txt +0 -0
chatgraph/types/request_types.py
CHANGED
|
@@ -1,101 +1,129 @@
|
|
|
1
|
-
from chatgraph.gRPC.gRPCCall import
|
|
2
|
-
from chatgraph.types.message_types import Message, Button,
|
|
3
|
-
from dataclasses import dataclass
|
|
1
|
+
from chatgraph.gRPC.gRPCCall import RouterServiceClient
|
|
2
|
+
from chatgraph.types.message_types import Message, Button, MessageTypes, messageTypes
|
|
4
3
|
from typing import Optional
|
|
5
4
|
from datetime import datetime
|
|
6
5
|
import json, os
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
class ChatID:
|
|
9
|
+
"""
|
|
10
|
+
Representa o ID de um chat.
|
|
11
|
+
|
|
12
|
+
Atributos:
|
|
13
|
+
user_id (str): O ID do usuário.
|
|
14
|
+
company_id (str): O ID da empresa
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
user_id: str,
|
|
20
|
+
company_id: str,
|
|
21
|
+
):
|
|
22
|
+
self.user_id = user_id
|
|
23
|
+
self.company_id = company_id
|
|
24
|
+
|
|
25
|
+
def __str__(self):
|
|
26
|
+
return f"ChatID({self.user_id}, {self.company_id})"
|
|
27
|
+
|
|
28
|
+
def to_dict(self) -> dict:
|
|
29
|
+
return {
|
|
30
|
+
"user_id": self.user_id,
|
|
31
|
+
"company_id": self.company_id,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
9
35
|
class UserState:
|
|
10
36
|
"""
|
|
11
37
|
Representa o estado de um usuário.
|
|
12
|
-
|
|
38
|
+
|
|
13
39
|
Atributos:
|
|
14
|
-
|
|
40
|
+
chatID (ChatID): O ID do chat.
|
|
15
41
|
menu (str): O menu atual.
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
route (str): A rota atual.
|
|
43
|
+
protocol (str): O protocolo atual.
|
|
44
|
+
observations (dict): Observações do estado do usuário.
|
|
18
45
|
"""
|
|
46
|
+
|
|
19
47
|
def __init__(
|
|
20
48
|
self,
|
|
21
|
-
|
|
49
|
+
chatID: ChatID,
|
|
22
50
|
menu: str,
|
|
23
51
|
route: str,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
voll_id: Optional[str]=None,
|
|
27
|
-
lst_update: Optional[str]=None,
|
|
28
|
-
obs: Optional[dict] = None,
|
|
52
|
+
protocol: str,
|
|
53
|
+
observation: dict,
|
|
29
54
|
) -> None:
|
|
30
|
-
|
|
31
|
-
self.
|
|
55
|
+
|
|
56
|
+
self.chatID = chatID
|
|
32
57
|
self.menu = menu
|
|
33
58
|
self.route = route
|
|
34
|
-
self.
|
|
35
|
-
self.
|
|
36
|
-
self.direction_in = direction_in
|
|
37
|
-
self.voll_id = voll_id
|
|
38
|
-
self.platform = platform
|
|
59
|
+
self.observation = observation
|
|
60
|
+
self.protocol = protocol
|
|
39
61
|
|
|
40
62
|
def __str__(self):
|
|
41
|
-
return f"UserState
|
|
63
|
+
return f"UserState({self.chatID}, {self.menu}, {self.route}, {self.protocol}, {self.observation})"
|
|
64
|
+
|
|
65
|
+
def __chat_id_to_dict(self) -> dict:
|
|
66
|
+
return {
|
|
67
|
+
"user_id": self.chatID.user_id,
|
|
68
|
+
"company_id": self.chatID.company_id,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def __user_state_to_dict(self) -> dict:
|
|
72
|
+
return {
|
|
73
|
+
"chat_id": {
|
|
74
|
+
"user_id": self.chatID.user_id,
|
|
75
|
+
"company_id": self.chatID.company_id,
|
|
76
|
+
},
|
|
77
|
+
"menu": self.menu,
|
|
78
|
+
"route": self.route,
|
|
79
|
+
"protocol": self.protocol,
|
|
80
|
+
"observation": json.dumps(self.observation),
|
|
81
|
+
}
|
|
42
82
|
|
|
43
83
|
def insert(self, grpc_uri: Optional[str] = None) -> None:
|
|
44
84
|
if grpc_uri is None:
|
|
45
|
-
grpc_uri = os.getenv(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'obs': json.dumps(self.obs),
|
|
53
|
-
'direction': self.direction_in,
|
|
54
|
-
'voll_id': self.voll_id,
|
|
55
|
-
'platform': self.platform,
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
def update(self, grpc_uri: Optional[str] = None) -> None:
|
|
59
|
-
if grpc_uri is None:
|
|
60
|
-
grpc_uri = os.getenv('GRPC_URI')
|
|
61
|
-
user_state_client = UserStateServiceClient(grpc_uri)
|
|
62
|
-
|
|
63
|
-
user_state_client.update_user_state({
|
|
64
|
-
'user_id': self.customer_id,
|
|
65
|
-
'menu_id': self.menu,
|
|
66
|
-
'route': self.route,
|
|
67
|
-
'obs': json.dumps(self.obs),
|
|
68
|
-
})
|
|
69
|
-
|
|
85
|
+
grpc_uri = os.getenv("GRPC_URI")
|
|
86
|
+
router_client = RouterServiceClient(grpc_uri)
|
|
87
|
+
|
|
88
|
+
ustate = self.__user_state_to_dict()
|
|
89
|
+
result = router_client.insert_update_user_state(ustate)
|
|
90
|
+
return result
|
|
91
|
+
|
|
70
92
|
def delete(self, grpc_uri: Optional[str] = None) -> None:
|
|
71
93
|
if grpc_uri is None:
|
|
72
|
-
grpc_uri = os.getenv(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
grpc_uri = os.getenv("GRPC_URI")
|
|
95
|
+
router_client = RouterServiceClient(grpc_uri)
|
|
96
|
+
|
|
97
|
+
ustate = self.__user_state_to_dict()
|
|
98
|
+
response = router_client.delete_user_state(ustate["chat_id"])
|
|
99
|
+
return response
|
|
76
100
|
|
|
77
101
|
@classmethod
|
|
78
|
-
def get_user_state(
|
|
102
|
+
def get_user_state(
|
|
103
|
+
cls, user_id: str, company_id: str, grpc_uri: Optional[str] = None
|
|
104
|
+
) -> "UserState":
|
|
79
105
|
if grpc_uri is None:
|
|
80
|
-
grpc_uri = os.getenv(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
106
|
+
grpc_uri = os.getenv("GRPC_URI")
|
|
107
|
+
router_client = RouterServiceClient(grpc_uri)
|
|
108
|
+
|
|
109
|
+
chat_id = {"user_id": user_id, "company_id": company_id}
|
|
110
|
+
response = router_client.get_user_state(chat_id)
|
|
111
|
+
|
|
85
112
|
if not response:
|
|
86
113
|
raise ValueError("Erro ao buscar estado do usuário.")
|
|
87
|
-
|
|
88
|
-
date = datetime.strptime(response.date, "%Y-%m-%d %H:%M:%S")
|
|
114
|
+
|
|
89
115
|
return cls(
|
|
90
|
-
|
|
91
|
-
|
|
116
|
+
chatID=ChatID(
|
|
117
|
+
user_id=response.chat_id.user_id,
|
|
118
|
+
company_id=response.chat_id.company_id,
|
|
119
|
+
),
|
|
120
|
+
menu=response.menu,
|
|
92
121
|
route=response.route,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
voll_id=response.voll_id,
|
|
96
|
-
platform=response.platform,
|
|
97
|
-
lst_update=date,
|
|
122
|
+
protocol=response.protocol,
|
|
123
|
+
observation=json.loads(response.observation),
|
|
98
124
|
)
|
|
125
|
+
|
|
126
|
+
|
|
99
127
|
class UserCall:
|
|
100
128
|
"""
|
|
101
129
|
Representa uma mensagem recebida ou enviada pelo chatbot.
|
|
@@ -109,32 +137,31 @@ class UserCall:
|
|
|
109
137
|
company_phone (str): O número de telefone da empresa que está enviando ou recebendo a mensagem.
|
|
110
138
|
status (Optional[str]): O status da mensagem (por exemplo, enviada, recebida, lida, etc.). Este campo é opcional.
|
|
111
139
|
"""
|
|
140
|
+
|
|
112
141
|
def __init__(
|
|
113
142
|
self,
|
|
114
|
-
type: str,
|
|
115
|
-
text: str,
|
|
116
143
|
user_state: UserState,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
company_phone: str,
|
|
144
|
+
type_message: str,
|
|
145
|
+
content_message: str,
|
|
120
146
|
grpc_uri: str,
|
|
121
|
-
status: Optional[str] = None,
|
|
122
147
|
) -> None:
|
|
123
|
-
|
|
148
|
+
|
|
124
149
|
self.type = type
|
|
125
|
-
self.
|
|
150
|
+
self.__type_message = type_message
|
|
151
|
+
self.__content_message = content_message
|
|
126
152
|
self.__user_state = user_state
|
|
127
|
-
self.channel = channel
|
|
128
|
-
self.customer_phone = customer_phone
|
|
129
|
-
self.company_phone = company_phone
|
|
130
|
-
self.status = status
|
|
131
|
-
|
|
132
|
-
self.grpc_uri = grpc_uri
|
|
133
|
-
|
|
134
|
-
self.__wpp_server_client = WhatsappServiceClient(self.grpc_uri)
|
|
135
|
-
self.__user_state_client = UserStateServiceClient(self.grpc_uri)
|
|
136
153
|
|
|
137
|
-
|
|
154
|
+
self.__grpc_uri = grpc_uri
|
|
155
|
+
|
|
156
|
+
self.__router_client = RouterServiceClient(self.__grpc_uri)
|
|
157
|
+
|
|
158
|
+
def __str__(self):
|
|
159
|
+
return f"UserCall({self.type}, {self.__type_message}, {self.__content_message}, {self.__user_state})"
|
|
160
|
+
|
|
161
|
+
def send(
|
|
162
|
+
self,
|
|
163
|
+
message: messageTypes | Message,
|
|
164
|
+
) -> None:
|
|
138
165
|
"""
|
|
139
166
|
Envia uma mensagem ao cliente.
|
|
140
167
|
|
|
@@ -142,206 +169,126 @@ class UserCall:
|
|
|
142
169
|
message (Message|Button|ListElements): A mensagem a ser enviada.
|
|
143
170
|
"""
|
|
144
171
|
if isinstance(message, MessageTypes):
|
|
145
|
-
message = Message(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
self.__send_text(message.text, message.absolute_text)
|
|
149
|
-
|
|
150
|
-
elif isinstance(message, Button):
|
|
151
|
-
self.__send_button(
|
|
152
|
-
message.text,
|
|
153
|
-
message.buttons,
|
|
154
|
-
message.title,
|
|
155
|
-
message.caption
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
elif isinstance(message, ListElements):
|
|
159
|
-
self.__send_list(
|
|
160
|
-
text=message.text,
|
|
161
|
-
title=message.title,
|
|
162
|
-
button_title=message.button_title,
|
|
163
|
-
caption=message.caption,
|
|
164
|
-
element_list=message.elements,
|
|
172
|
+
message = Message(
|
|
173
|
+
type="message",
|
|
174
|
+
detail=str(message),
|
|
165
175
|
)
|
|
176
|
+
|
|
177
|
+
if isinstance(message, Message):
|
|
178
|
+
self.__send(message)
|
|
166
179
|
else:
|
|
167
180
|
raise ValueError("Tipo de mensagem inválido.")
|
|
168
|
-
|
|
169
|
-
def
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
response = self.
|
|
174
|
-
{
|
|
175
|
-
"hook_id": self.company_phone,
|
|
176
|
-
"enterprise_id": self.customer_phone,
|
|
177
|
-
"unique_customer_id": self.__user_state.voll_id,
|
|
178
|
-
"message_text": text,
|
|
179
|
-
"platform": self.channel,
|
|
180
|
-
}
|
|
181
|
-
)
|
|
181
|
+
|
|
182
|
+
def __send(self, message: Message) -> None:
|
|
183
|
+
|
|
184
|
+
dict_message = message.to_dict()
|
|
185
|
+
dict_message["chat_id"] = self.__user_state.chatID.to_dict()
|
|
186
|
+
response = self.__router_client.send_message(dict_message)
|
|
182
187
|
|
|
183
188
|
if not response.status:
|
|
184
189
|
raise ValueError("Erro ao enviar mensagem de texto.")
|
|
185
|
-
|
|
186
|
-
def __send_button(
|
|
187
|
-
self,
|
|
188
|
-
text:str,
|
|
189
|
-
buttons:list,
|
|
190
|
-
title: str|None = None,
|
|
191
|
-
caption: str|None = None,
|
|
192
|
-
) -> None:
|
|
193
|
-
if len(buttons) > 3:
|
|
194
|
-
raise ValueError("O número máximo de botões é 3.")
|
|
195
|
-
|
|
196
|
-
response = self.__wpp_server_client.send_button(
|
|
197
|
-
{
|
|
198
|
-
"hook_id": self.company_phone,
|
|
199
|
-
"enterprise_id": self.customer_phone,
|
|
200
|
-
"unique_customer_id": self.__user_state.voll_id,
|
|
201
|
-
"message_text": text,
|
|
202
|
-
"button_title": title,
|
|
203
|
-
"message_caption": caption,
|
|
204
|
-
"message_title": title,
|
|
205
|
-
"options": [{"title": b} for b in buttons],
|
|
206
|
-
}
|
|
207
|
-
)
|
|
208
190
|
|
|
209
191
|
if not response.status:
|
|
210
192
|
raise ValueError("Erro ao enviar mensagem de botões.")
|
|
211
193
|
|
|
212
|
-
def
|
|
213
|
-
self,
|
|
214
|
-
text:str,
|
|
215
|
-
button_title: str,
|
|
216
|
-
title: str|None = None,
|
|
217
|
-
element_list: list[dict] = None,
|
|
218
|
-
caption: str|None = None,
|
|
219
|
-
) -> None:
|
|
220
|
-
|
|
221
|
-
if not button_title:
|
|
222
|
-
raise NameError('Button Title é um parâmetro obrigatório!')
|
|
223
|
-
|
|
224
|
-
if len(element_list) > 20:
|
|
225
|
-
raise ValueError("O número máximo de elementos é 20.")
|
|
194
|
+
def transfer_to_human(self, message: str, campaign_name: str) -> None:
|
|
226
195
|
|
|
227
|
-
|
|
228
|
-
raise ValueError("O corpo da mensagem não pode ser vazio.")
|
|
229
|
-
|
|
196
|
+
campaign = self.__router_client.get_campaign_id({"name": campaign_name})
|
|
230
197
|
|
|
231
|
-
response = self.
|
|
198
|
+
response = self.__router_client.transfer_to_human(
|
|
232
199
|
{
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"unique_customer_id": self.__user_state.voll_id,
|
|
236
|
-
"message_text": text,
|
|
237
|
-
"button_title": button_title,
|
|
238
|
-
"message_caption": caption,
|
|
239
|
-
"message_title": title,
|
|
240
|
-
"options": [{"title": k, "description": v} for k,v in element_list.items()],
|
|
241
|
-
}
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
if not response.status:
|
|
245
|
-
raise ValueError("Erro ao enviar mensagem de lista.")
|
|
246
|
-
|
|
247
|
-
def transfer_to_human(self, message:str, campaign_name:str) -> None:
|
|
248
|
-
response = self.__wpp_server_client.transfer_to_human(
|
|
249
|
-
{
|
|
250
|
-
"hook_id": self.company_phone,
|
|
251
|
-
"enterprise_id": self.customer_phone,
|
|
252
|
-
"unique_customer_id": self.__user_state.customer_id,
|
|
253
|
-
"voll_id": self.__user_state.voll_id,
|
|
254
|
-
"message_text": message,
|
|
255
|
-
"platform": self.channel,
|
|
256
|
-
"campaign_name": campaign_name,
|
|
200
|
+
"chat_id": self.__user_state.chatID.to_dict(),
|
|
201
|
+
"campaign_id": campaign.id,
|
|
257
202
|
}
|
|
258
203
|
)
|
|
259
204
|
|
|
260
205
|
if not response.status:
|
|
261
206
|
raise ValueError("Erro ao transferir chat para humano.")
|
|
262
|
-
|
|
263
|
-
def end_chat(self, message:str, tabulation_name:str) -> None:
|
|
264
|
-
|
|
207
|
+
|
|
208
|
+
def end_chat(self, message: str, tabulation_name: str) -> None:
|
|
209
|
+
tabulation = self.__router_client.get_tabulation_id({"name": tabulation_name})
|
|
210
|
+
|
|
211
|
+
response = self.__router_client.end_chat(
|
|
265
212
|
{
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"unique_customer_id": self.__user_state.customer_id,
|
|
269
|
-
"voll_id": self.__user_state.voll_id,
|
|
270
|
-
"message_text": message,
|
|
271
|
-
"platform": self.channel,
|
|
213
|
+
"chat_id": self.__user_state.chatID.to_dict(),
|
|
214
|
+
"tabulation_id": tabulation.id,
|
|
272
215
|
}
|
|
273
216
|
)
|
|
274
217
|
|
|
275
218
|
if not response.status:
|
|
276
219
|
raise ValueError("Erro ao encerrar chat.")
|
|
277
|
-
|
|
220
|
+
|
|
278
221
|
def delete_user_state(self) -> None:
|
|
279
|
-
response = self.
|
|
222
|
+
response = self.__user_state.delete(self.__grpc_uri)
|
|
280
223
|
|
|
281
224
|
if not response.status:
|
|
282
225
|
raise ValueError("Erro ao deletar estado do usuário.")
|
|
283
226
|
|
|
284
227
|
def update_user_state(
|
|
285
|
-
self,
|
|
228
|
+
self,
|
|
286
229
|
menu: str,
|
|
287
230
|
route: str,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
response = self.__user_state_client.update_user_state({
|
|
292
|
-
"user_id": self.__user_state.customer_id,
|
|
293
|
-
"menu_id": menu,
|
|
294
|
-
"route": route,
|
|
295
|
-
"obs": json.dumps(obs),
|
|
296
|
-
})
|
|
231
|
+
observation: dict,
|
|
232
|
+
) -> None:
|
|
297
233
|
|
|
298
|
-
if not response.status:
|
|
299
|
-
raise ValueError("Erro ao atualizar estado do usuário.")
|
|
300
|
-
|
|
301
234
|
self.__user_state.menu = menu
|
|
302
235
|
self.__user_state.route = route
|
|
303
|
-
self.__user_state.
|
|
304
|
-
|
|
236
|
+
self.__user_state.observation = observation
|
|
237
|
+
self.__user_state.insert(self.__grpc_uri)
|
|
238
|
+
|
|
239
|
+
@property
|
|
240
|
+
def chatID(self):
|
|
241
|
+
return self.__user_state.chatID
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
def user_id(self):
|
|
245
|
+
return self.__user_state.chatID.user_id
|
|
246
|
+
|
|
247
|
+
@property
|
|
248
|
+
def company_id(self):
|
|
249
|
+
return self.__user_state.chatID.company_id
|
|
250
|
+
|
|
305
251
|
@property
|
|
306
252
|
def menu(self):
|
|
307
253
|
return self.__user_state.menu
|
|
308
|
-
|
|
254
|
+
|
|
309
255
|
@property
|
|
310
256
|
def route(self):
|
|
311
257
|
return self.__user_state.route
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def customer_id(self):
|
|
261
|
+
return self.__user_state.customer_id
|
|
262
|
+
|
|
263
|
+
@property
|
|
264
|
+
def protocol(self):
|
|
265
|
+
return self.__user_state.protocol
|
|
312
266
|
|
|
313
267
|
@property
|
|
314
|
-
def
|
|
315
|
-
return self.__user_state.
|
|
268
|
+
def observation(self):
|
|
269
|
+
return self.__user_state.observation
|
|
316
270
|
|
|
317
271
|
@property
|
|
318
|
-
def
|
|
319
|
-
return self.
|
|
272
|
+
def type_message(self):
|
|
273
|
+
return self.__type_message
|
|
320
274
|
|
|
275
|
+
@property
|
|
276
|
+
def content_message(self):
|
|
277
|
+
return self.__content_message
|
|
278
|
+
|
|
321
279
|
@menu.setter
|
|
322
280
|
def menu(self, menu):
|
|
323
|
-
|
|
324
|
-
self.update_user_state(
|
|
325
|
-
|
|
326
|
-
self.__user_state.route,
|
|
327
|
-
self.__user_state.obs
|
|
328
|
-
)
|
|
329
|
-
|
|
281
|
+
|
|
282
|
+
self.update_user_state(menu, self.__user_state.route, self.__user_state.observation)
|
|
283
|
+
|
|
330
284
|
@route.setter
|
|
331
285
|
def route(self, route):
|
|
332
|
-
|
|
333
|
-
self.update_user_state(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
@obs.setter
|
|
340
|
-
def obs(self, obs):
|
|
341
|
-
|
|
286
|
+
|
|
287
|
+
self.update_user_state(self.__user_state.menu, route, self.__user_state.observation)
|
|
288
|
+
|
|
289
|
+
@observation.setter
|
|
290
|
+
def observation(self, observation):
|
|
291
|
+
|
|
342
292
|
self.update_user_state(
|
|
343
|
-
self.__user_state.menu,
|
|
344
|
-
self.__user_state.route,
|
|
345
|
-
obs
|
|
293
|
+
self.__user_state.menu, self.__user_state.route, observation
|
|
346
294
|
)
|
|
347
|
-
|
chatgraph/types/route.py
CHANGED
|
@@ -30,6 +30,13 @@ class Route:
|
|
|
30
30
|
"""
|
|
31
31
|
return self.get_previous()
|
|
32
32
|
|
|
33
|
+
@property
|
|
34
|
+
def current_node(self)->str:
|
|
35
|
+
"""
|
|
36
|
+
Retorna o nó atual do usuário
|
|
37
|
+
"""
|
|
38
|
+
return self.current.split(self.separator)[-1]
|
|
39
|
+
|
|
33
40
|
def get_previous(self) -> 'Route':
|
|
34
41
|
"""
|
|
35
42
|
Retorna o caminho anterior ao caminho atual.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
chatgraph/__init__.py,sha256=SAMzqUOZCW8K0mvWns1zjQFimsiZijAMwuJrH_EG-2M,713
|
|
2
|
+
chatgraph/auth/credentials.py,sha256=xsMEpLQnc66novPjL6upocMcnUnvFJ7yxINzUenkxmc,2388
|
|
3
|
+
chatgraph/bot/chatbot_model.py,sha256=GGeU-LZYqR7zhrP-B5gRloJi31_7Vmk7--H9bGKvcto,6826
|
|
4
|
+
chatgraph/bot/chatbot_router.py,sha256=bVbm9dBoC2OesetXlQJpCrkaiLM3GUro0GrOyCSgreI,2586
|
|
5
|
+
chatgraph/cli/__init__.py,sha256=tfgYhGoKy1nD4STN4xDh6J4VV55RICk7v1GZmzAg-bM,7413
|
|
6
|
+
chatgraph/error/chatbot_error.py,sha256=4sEcW8vz0eQk2QDmDygucVM4caHliZW5iH7XJvmLBuk,1897
|
|
7
|
+
chatgraph/error/route_error.py,sha256=CY8m82ap7-Sr-DXPsolltRW50TqD__5RyXBmNNJCWr8,793
|
|
8
|
+
chatgraph/gRPC/gRPCCall.py,sha256=8rxs_tGPY5UeP0dnoqL8zhTZ7XqJLOJcewlK8yB8Q_E,4669
|
|
9
|
+
chatgraph/messages/message_consumer.py,sha256=yHhfLYjtmXQYG44o7SNO6XUaeM4-jH8BpIpPHI-mt8Y,6116
|
|
10
|
+
chatgraph/pb/router.proto,sha256=pw3hTwjdMN8-yJIAlKHNigVKYqM-w2nme9-2bCTBiJ0,2853
|
|
11
|
+
chatgraph/pb/router_pb2.py,sha256=jw-Rg05NMwgOKrRsoubFFb82v_O80KgWY4tIqwUf2Aw,6571
|
|
12
|
+
chatgraph/pb/router_pb2_grpc.py,sha256=KxhVxCMVD9tpuX7CyXqIkzZ4P3zfXeVT92Bt_Hi7mrE,24109
|
|
13
|
+
chatgraph/types/end_types.py,sha256=--Ty2gM_y7J-yRAvZV26e4HMUpoguAMAhfOIS9-kQTk,1316
|
|
14
|
+
chatgraph/types/message_types.py,sha256=NM0kjiajKnZd-Yr56Stehdpr18xc857FZW8TzmqgUmU,3369
|
|
15
|
+
chatgraph/types/request_types.py,sha256=BeUI2l9XZpBf5c8xyPvKI68WZ5u6n98cC8DmUfWKlQ0,8788
|
|
16
|
+
chatgraph/types/route.py,sha256=FO5INy5UXgicuQ8FKEZKcPv6WS5YH10dPx2OaPu_0sE,2978
|
|
17
|
+
chatgraph-0.5.0.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
|
|
18
|
+
chatgraph-0.5.0.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
|
|
19
|
+
chatgraph-0.5.0.dist-info/METADATA,sha256=dDJI_cTfs7Ayhshv6VB7xTvP3aV3uN694bxMD6se65Y,12866
|
|
20
|
+
chatgraph-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
21
|
+
chatgraph-0.5.0.dist-info/RECORD,,
|
chatgraph/pb/userstate.proto
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package userstate;
|
|
4
|
-
|
|
5
|
-
option go_package = "./pb/userstate";
|
|
6
|
-
|
|
7
|
-
service UserStateService {
|
|
8
|
-
rpc SelectUserState(UserStateId) returns (UserState);
|
|
9
|
-
rpc InsertUserState(UserState) returns (RequestStatus);
|
|
10
|
-
rpc UpdateUserState(UserState) returns (RequestStatus);
|
|
11
|
-
rpc DeleteUserState(UserStateId) returns (RequestStatus);
|
|
12
|
-
|
|
13
|
-
rpc GetAllUserStates(Void) returns (UserStatesList);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
message Void {
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
message UserState {
|
|
20
|
-
string user_id = 1;
|
|
21
|
-
string menu_id = 2;
|
|
22
|
-
string route = 3;
|
|
23
|
-
string obs = 4;
|
|
24
|
-
string date = 5;
|
|
25
|
-
bool direction = 6;
|
|
26
|
-
string voll_id = 7;
|
|
27
|
-
string platform = 8;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
message UserStateId {
|
|
31
|
-
string user_id = 1;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
message RequestStatus {
|
|
35
|
-
bool status = 1;
|
|
36
|
-
string message = 2;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
message UserStatesList {
|
|
40
|
-
repeated UserState user_states = 1;
|
|
41
|
-
}
|
chatgraph/pb/userstate_pb2.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
-
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
-
# source: userstate.proto
|
|
5
|
-
# Protobuf Python Version: 5.27.2
|
|
6
|
-
"""Generated protocol buffer code."""
|
|
7
|
-
from google.protobuf import descriptor as _descriptor
|
|
8
|
-
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
-
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
-
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
-
from google.protobuf.internal import builder as _builder
|
|
12
|
-
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
-
_runtime_version.Domain.PUBLIC,
|
|
14
|
-
5,
|
|
15
|
-
27,
|
|
16
|
-
2,
|
|
17
|
-
'',
|
|
18
|
-
'userstate.proto'
|
|
19
|
-
)
|
|
20
|
-
# @@protoc_insertion_point(imports)
|
|
21
|
-
|
|
22
|
-
_sym_db = _symbol_database.Default()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fuserstate.proto\x12\tuserstate\"\x06\n\x04Void\"\x8d\x01\n\tUserState\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12\x0f\n\x07menu_id\x18\x02 \x01(\t\x12\r\n\x05route\x18\x03 \x01(\t\x12\x0b\n\x03obs\x18\x04 \x01(\t\x12\x0c\n\x04\x64\x61te\x18\x05 \x01(\t\x12\x11\n\tdirection\x18\x06 \x01(\x08\x12\x0f\n\x07voll_id\x18\x07 \x01(\t\x12\x10\n\x08platform\x18\x08 \x01(\t\"\x1e\n\x0bUserStateId\x12\x0f\n\x07user_id\x18\x01 \x01(\t\"0\n\rRequestStatus\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\";\n\x0eUserStatesList\x12)\n\x0buser_states\x18\x01 \x03(\x0b\x32\x14.userstate.UserState2\xde\x02\n\x10UserStateService\x12?\n\x0fSelectUserState\x12\x16.userstate.UserStateId\x1a\x14.userstate.UserState\x12\x41\n\x0fInsertUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x41\n\x0fUpdateUserState\x12\x14.userstate.UserState\x1a\x18.userstate.RequestStatus\x12\x43\n\x0f\x44\x65leteUserState\x12\x16.userstate.UserStateId\x1a\x18.userstate.RequestStatus\x12>\n\x10GetAllUserStates\x12\x0f.userstate.Void\x1a\x19.userstate.UserStatesListB\x10Z\x0e./pb/userstateb\x06proto3')
|
|
28
|
-
|
|
29
|
-
_globals = globals()
|
|
30
|
-
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
-
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'userstate_pb2', _globals)
|
|
32
|
-
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
-
_globals['DESCRIPTOR']._loaded_options = None
|
|
34
|
-
_globals['DESCRIPTOR']._serialized_options = b'Z\016./pb/userstate'
|
|
35
|
-
_globals['_VOID']._serialized_start=30
|
|
36
|
-
_globals['_VOID']._serialized_end=36
|
|
37
|
-
_globals['_USERSTATE']._serialized_start=39
|
|
38
|
-
_globals['_USERSTATE']._serialized_end=180
|
|
39
|
-
_globals['_USERSTATEID']._serialized_start=182
|
|
40
|
-
_globals['_USERSTATEID']._serialized_end=212
|
|
41
|
-
_globals['_REQUESTSTATUS']._serialized_start=214
|
|
42
|
-
_globals['_REQUESTSTATUS']._serialized_end=262
|
|
43
|
-
_globals['_USERSTATESLIST']._serialized_start=264
|
|
44
|
-
_globals['_USERSTATESLIST']._serialized_end=323
|
|
45
|
-
_globals['_USERSTATESERVICE']._serialized_start=326
|
|
46
|
-
_globals['_USERSTATESERVICE']._serialized_end=676
|
|
47
|
-
# @@protoc_insertion_point(module_scope)
|