chatgraph 0.5.2__tar.gz → 0.6.0__tar.gz

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.

Files changed (26) hide show
  1. {chatgraph-0.5.2 → chatgraph-0.6.0}/PKG-INFO +2 -1
  2. chatgraph-0.6.0/chatgraph/__init__.py +36 -0
  3. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/bot/chatbot_model.py +22 -1
  4. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/gRPC/gRPCCall.py +17 -3
  5. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/pb/router.proto +17 -0
  6. chatgraph-0.6.0/chatgraph/pb/router_pb2.py +81 -0
  7. chatgraph-0.6.0/chatgraph/pb/router_pb2_grpc.py +855 -0
  8. chatgraph-0.6.0/chatgraph/types/background_task.py +27 -0
  9. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/types/end_types.py +22 -8
  10. chatgraph-0.6.0/chatgraph/types/image.py +36 -0
  11. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/types/request_types.py +45 -9
  12. {chatgraph-0.5.2 → chatgraph-0.6.0}/pyproject.toml +2 -1
  13. chatgraph-0.5.2/chatgraph/__init__.py +0 -27
  14. chatgraph-0.5.2/chatgraph/pb/router_pb2.py +0 -77
  15. chatgraph-0.5.2/chatgraph/pb/router_pb2_grpc.py +0 -669
  16. chatgraph-0.5.2/chatgraph/types/background_task.py +0 -23
  17. {chatgraph-0.5.2 → chatgraph-0.6.0}/LICENSE +0 -0
  18. {chatgraph-0.5.2 → chatgraph-0.6.0}/README.md +0 -0
  19. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/auth/credentials.py +0 -0
  20. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/bot/chatbot_router.py +0 -0
  21. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/cli/__init__.py +0 -0
  22. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/error/chatbot_error.py +0 -0
  23. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/error/route_error.py +0 -0
  24. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/messages/message_consumer.py +0 -0
  25. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/types/message_types.py +0 -0
  26. {chatgraph-0.5.2 → chatgraph-0.6.0}/chatgraph/types/route.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgraph
3
- Version: 0.5.2
3
+ Version: 0.6.0
4
4
  Summary: A user-friendly chatbot library
5
5
  Home-page: https://github.com/irissonnlima/chatgraph
6
6
  License: MIT
@@ -16,6 +16,7 @@ Requires-Dist: grpcio-tools (>=1.67.0,<2.0.0)
16
16
  Requires-Dist: matplotlib (>=3.10.0,<4.0.0)
17
17
  Requires-Dist: networkx (>=3.4.2,<4.0.0)
18
18
  Requires-Dist: pika (>=1.3.2,<2.0.0)
19
+ Requires-Dist: protobuf (>=6.31.1,<7.0.0)
19
20
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
20
21
  Requires-Dist: rich (>=13.8.1,<14.0.0)
21
22
  Requires-Dist: typer (>=0.12.5,<0.13.0)
@@ -0,0 +1,36 @@
1
+ from .auth.credentials import Credential
2
+ from .bot.chatbot_model import ChatbotApp
3
+ from .bot.chatbot_router import ChatbotRouter
4
+ from .messages.message_consumer import MessageConsumer
5
+ from .types.request_types import UserCall, UserState, ChatID
6
+ from .types.end_types import (
7
+ RedirectResponse,
8
+ EndChatResponse,
9
+ TransferToHuman,
10
+ TransferToMenu,
11
+ )
12
+ from .types.message_types import Message, Button
13
+ from .types.route import Route
14
+ from .types.background_task import BackgroundTask
15
+ from .types.image import ImageData, SendImage
16
+
17
+ __all__ = [
18
+ "ChatbotApp",
19
+ "Credential",
20
+ "UserCall",
21
+ "ChatbotRouter",
22
+ "ChatbotResponse",
23
+ "RedirectResponse",
24
+ "MessageConsumer",
25
+ "Route",
26
+ "EndChatResponse",
27
+ "TransferToHuman",
28
+ "TransferToMenu",
29
+ "ChatID",
30
+ "UserState",
31
+ "Message",
32
+ "Button",
33
+ "BackgroundTask",
34
+ "ImageData",
35
+ "SendImage",
36
+ ]
@@ -7,9 +7,15 @@ from ..error.chatbot_error import ChatbotMessageError
7
7
  from ..messages.message_consumer import MessageConsumer
8
8
  from ..types.request_types import UserCall
9
9
  from ..types.message_types import Message, Button
