Beispiel #1
0
 def observe(self, msg):
     print(
         display_messages(
             [msg],
             ignore_fields=self.opt.get('display_ignore_fields', ''),
             prettify=self.opt.get('display_prettify', False),
         ))
Beispiel #2
0
 def observe(self, msg):
     print(
         display_messages(
             [msg],
             add_fields=self.opt.get('display_add_fields', ''),
             prettify=self.opt.get('display_prettify', False),
             verbose=self.opt.get('verbose', False),
         ))
Beispiel #3
0
 def act(self):
     reply = {
         'id': self.getID(),
         'text': self.text,
         'episode_done': self.episode_done,
     }
     print('\t' + display_messages([reply]))
     return reply
Beispiel #4
0
 def observe(self, msg):
     print(
         display_messages(
             [msg],
             
             prettify=self.opt.get('display_prettify', False),
         )
     )
Beispiel #5
0
 def observe(self, msg):
     # msg에 response가 이미 만들어져 있음
     print(
         # 여기서 Display Response
         display_messages(
             [msg],
             ignore_fields=self.opt.get('display_ignore_fields', ''),
             prettify=self.opt.get('display_prettify', False),
         ))
Beispiel #6
0
 def observe(self, msg):
     # print(msg['text'])
     # f = open("my_log.txt","a+")
     # f.write(msg['text']+"\n")
     # f.close()
     print(
         display_messages(
             [msg],
             ignore_fields=self.opt.get('display_ignore_fields', ''),
             prettify=self.opt.get('display_prettify', False),
         ))
 def observe(self, msg):
     if not self.self_offensive:
         # check offensiveness of other agent.
         if not self.offensive(msg.get('text', '')):
             print(
                 display_messages(
                     [msg],
                     ignore_fields=self.opt.get('display_ignore_fields',
                                                ''),
                     prettify=self.opt.get('display_prettify', False),
                 ))
         else:
             # do not print anything at all.
             pass
Beispiel #8
0
    def display(self):
        """
        Return a string describing the current state of the world.

        Useful for monitoring and debugging. By default, display the messages between
        the agents.
        """
        if not hasattr(self, 'acts'):
            return ''
        return display_messages(
            self.acts,
            ignore_fields=self.opt.get('display_ignore_fields', ''),
            prettify=self.opt.get('display_prettify', False),
            max_len=self.opt.get('max_display_len', 1000),
        )
Beispiel #9
0
 def display(self):
     s = "[--batchsize " + str(self.batchsize) + "--]\n"
     for i in range(self.batchsize):
         s += "[batch " + str(i) + ":]\n"
         s += display_messages(
             self.batch_acts[i],
             ignore_agent_reply=self.opt.get("ignore_agent_reply", False),
             add_fields=self.opt.get("display_add_fields", ""),
             prettify=self.opt.get("display_prettify", False),
             max_len=self.opt.get("max_display_len", 1000),
             verbose=self.opt.get("verbose", False),
         )
         s += "\n"
     s += "[--end of batch--]\n"
     return s
Beispiel #10
0
    def observe(self, msg):
        # time.sleep(2)
        print("observe!!!!!!!!!!!!!!!!!\n")
        msg = display_messages([msg],
                               ignore_fields=self.opt.get(
                                   'display_ignore_fields', ''),
                               prettify=self.opt.get('display_prettify',
                                                     False))
        print(msg)
        #connectionSock.sendall(msg.encode('utf-8'))

        try:
            print("@##@@@@")
            sendByteLen = connectionSock.sendall(
                msg.encode('utf-8'))  #서버로 데이터 보내기
            print(sendByteLen)
        except IOError:
            print("@")
            return
Beispiel #11
0
    def observe(self, observation):
        print('\t' + display_messages([observation]))
        self.observation = observation
        self.episode_done = observation['episode_done']

        if self.episode_done:
            self.text = '/end'
        else:
            self.text = random.choice([
                'I love you!',
                'Wow!',
                'Really?',
                'Nice!',
                'Hi',
                'Hello',
                'This is not very interesting. Let\'s change the subject of the '
                'conversation and talk about cats.',
                '/end',
            ])
    def observe(self, msg):
        """
        Observe bot reply if and only if it passes.
        """
        if self.self_offensive:
            # User was offensive, they must try again
            return

        # Now check if bot was offensive
        bot_offensive = self.check_offensive(msg.get('text', ''))
        if not bot_offensive:
            # View bot message
            print(
                display_messages(
                    [msg],
                    ignore_fields=self.opt.get('display_ignore_fields', ''),
                    prettify=self.opt.get('display_prettify', False),
                ))
            msg.force_set('bot_offensive', False)
        else:
            msg.force_set('bot_offensive', True)
            print(OFFENSIVE_BOT_REPLY)
 def display(self):
     if self.curr_chatID in self.chats.keys():
         return display_messages(self.last_exchanges[self.curr_chatID])
     else:
         return ''