chatgraph 0.2.3__py3-none-any.whl → 0.2.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 +6 -3
- chatgraph/messages/base_message_consumer.py +7 -0
- chatgraph/messages/rabbitMQ_message_consumer.py +35 -1
- {chatgraph-0.2.3.dist-info → chatgraph-0.2.4.dist-info}/METADATA +2 -1
- {chatgraph-0.2.3.dist-info → chatgraph-0.2.4.dist-info}/RECORD +7 -7
- {chatgraph-0.2.3.dist-info → chatgraph-0.2.4.dist-info}/LICENSE +0 -0
- {chatgraph-0.2.3.dist-info → chatgraph-0.2.4.dist-info}/WHEEL +0 -0
chatgraph/bot/chatbot_model.py
CHANGED
|
@@ -98,8 +98,9 @@ class ChatbotApp(ABC):
|
|
|
98
98
|
"""
|
|
99
99
|
Inicia o consumo de mensagens pelo chatbot, processando cada mensagem recebida.
|
|
100
100
|
"""
|
|
101
|
+
self.__message_consumer.reprer()
|
|
101
102
|
self.__message_consumer.start_consume(self.process_message)
|
|
102
|
-
|
|
103
|
+
|
|
103
104
|
def process_message(self, message: Message):
|
|
104
105
|
"""
|
|
105
106
|
Processa uma mensagem recebida, identificando a rota correspondente e executando a função associada.
|
|
@@ -149,7 +150,9 @@ class ChatbotApp(ABC):
|
|
|
149
150
|
}
|
|
150
151
|
return json.dumps(response)
|
|
151
152
|
elif type(message_response) in (ChatbotResponse, EndChatResponse, TransferToHuman):
|
|
152
|
-
|
|
153
|
+
response = message_response.json()
|
|
154
|
+
response['customer_id'] = customer_id
|
|
155
|
+
return json.dumps(response)
|
|
153
156
|
elif type(message_response) == RedirectResponse:
|
|
154
157
|
route = self.__adjust_route(message_response.route, menu)
|
|
155
158
|
message.user_state.menu = route
|
|
@@ -174,4 +177,4 @@ class ChatbotApp(ABC):
|
|
|
174
177
|
if 'start' not in route:
|
|
175
178
|
route = absolute_route + route
|
|
176
179
|
|
|
177
|
-
return route
|
|
180
|
+
return route
|
|
@@ -6,7 +6,10 @@ from typing import Callable
|
|
|
6
6
|
from ..auth.credentials import Credential
|
|
7
7
|
from ..types.message_types import Message, UserState
|
|
8
8
|
from .base_message_consumer import MessageConsumer
|
|
9
|
-
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
from rich.table import Table
|
|
11
|
+
from rich.text import Text
|
|
12
|
+
from rich.panel import Panel
|
|
10
13
|
|
|
11
14
|
class RabbitMessageConsumer(MessageConsumer):
|
|
12
15
|
"""
|
|
@@ -175,3 +178,34 @@ class RabbitMessageConsumer(MessageConsumer):
|
|
|
175
178
|
company_phone=message.get('company_phone', ''),
|
|
176
179
|
status=message.get('status'),
|
|
177
180
|
)
|
|
181
|
+
|
|
182
|
+
def reprer(self):
|
|
183
|
+
console = Console()
|
|
184
|
+
|
|
185
|
+
# Título "ChatGraph" destacado em vermelho e negrito dentro de um painel
|
|
186
|
+
title_text = Text("ChatGraph", style="bold red", justify="center")
|
|
187
|
+
title_panel = Panel.fit(title_text, title=" ", border_style="bold red", padding=(1, 4))
|
|
188
|
+
|
|
189
|
+
# Linha separadora com emojis
|
|
190
|
+
separator = Text("🐇🐇🐇 RabbitMessageConsumer 📨📨📨", style="cyan", justify="center")
|
|
191
|
+
|
|
192
|
+
# Criação da tabela com os atributos
|
|
193
|
+
table = Table(show_header=True, header_style="bold magenta", title="RabbitMQ Consumer")
|
|
194
|
+
table.add_column("Atributo", justify="center", style="cyan", no_wrap=True)
|
|
195
|
+
table.add_column("Valor", justify="center", style="magenta")
|
|
196
|
+
|
|
197
|
+
table.add_row("Virtual Host", self.__virtual_host)
|
|
198
|
+
table.add_row("Prefetch Count", str(self.__prefetch_count))
|
|
199
|
+
table.add_row("Queue Consume", self.__queue_consume)
|
|
200
|
+
table.add_row("AMQP URL", self.__amqp_url)
|
|
201
|
+
table.add_row("Username", self.__credentials.username)
|
|
202
|
+
table.add_row("Password", "******") # Oculta a senha
|
|
203
|
+
|
|
204
|
+
# Imprime o título, separador e a tabela centralizada
|
|
205
|
+
console.print(title_panel, justify="center")
|
|
206
|
+
console.print(separator, justify="center")
|
|
207
|
+
console.print(table, justify="center")
|
|
208
|
+
|
|
209
|
+
c = Credential('user', 'pass')
|
|
210
|
+
consumer = RabbitMessageConsumer(c, "amqp://example.com", "queue_name", 10, "/virtual_host")
|
|
211
|
+
consumer.reprer()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chatgraph
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: A user-friendly chatbot library
|
|
5
5
|
Home-page: https://github.com/irissonnlima/chatgraph
|
|
6
6
|
License: MIT
|
|
@@ -12,6 +12,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Requires-Dist: pika (>=1.3.2,<2.0.0)
|
|
15
|
+
Requires-Dist: rich (>=13.8.1,<14.0.0)
|
|
15
16
|
Project-URL: Repository, https://github.com/irissonnlima/chatgraph
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
17
18
|
|
|
@@ -1,17 +1,17 @@
|
|
|
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=IBmFLGRkFh4eEwNInIMw3czQ5Kdry8NmQ4dCg81Yqro,6626
|
|
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
|
-
chatgraph/messages/base_message_consumer.py,sha256=
|
|
8
|
-
chatgraph/messages/rabbitMQ_message_consumer.py,sha256=
|
|
7
|
+
chatgraph/messages/base_message_consumer.py,sha256=4qZj69eDtqeqmSDSfGsCRt6hyypSPTSry3pmRh8r8nM,1269
|
|
8
|
+
chatgraph/messages/rabbitMQ_message_consumer.py,sha256=xdKrHeq1zV_0FDy1JtcLpWGW0RoUD-8q32ZWvnsdEOQ,8851
|
|
9
9
|
chatgraph/messages/test_message_consumer.py,sha256=9XIkbCHd1S6S8pINRT-SLEvUT0TQWBCsdPhYN6PpZ2s,518
|
|
10
10
|
chatgraph/types/message_types.py,sha256=7eB45hrlbYKV1Lp9vysR6V7OXNsySpeKYbGBc2Ux6xE,1363
|
|
11
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.4.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
|
|
15
|
+
chatgraph-0.2.4.dist-info/METADATA,sha256=6JnfS0l3ArZorgyQNUX93L9S-3hA6NuA-IMgPyDXsy0,5868
|
|
16
|
+
chatgraph-0.2.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
17
|
+
chatgraph-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|