-
Notifications
You must be signed in to change notification settings - Fork 0
Refatora lógica de resposta do assistente em on_message #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,6 +131,8 @@ def on_message(self, message: Message): | |||||||||||||||||||||||||
| if message.room_id != self.page.session.get("current_room"): | ||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| should_render_chat_message = message.message_type == "chat_message" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if message.message_type == "chat_message": | ||||||||||||||||||||||||||
| control = self.create_chat_message(message) | ||||||||||||||||||||||||||
| self.append_chat_control(control) | ||||||||||||||||||||||||||
|
|
@@ -172,7 +174,15 @@ def on_message(self, message: Message): | |||||||||||||||||||||||||
| self.append_chat_control(control) | ||||||||||||||||||||||||||
| self.update_page() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if message.room_id == "programador" and message.message_type == "chat_message": | ||||||||||||||||||||||||||
| assistant_name = getattr(self.assistant_responder, "nome", "").strip().lower() | ||||||||||||||||||||||||||
| should_process_assistant_response = ( | ||||||||||||||||||||||||||
| should_render_chat_message | ||||||||||||||||||||||||||
| and message.room_id == "programador" | ||||||||||||||||||||||||||
| and message.message_type not in {"login_message", "file_message"} | ||||||||||||||||||||||||||
| and message.user_name.strip().lower() != assistant_name | ||||||||||||||||||||||||||
|
Comment on lines
+177
to
+182
|
||||||||||||||||||||||||||
| assistant_name = getattr(self.assistant_responder, "nome", "").strip().lower() | |
| should_process_assistant_response = ( | |
| should_render_chat_message | |
| and message.room_id == "programador" | |
| and message.message_type not in {"login_message", "file_message"} | |
| and message.user_name.strip().lower() != assistant_name | |
| is_assistant_message = getattr(message, "is_assistant", False) | |
| should_process_assistant_response = ( | |
| should_render_chat_message | |
| and message.room_id == "programador" | |
| and message.message_type not in {"login_message", "file_message"} | |
| and not is_assistant_message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should_render_chat_messagejá garantemessage.message_type == "chat_message", então o predicadoand message.message_type not in {"login_message", "file_message"}é redundante e não tem efeito. Remover essa condição (ou removershould_render_chat_messagee manter apenas uma checagem de tipo) deixa a regra mais clara e evita confusão em futuras refatorações.