Beispiel #1
0
 def observe(self, observation):
     self.observation = observation
     self.episode_done = observation['episode_done']
     text = observation['text']
     if self.episode_done:
         self.text = '/end'
     elif text == "$desc":
         self.text = "Total chats: %s\nFinished chats: %s\nCurrnet chat: %s" % (
             len(self.convai_world.chats),
             len(self.convai_world.finished_chats), self.convai_world.chat)
     elif text == "$end":
         self.text = "/end"
         self.episode_done = True
     elif text == "$ls":
         res = []
         for chat in self.convai_world.chats.keys():
             status = "Finished" if chat in self.convai_world.finished_chats else "Active"
             res.append((chat, status))
         self.text = str(res)
     elif text == "$cleanup":
         self.text = str(self.convai_world.finished_chats)
         self.convai_world.cleanup_finished_chats()
     elif text == "$chat":
         self.text = "Current chat id is %s" % self.convai_world.chat
     else:
         texts = [
             'I love you!', 'Wow!', 'Really?', 'Nice!', 'Hi', 'Hello',
             "This is not very interesting. Let's change the subject of the conversation. For example, let's talk about cats. What do you think?",
             '/end'
         ]
         self.text = texts[random.randint(0, 7)]
         if self.text != '/end':
             self.text = "%s : %s" % (self.bot_id[:7], self.text)
     print("\t" + display_messages([observation]))
Beispiel #2
0
 def act(self):
     reply = {
         'id': self.getID(),
         'text': self.text,
         'episode_done': self.episode_done
     }
     print("\t" + display_messages([reply]))
     return reply
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, 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'
            ])
Beispiel #5
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'])
Beispiel #6
0
 def observe(self, msg):
     print(display_messages([msg]))
Beispiel #7
0
 def observe(self, msg):
     print(display_messages([msg]))
Beispiel #8
0
 def display(self):
     if self.curr_chatID in self.chats.keys():
         return display_messages(self.last_exchanges[self.curr_chatID])
     else:
         return ''
 def display(self):
     if self.curr_chatID in self.chats.keys():
         return display_messages(self.last_exchanges[self.curr_chatID])
     else:
         return ''