Skip to content

Commit

Permalink
bugfix: null handler
Browse files Browse the repository at this point in the history
  • Loading branch information
V-know committed May 16, 2023
1 parent e6a03aa commit 29039bc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
logger.addHandler(fh)

token = {0: 256, 1: 1024, 2: 1024}
context_count = {0: 5, 1: 10, 2: 10}
context_count = {0: 3, 1: 5, 2: 10}
rate_limit = {0: 5, 1: 15, 2: 300}

CHOOSING, TYPING_REPLY, TYPING_SYS_CONTENT = range(3)
Expand Down Expand Up @@ -239,6 +239,12 @@ async def statistics(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
f"select sum(tokens) as tokens from records where user_id={user_id} and role='user'", 1)[0]
completion_tokens = mysql.getMany(
f"select sum(tokens) as tokens from records where user_id={user_id} and role='assistant'", 1)[0]

if not prompt_tokens["tokens"]:
prompt_tokens["tokens"] = 0
if not completion_tokens["tokens"]:
completion_tokens["tokens"] = 0

await update.message.reply_html(
rf"""
Hej {user.mention_html()}!
Expand Down Expand Up @@ -292,10 +298,11 @@ async def set_system_content(update: Update, context: ContextTypes.DEFAULT_TYPE)
mysql = Mysql()
user = mysql.getOne("select * from users where user_id=%s", user_id)
mysql.end()
system_content = user.get("system_content") if user else 'You are an AI assistant that helps people find information.'
await update.message.reply_text(text=f"""
您当前的系统AI助手身份设置为🤖:
**{user["system_content"]}**
**{system_content}**
请直接回复新的AI助手身份设置!
Expand Down

0 comments on commit 29039bc

Please sign in to comment.