chatgraph 0.2.2__tar.gz → 0.2.4__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.
- {chatgraph-0.2.2 → chatgraph-0.2.4}/PKG-INFO +2 -1
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/bot/chatbot_model.py +8 -4
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/messages/base_message_consumer.py +7 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/messages/rabbitMQ_message_consumer.py +35 -1
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/types/output_state.py +6 -6
- {chatgraph-0.2.2 → chatgraph-0.2.4}/pyproject.toml +2 -1
- {chatgraph-0.2.2 → chatgraph-0.2.4}/LICENSE +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/README.md +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/__init__.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/auth/credentials.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/bot/chatbot_router.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/error/chatbot_error.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/error/route_error.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/messages/test_message_consumer.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/types/message_types.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/types/route.py +0 -0
- {chatgraph-0.2.2 → chatgraph-0.2.4}/chatgraph/types/user_state.py +0 -0
|
@@ -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
|
|
|
@@ -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
|
|
@@ -97,8 +98,9 @@ class ChatbotApp(ABC):
|
|
|
97
98
|
"""
|
|
98
99
|
Inicia o consumo de mensagens pelo chatbot, processando cada mensagem recebida.
|
|
99
100
|
"""
|
|
101
|
+
self.__message_consumer.reprer()
|
|
100
102
|
self.__message_consumer.start_consume(self.process_message)
|
|
101
|
-
|
|
103
|
+
|
|
102
104
|
def process_message(self, message: Message):
|
|
103
105
|
"""
|
|
104
106
|
Processa uma mensagem recebida, identificando a rota correspondente e executando a função associada.
|
|
@@ -146,9 +148,11 @@ class ChatbotApp(ABC):
|
|
|
146
148
|
'menu': route,
|
|
147
149
|
'obs': user_state.obs,
|
|
148
150
|
}
|
|
149
|
-
return response
|
|
151
|
+
return json.dumps(response)
|
|
150
152
|
elif type(message_response) in (ChatbotResponse, EndChatResponse, TransferToHuman):
|
|
151
|
-
|
|
153
|
+
response = message_response.json()
|
|
154
|
+
response['customer_id'] = customer_id
|
|
155
|
+
return json.dumps(response)
|
|
152
156
|
elif type(message_response) == RedirectResponse:
|
|
153
157
|
route = self.__adjust_route(message_response.route, menu)
|
|
154
158
|
message.user_state.menu = route
|
|
@@ -173,4 +177,4 @@ class ChatbotApp(ABC):
|
|
|
173
177
|
if 'start' not in route:
|
|
174
178
|
route = absolute_route + route
|
|
175
179
|
|
|
176
|
-
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()
|
|
@@ -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
|
[tool.poetry]
|
|
2
2
|
name = "chatgraph"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4"
|
|
4
4
|
description = "A user-friendly chatbot library"
|
|
5
5
|
authors = ["Irisson N. Lima <irisson.lima@verdecard.com.br>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -12,6 +12,7 @@ license = "MIT"
|
|
|
12
12
|
[tool.poetry.dependencies]
|
|
13
13
|
python = "^3.12"
|
|
14
14
|
pika = "^1.3.2"
|
|
15
|
+
rich = "^13.8.1"
|
|
15
16
|
|
|
16
17
|
[tool.poetry.group.dev.dependencies]
|
|
17
18
|
ruff = "^0.5.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|