10
- from ..types.end_types import RedirectResponse, EndChatResponse, TransferToHuman
10
+ from ..types.end_types import (
11
+ RedirectResponse,
12
+ EndChatResponse,
13
+ TransferToHuman,
14
+ TransferToMenu,
15
+ )
11
16
  from ..types.route import Route
12
17
  from .chatbot_router import ChatbotRouter
18
+ from ..types.background_task import BackgroundTask
13
19
 
14
20
 
15
21
  class ChatbotApp:
@@ -172,14 +178,29 @@ class ChatbotApp:
172
178
  )
173
179
  return
174
180
 
181
+ elif isinstance(userCall_response, TransferToMenu):
182
+ await loop.run_in_executor(
183
+ None,
184
+ userCall.transfer_to_menu,
185
+ userCall_response.menu,
186
+ userCall_response.user_message,
187
+ )
188
+ return
189
+
175
190
  elif isinstance(userCall_response, RedirectResponse):
176
191
  route = route + "." + userCall_response.route
177
192
  userCall.route = route
178
193
  await self.process_message(userCall)
179
194
 
180
195
  elif not userCall_response:
196
+ route = route + "." + route.split(".")[-1]
197
+ userCall.route = route
181
198
  return
182
199
 
200
+ elif isinstance(userCall_response, BackgroundTask):
201
+ response = await userCall_response.run()
202
+ await self.__process_func_response(response, userCall, route=route)
203
+
183
204
  else:
184
205
  error("Tipo de retorno inválido!")
185
206
  return None
@@ -55,9 +55,9 @@ class RouterServiceClient:
55
55
 
56
56
  def send_message(self, message_data):
57
57
  # print(json.dumps(message_data))
58
-
58
+
59
59
  request = chatbot_pb2.Message(**message_data)
60
-
60
+
61
61
  try:
62
62
  response = self.send_message_stub.SendMessage(request)
63
63
  if not response.status:
@@ -67,6 +67,20 @@ class RouterServiceClient:
67
67
  print(f"Erro ao chamar SendMessage: {e}")
68
68
  return None
69
69
 
70
+ def send_image(self, message_data):
71
+ # print(json.dumps(message_data))
72
+
73
+ request = chatbot_pb2.FileMessage(**message_data)
74
+
75
+ try:
76
+ response = self.send_message_stub.SendImage(request)
77
+ if not response.status:
78
+ print(f"Erro ao chamar SendImage: {response.message}")
79
+ return response
80
+ except grpc.RpcError as e:
81
+ print(f"Erro ao chamar SendImage: {e}")
82
+ return None
83
+
70
84
  def transfer_to_human(self, transfer_request_data):
71
85
  request = chatbot_pb2.TransferToHumanRequest(**transfer_request_data)
72
86
  try:
@@ -83,7 +97,7 @@ class RouterServiceClient:
83
97
  try:
84
98
  response = self.transfer_stub.TransferToMenu(request)
85
99
  if not response.status:
86
- print(f"Erro ao chamar SendMessage: {response.message}")
100
+ print(f"Erro ao chamar TransferToMenu: {response.message}")
87
101
  return response
88
102
  except grpc.RpcError as e:
89
103
  print(f"Erro ao chamar TransferToMenu: {e}")
