diff --git a/typeclasses/chatbots.py b/typeclasses/chatbots.py index 79c0beb..b8e45af 100755 --- a/typeclasses/chatbots.py +++ b/typeclasses/chatbots.py @@ -436,16 +436,17 @@ class Dragon(Traveler): "say Look at all these luscious peoples.", "emote waves to everyone.", "emote waves to everybody." - ]) + ] delay(5, self.do_cmd, cmd) def goodbye(self, new_room=None): if self.location.key == "Wyldwood Bar": self.do_cmd("drop drink") - system_prompt = self.setting_and_backstory() - messages = [{"role": "user", "content": "Say goodbye."}] - reply = self._think(system_prompt, messages) - self.process_thoughts(reply) + if self.location.characters_here(): + system_prompt = self.setting_and_backstory() + messages = [{"role": "user", "content": "Say goodbye."}] + reply = self._think(system_prompt, messages) + self.process_thoughts(reply) class TravelingNPC(Script): diff --git a/typeclasses/objects.py b/typeclasses/objects.py index 729e8eb..447ff2a 100755 --- a/typeclasses/objects.py +++ b/typeclasses/objects.py @@ -846,18 +846,19 @@ class AI: and 'messages' from the JSON history function, appended with all 'events' recorded since last time. """ - system_prompt = self.setting_and_backstory(speaker) - messages = self.history(speaker) - recent_events = self.pop_recent_events(speech) - if recent_events: - speech = f"{recent_events}\n\n{speaker.key}: {speech}" - messages.append({"role": "user", "content": speech}) + if self.location.characters_here(): + system_prompt = self.setting_and_backstory(speaker) + messages = self.history(speaker) + recent_events = self.pop_recent_events(speech) + if recent_events: + speech = f"{recent_events}\n\n{speaker.key}: {speech}" + messages.append({"role": "user", "content": speech}) - # logger.info(f"Deep Thoughts: {system_prompt} / {messages}") - reply = self._think(system_prompt, messages) + # logger.info(f"Deep Thoughts: {system_prompt} / {messages}") + reply = self._think(system_prompt, messages) - self.update_history(speaker, messages, reply) - return reply + self.update_history(speaker, messages, reply) + return reply def process_thoughts(self, response): paragraphs = response.split('\n\n')