If an NPC calls to AI to talk...

And no one is around to listen, are we just wasting tokens?

Yup.
This commit is contained in:
Howard Abrams 2026-05-03 08:27:35 -07:00
parent 9e77eb87ad
commit 5f2df4341e
2 changed files with 17 additions and 15 deletions

View file

@ -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):

View file

@ -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')