@@ -15,6 +15,9 @@ service UserStateService {
15
15
  ///// Serviços de Mensagens /////
16
16
  service SendMessage {
17
17
  rpc SendMessage(Message) returns (RequestStatus);
18
+ rpc SendImage(FileMessage) returns (RequestStatus);
19
+ rpc SendFile(FileMessage) returns (RequestStatus);
20
+ rpc UploadFile(UploadFileRequest) returns (RequestStatus);
18
21
  }
19
22
 
20
23
  ///// Serviços de Transfer /////
@@ -80,10 +83,23 @@ message Message {
80
83
  Button display_button = 4;
81
84
  }
82
85
 
86
+ message FileMessage {
87
+ Message message = 1;
88
+ string file_id = 2;
89
+ }
90
+
91
+ message UploadFileRequest {
92
+ string file_id = 1;
93
+ string file_url = 2;
94
+ string file_type = 3;
95
+ bytes file_content = 4;
96
+ }
97
+
83
98
  ///// Mensagens para Serviços de Transfer /////
84
99
  message TransferToHumanRequest{
85
100
  ChatID chat_id = 1;
86
101
  string campaign_id = 2;
102
+ string observation = 3;
87
103
  }
88
104
 
89
105
  message TransferToMenuRequest{
@@ -110,6 +126,7 @@ message TabulationsList{
110
126
  message EndChatRequest {
111
127
  ChatID chat_id = 1;
112
128
  string tabulation_id = 2;
129
+ string observation = 3;
113
130
  }
114
131
 
115
132
  message CampaignName {
@@ -0,0 +1,81 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: router.proto
5
+ # Protobuf Python Version: 6.31.0
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
+ 6,
15
+ 31,
16
+ 0,
17
+ '',
18
+ 'router.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\x0crouter.proto\x12\x07\x63hatbot\"\x06\n\x04Void\"0\n\rRequestStatus\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\"-\n\x06\x43hatID\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12\x12\n\ncompany_id\x18\x02 \x01(\t\"q\n\tUserState\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x0c\n\x04menu\x18\x02 \x01(\t\x12\r\n\x05route\x18\x03 \x01(\t\x12\x10\n\x08protocol\x18\x04 \x01(\t\x12\x13\n\x0bobservation\x18\x05 \x01(\t\"8\n\rUserStateList\x12\'\n\x0buser_states\x18\x01 \x03(\x0b\x32\x12.chatbot.UserState\"j\n\x0bTextMessage\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t\x12\r\n\x05title\x18\x04 \x01(\t\x12\x0e\n\x06\x64\x65tail\x18\x05 \x01(\t\x12\x0f\n\x07\x63\x61ption\x18\x06 \x01(\t\"5\n\x06\x42utton\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\r\n\x05title\x18\x02 \x01(\t\x12\x0e\n\x06\x64\x65tail\x18\x03 \x01(\t\"\x9d\x01\n\x07Message\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12%\n\x07message\x18\x02 \x01(\x0b\x32\x14.chatbot.TextMessage\x12 \n\x07\x62uttons\x18\x03 \x03(\x0b\x32\x0f.chatbot.Button\x12\'\n\x0e\x64isplay_button\x18\x04 \x01(\x0b\x32\x0f.chatbot.Button\"A\n\x0b\x46ileMessage\x12!\n\x07message\x18\x01 \x01(\x0b\x32\x10.chatbot.Message\x12\x0f\n\x07\x66ile_id\x18\x02 \x01(\t\"_\n\x11UploadFileRequest\x12\x0f\n\x07\x66ile_id\x18\x01 \x01(\t\x12\x10\n\x08\x66ile_url\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x14\n\x0c\x66ile_content\x18\x04 \x01(\x0c\"d\n\x16TransferToHumanRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x13\n\x0b\x63\x61mpaign_id\x18\x02 \x01(\t\x12\x13\n\x0bobservation\x18\x03 \x01(\t\"]\n\x15TransferToMenuRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x0c\n\x04menu\x18\x02 \x01(\t\x12\x14\n\x0cuser_message\x18\x03 \x01(\t\"\x1e\n\x0eTabulationName\x12\x0c\n\x04name\x18\x01 \x01(\t\"B\n\x11TabulationDetails\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0blast_update\x18\x03 \x01(\t\"B\n\x0fTabulationsList\x12/\n\x0btabulations\x18\x01 \x03(\x0b\x32\x1a.chatbot.TabulationDetails\"^\n\x0e\x45ndChatRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x15\n\rtabulation_id\x18\x02 \x01(\t\x12\x13\n\x0bobservation\x18\x03 \x01(\t\"\x1c\n\x0c\x43\x61mpaignName\x12\x0c\n\x04name\x18\x01 \x01(\t\"@\n\x0f\x43\x61mpaignDetails\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0blast_update\x18\x03 \x01(\t\"<\n\rCampaignsList\x12+\n\tcampaigns\x18\x01 \x03(\x0b\x32\x18.chatbot.CampaignDetails2\x83\x02\n\x10UserStateService\x12\x43\n\x15InsertUpdateUserState\x12\x12.chatbot.UserState\x1a\x16.chatbot.RequestStatus\x12:\n\x0f\x44\x65leteUserState\x12\x0f.chatbot.ChatID\x1a\x16.chatbot.RequestStatus\x12\x33\n\x0cGetUserState\x12\x0f.chatbot.ChatID\x1a\x12.chatbot.UserState\x12\x39\n\x10GetAllUserStates\x12\r.chatbot.Void\x1a\x16.chatbot.UserStateList2\xfd\x01\n\x0bSendMessage\x12\x37\n\x0bSendMessage\x12\x10.chatbot.Message\x1a\x16.chatbot.RequestStatus\x12\x39\n\tSendImage\x12\x14.chatbot.FileMessage\x1a\x16.chatbot.RequestStatus\x12\x38\n\x08SendFile\x12\x14.chatbot.FileMessage\x1a\x16.chatbot.RequestStatus\x12@\n\nUploadFile\x12\x1a.chatbot.UploadFileRequest\x1a\x16.chatbot.RequestStatus2\x9c\x02\n\x08Transfer\x12\x38\n\x0fGetAllCampaigns\x12\r.chatbot.Void\x1a\x16.chatbot.CampaignsList\x12@\n\rGetCampaignID\x12\x15.chatbot.CampaignName\x1a\x18.chatbot.CampaignDetails\x12J\n\x0fTransferToHuman\x12\x1f.chatbot.TransferToHumanRequest\x1a\x16.chatbot.RequestStatus\x12H\n\x0eTransferToMenu\x12\x1e.chatbot.TransferToMenuRequest\x1a\x16.chatbot.RequestStatus2\xcb\x01\n\x07\x45ndChat\x12<\n\x11GetAllTabulations\x12\r.chatbot.Void\x1a\x18.chatbot.TabulationsList\x12\x46\n\x0fGetTabulationID\x12\x17.chatbot.TabulationName\x1a\x1a.chatbot.TabulationDetails\x12:\n\x07\x45ndChat\x12\x17.chatbot.EndChatRequest\x1a\x16.chatbot.RequestStatusB\x0bZ\t./chatbotb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'router_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'Z\t./chatbot'
35
+ _globals['_VOID']._serialized_start=25
36
+ _globals['_VOID']._serialized_end=31
37
+ _globals['_REQUESTSTATUS']._serialized_start=33
38
+ _globals['_REQUESTSTATUS']._serialized_end=81
39
+ _globals['_CHATID']._serialized_start=83
40
+ _globals['_CHATID']._serialized_end=128
41
+ _globals['_USERSTATE']._serialized_start=130
42
+ _globals['_USERSTATE']._serialized_end=243
43
+ _globals['_USERSTATELIST']._serialized_start=245
44
+ _globals['_USERSTATELIST']._serialized_end=301
45
+ _globals['_TEXTMESSAGE']._serialized_start=303
46
+ _globals['_TEXTMESSAGE']._serialized_end=409
47
+ _globals['_BUTTON']._serialized_start=411
48
+ _globals['_BUTTON']._serialized_end=464
49
+ _globals['_MESSAGE']._serialized_start=467
50
+ _globals['_MESSAGE']._serialized_end=624
51
+ _globals['_FILEMESSAGE']._serialized_start=626
52
+ _globals['_FILEMESSAGE']._serialized_end=691
53
+ _globals['_UPLOADFILEREQUEST']._serialized_start=693
54
+ _globals['_UPLOADFILEREQUEST']._serialized_end=788
55
+ _globals['_TRANSFERTOHUMANREQUEST']._serialized_start=790
56
+ _globals['_TRANSFERTOHUMANREQUEST']._serialized_end=890
57
+ _globals['_TRANSFERTOMENUREQUEST']._serialized_start=892
58
+ _globals['_TRANSFERTOMENUREQUEST']._serialized_end=985
59
+ _globals['_TABULATIONNAME']._serialized_start=987
60
+ _globals['_TABULATIONNAME']._serialized_end=1017
61
+ _globals['_TABULATIONDETAILS']._serialized_start=1019
62
+ _globals['_TABULATIONDETAILS']._serialized_end=1085
63
+ _globals['_TABULATIONSLIST']._serialized_start=1087
64
+ _globals['_TABULATIONSLIST']._serialized_end=1153
65
+ _globals['_ENDCHATREQUEST']._serialized_start=1155
66
+ _globals['_ENDCHATREQUEST']._serialized_end=1249
67
+ _globals['_CAMPAIGNNAME']._serialized_start=1251
68
+ _globals['_CAMPAIGNNAME']._serialized_end=1279
69
+ _globals['_CAMPAIGNDETAILS']._serialized_start=1281
70
+ _globals['_CAMPAIGNDETAILS']._serialized_end=1345
71
+ _globals['_CAMPAIGNSLIST']._serialized_start=1347
72
+ _globals['_CAMPAIGNSLIST']._serialized_end=1407
73
+ _globals['_USERSTATESERVICE']._serialized_start=1410
74
+ _globals['_USERSTATESERVICE']._serialized_end=1669
75
+ _globals['_SENDMESSAGE']._serialized_start=1672
76
+ _globals['_SENDMESSAGE']._serialized_end=1925
77
+ _globals['_TRANSFER']._serialized_start=1928
78
+ _globals['_TRANSFER']._serialized_end=2212
79
+ _globals['_ENDCHAT']._serialized_start=2215
80
+ _globals['_ENDCHAT']._serialized_end=2418
81
+ # @@protoc_insertion_point(module_scope)