feat: update bot info and deprecate stats command
All checks were successful
Docker CI/CD / Docker Build and Push to Docker Hub (push) Successful in 8m55s
Python Package CI/CD / Setup and Test (push) Successful in 1m58s
Python Package CI/CD / Publish to PyPI (push) Successful in 1m11s

Updated bot info command to display model info specific to room.
Removed the now unsupported stats command from help and privacy.
Retired the 'stats' command, informing users of its deprecation.
Updated version to 0.3.18 to reflect these changes.
This commit is contained in:
Kumi 2024-08-18 10:44:09 +02:00
parent e4dba23e39
commit 99d3974e17
Signed by: kumi
GPG key ID: ECBCC9082395383F
5 changed files with 27 additions and 19 deletions

View file

@ -7,7 +7,7 @@ allow-direct-references = true
[project] [project]
name = "matrix-gptbot" name = "matrix-gptbot"
version = "0.3.17" version = "0.3.18"
authors = [ authors = [
{ name = "Kumi", email = "gptbot@kumi.email" }, { name = "Kumi", email = "gptbot@kumi.email" },

View file

@ -5,19 +5,14 @@ from nio.rooms import MatrixRoom
async def command_botinfo(room: MatrixRoom, event: RoomMessageText, bot): async def command_botinfo(room: MatrixRoom, event: RoomMessageText, bot):
bot.logger.log("Showing bot info...") bot.logger.log("Showing bot info...")
body = f"""GPT Info: body = f"""GPT Room info:
Model: {bot.model} Model: {await bot.get_room_model(room)}\n
Maximum context tokens: {bot.max_tokens} Maximum context tokens: {bot.chat_api.max_tokens}\n
Maximum context messages: {bot.max_messages} Maximum context messages: {bot.chat_api.max_messages}\n
Bot user ID: {bot.matrix_client.user_id}\n
Room info: Current room ID: {room.room_id}\n
Bot user ID: {bot.matrix_client.user_id}
Current room ID: {room.room_id}
System message: {bot.get_system_message(room)} System message: {bot.get_system_message(room)}
For usage statistics, run !gptbot stats
""" """
await bot.send_message(room, body, True) await bot.send_message(room, body, True)

View file

@ -9,7 +9,6 @@ async def command_help(room: MatrixRoom, event: RoomMessageText, bot):
- !gptbot botinfo - Show information about the bot - !gptbot botinfo - Show information about the bot
- !gptbot privacy - Show privacy information - !gptbot privacy - Show privacy information
- !gptbot newroom <room name> - Create a new room and invite yourself to it - !gptbot newroom <room name> - Create a new room and invite yourself to it
- !gptbot stats - Show usage statistics for this room
- !gptbot systemmessage <message> - Get or set the system message for this room - !gptbot systemmessage <message> - Get or set the system message for this room
- !gptbot space [enable|disable|update|invite] - Enable, disable, force update, or invite yourself to your space - !gptbot space [enable|disable|update|invite] - Enable, disable, force update, or invite yourself to your space
- !gptbot coin - Flip a coin (heads or tails) - !gptbot coin - Flip a coin (heads or tails)

View file

@ -11,7 +11,7 @@ async def command_privacy(room: MatrixRoom, event: RoomMessageText, bot):
body += "- For chat requests: " + f"{bot.chat_api.operator}" + "\n" body += "- For chat requests: " + f"{bot.chat_api.operator}" + "\n"
if bot.image_api: if bot.image_api:
body += "- For image generation requests (!gptbot imagine): " + f"{bot.image_api.operator}" + "\n" body += "- For image generation requests (!gptbot imagine): " + f"{bot.image_api.operator}" + "\n"
if bot.calculate_api: if bot.calculation_api:
body += "- For calculation requests (!gptbot calculate): " + f"{bot.calculate_api.operator}" + "\n" body += "- For calculation requests (!gptbot calculate): " + f"{bot.calculation_api.operator}" + "\n"
await bot.send_message(room, body, True) await bot.send_message(room, body, True)

View file

@ -5,16 +5,30 @@ from contextlib import closing
async def command_stats(room: MatrixRoom, event: RoomMessageText, bot): async def command_stats(room: MatrixRoom, event: RoomMessageText, bot):
await bot.send_message(
room,
"The `stats` command is no longer supported. Sorry for the inconvenience.",
True,
)
return
# Yes, the code below is unreachable, but it's kept here for reference.
bot.logger.log("Showing stats...") bot.logger.log("Showing stats...")
if not bot.database: if not bot.database:
bot.logger.log("No database connection - cannot show stats") bot.logger.log("No database connection - cannot show stats")
bot.send_message(room, "Sorry, I'm not connected to a database, so I don't have any statistics on your usage.", True) await bot.send_message(
room,
"Sorry, I'm not connected to a database, so I don't have any statistics on your usage.",
True,
)
return return
with closing(bot.database.cursor()) as cursor: with closing(bot.database.cursor()) as cursor:
cursor.execute( cursor.execute(
"SELECT SUM(tokens) FROM token_usage WHERE room_id = ?", (room.room_id,)) "SELECT SUM(tokens) FROM token_usage WHERE room_id = ?", (room.room_id,)
)
total_tokens = cursor.fetchone()[0] or 0 total_tokens = cursor.fetchone()[0] or 0
bot.send_message(room, f"Total tokens used: {total_tokens}", True) await bot.send_message(room, f"Total tokens used: {total_tokens}", True)