Compare commits
No commits in common. "master" and "9month-revision-update" have entirely different histories.
master
...
9month-rev
@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"convertable": true,
|
|
||||||
"units": {
|
|
||||||
"kilogram": {
|
|
||||||
"factor": 1,
|
|
||||||
"aliases": [
|
|
||||||
"kg",
|
|
||||||
"kgs",
|
|
||||||
"kilogram",
|
|
||||||
"kilograms",
|
|
||||||
"kilogramme",
|
|
||||||
"kilogrammes",
|
|
||||||
"kg.",
|
|
||||||
"kgs."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"pound": {
|
|
||||||
"factor": 0.45,
|
|
||||||
"aliases": [
|
|
||||||
"lb",
|
|
||||||
"lb.",
|
|
||||||
"lbs",
|
|
||||||
"lbs.",
|
|
||||||
"pound",
|
|
||||||
"pounds"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"tonne": {
|
|
||||||
"factor": 1000,
|
|
||||||
"aliases": [
|
|
||||||
"t",
|
|
||||||
"t.",
|
|
||||||
"tonne",
|
|
||||||
"tonnes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -12,7 +12,7 @@ class FitnessCog(commands.Cog):
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
default_threads = "1457402451530350727,1328363409648910356,1533433244186443827"
|
default_threads = "1457402451530350727,1328363409648910356"
|
||||||
threads_raw = os.getenv("THREADS_ID", default_threads)
|
threads_raw = os.getenv("THREADS_ID", default_threads)
|
||||||
|
|
||||||
self.threads_id: list[int] = []
|
self.threads_id: list[int] = []
|
||||||
@ -117,7 +117,7 @@ class FitnessCog(commands.Cog):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
unit = parts[2] if len(parts) > 2 else None
|
unit = parts[2] if len(parts) > 2 else "m"
|
||||||
|
|
||||||
timestamp = int(message.created_at.timestamp())
|
timestamp = int(message.created_at.timestamp())
|
||||||
username = message.author.name
|
username = message.author.name
|
||||||
|
|||||||
@ -25,6 +25,7 @@ CALLABLE_FUNCTIONS = {
|
|||||||
|
|
||||||
DEFAULT_MODEL = "gpt-5-mini-2025-08-07"
|
DEFAULT_MODEL = "gpt-5-mini-2025-08-07"
|
||||||
DEFAULT_MAX_COMPLETION_TOKENS = 2000
|
DEFAULT_MAX_COMPLETION_TOKENS = 2000
|
||||||
|
TYPING_HEARTBEAT_INTERVAL_SECONDS = 8
|
||||||
STATUS_UPDATE_MIN_INTERVAL_SECONDS = 1.5
|
STATUS_UPDATE_MIN_INTERVAL_SECONDS = 1.5
|
||||||
|
|
||||||
|
|
||||||
@ -99,6 +100,12 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog):
|
|||||||
}
|
}
|
||||||
return tool_statuses.get(tool_name, "Reginald is consulting an external source...")
|
return tool_statuses.get(tool_name, "Reginald is consulting an external source...")
|
||||||
|
|
||||||
|
async def typing_heartbeat(self, channel: discord.TextChannel):
|
||||||
|
while True:
|
||||||
|
with suppress(discord.HTTPException):
|
||||||
|
await channel.trigger_typing()
|
||||||
|
await asyncio.sleep(TYPING_HEARTBEAT_INTERVAL_SECONDS)
|
||||||
|
|
||||||
def make_status_updater(
|
def make_status_updater(
|
||||||
self, status_message: discord.Message
|
self, status_message: discord.Message
|
||||||
) -> Callable[[str, bool], Awaitable[None]]:
|
) -> Callable[[str, bool], Awaitable[None]]:
|
||||||
@ -208,37 +215,18 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog):
|
|||||||
status_message = await message.channel.send(self.get_thinking_status_message())
|
status_message = await message.channel.send(self.get_thinking_status_message())
|
||||||
status_update = self.make_status_updater(status_message)
|
status_update = self.make_status_updater(status_message)
|
||||||
|
|
||||||
response_text = None
|
typing_task = asyncio.create_task(self.typing_heartbeat(message.channel))
|
||||||
if hasattr(message.channel, "typing"):
|
|
||||||
try:
|
try:
|
||||||
async with message.channel.typing():
|
|
||||||
response_text = await self.generate_response(
|
response_text = await self.generate_response(
|
||||||
api_key,
|
api_key,
|
||||||
formatted_messages,
|
formatted_messages,
|
||||||
status_update=status_update,
|
status_update=status_update,
|
||||||
)
|
)
|
||||||
except (discord.HTTPException, AttributeError):
|
|
||||||
# Fall back to normal processing if typing indicator isn't available.
|
|
||||||
response_text = await self.generate_response(
|
|
||||||
api_key,
|
|
||||||
formatted_messages,
|
|
||||||
status_update=status_update,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
response_text = await self.generate_response(
|
|
||||||
api_key,
|
|
||||||
formatted_messages,
|
|
||||||
status_update=status_update,
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
await self.send_split_message(message.channel, response_text)
|
|
||||||
finally:
|
finally:
|
||||||
if status_message is not None:
|
typing_task.cancel()
|
||||||
with suppress(discord.HTTPException):
|
with suppress(asyncio.CancelledError):
|
||||||
await status_message.delete()
|
await typing_task
|
||||||
|
|
||||||
try:
|
|
||||||
memory.append({"user": user_name, "content": prompt})
|
memory.append({"user": user_name, "content": prompt})
|
||||||
memory.append({"user": "Reginald", "content": response_text})
|
memory.append({"user": "Reginald", "content": response_text})
|
||||||
|
|
||||||
@ -262,8 +250,11 @@ class ReginaldCog(PermissionsMixin, BlacklistMixin, MemoryMixin, commands.Cog):
|
|||||||
).mid_term_memory() as mid_memory:
|
).mid_term_memory() as mid_memory:
|
||||||
short_memory[channel_id] = memory
|
short_memory[channel_id] = memory
|
||||||
mid_memory[channel_id] = mid_term_summaries[-self.summary_retention_limit :]
|
mid_memory[channel_id] = mid_term_summaries[-self.summary_retention_limit :]
|
||||||
except Exception as error:
|
|
||||||
print(f"DEBUG: Memory persistence failed after response delivery: {error}")
|
await self.send_split_message(message.channel, response_text)
|
||||||
|
if status_message is not None:
|
||||||
|
with suppress(discord.HTTPException):
|
||||||
|
await status_message.delete()
|
||||||
|
|
||||||
def should_reginald_interject(self, message_content: str) -> bool:
|
def should_reginald_interject(self, message_content: str) -> bool:
|
||||||
direct_invocation = {"reginald,"}
|
direct_invocation = {"reginald,"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user