Skip to content

Commit

Permalink
add some extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Pro committed Feb 19, 2024
1 parent a7a0c97 commit 7e1ff3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "pypi"

[[description]]
name = "vldc-bot"
version = "0.8.6"
version = "0.8.7"
description = "VLDC nyan bot ^_^"
authors = [
#tg
Expand Down
11 changes: 7 additions & 4 deletions bot/skills/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# Max number of messages to keep in memory.
MAX_MESSAGES = 100
# Max age of message to be considered for poem generation.
MAX_AGE = timedelta(hours=6)
# Number of examples to show in the prompt.
MAX_AGE = timedelta(hours=12)
# Number of examples to show to LLM in the prompt.
NUM_EXAMPLES = 10
# How often muse visits Nyan.
SLEEP_INTERVAL = 60 * 60
Expand Down Expand Up @@ -60,6 +60,7 @@ def write_a_poem(self) -> str:
continue
log.append(message)
if len(log) < 10:
logger.info("not writing poem since only have %d messages", len(log))
return ""

theme = summarize("\n".join(log))
Expand Down Expand Up @@ -144,6 +145,7 @@ def muse_visit(context: CallbackContext):
secondsInDay = 24 * 60 * 60
inspirationRate = float(POEMS_PER_DAY) / float(secondsInDay / SLEEP_INTERVAL)
if random.random() > inspirationRate:
logger.info("checked for inspiration but it did not come")
return

try:
Expand All @@ -152,9 +154,10 @@ def muse_visit(context: CallbackContext):
context.bot.send_message(
chat_id=context.job.context["chat_id"], text=message
)
nyan.forget()
# Forget messages we already wrote about.
nyan.forget()
except Exception as e: # pylint: disable=broad-except
logger.error("inspiration did not come: %s", e)
logger.error("inspiration failed: %s", e)


def summarize(log):
Expand Down

0 comments on commit 7e1ff3f

Please sign in to comment.