From ee95cacc81f0bdc702cd5f6b782dbfb0ddc98f10 Mon Sep 17 00:00:00 2001 From: Kurt Shuster Date: Wed, 2 Sep 2020 17:26:45 -0400 Subject: [PATCH] browser chat bug fix --- parlai/chat_service/services/browser_chat/client.py | 3 +++ parlai/chat_service/tasks/chatbot/worlds.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/parlai/chat_service/services/browser_chat/client.py b/parlai/chat_service/services/browser_chat/client.py index 07c68d11def..69eecf7b7aa 100644 --- a/parlai/chat_service/services/browser_chat/client.py +++ b/parlai/chat_service/services/browser_chat/client.py @@ -64,10 +64,13 @@ def do_POST(self): json_str = json.dumps(model_response) self.wfile.write(bytes(json_str, 'utf-8')) elif self.path == '/reset': + self._interactive_running(b"[RESET]") self.send_response(200) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(bytes("{}", 'utf-8')) + message_available.wait() + message_available.clear() else: return self._respond({'status': 500}) diff --git a/parlai/chat_service/tasks/chatbot/worlds.py b/parlai/chat_service/tasks/chatbot/worlds.py index bbce854c28b..1490d0d2346 100644 --- a/parlai/chat_service/tasks/chatbot/worlds.py +++ b/parlai/chat_service/tasks/chatbot/worlds.py @@ -62,7 +62,7 @@ def parley(self): 'id': 'World', 'text': 'Welcome to the ParlAI Chatbot demo. ' 'You are now paired with a bot - feel free to send a message.' - 'Type [DONE] to finish the chat.', + 'Type [DONE] to finish the chat, or [RESET] to reset the dialogue history.', } ) self.first_time = False @@ -70,6 +70,9 @@ def parley(self): if a is not None: if '[DONE]' in a['text']: self.episodeDone = True + elif '[RESET]' in a['text']: + self.model.reset() + self.agent.observe({"text": "[History Cleared]", "episode_done": False}) else: print("===act====") print(a)