Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
xingty committed Jun 25, 2024
1 parent db4998b commit bfac84e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
42 changes: 21 additions & 21 deletions src/catgpt/commands/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,32 +185,32 @@ async def do_reply(
else:
raise ae

if len(buffered) > 0:
delta = timeout - (time.time() - start)
if delta > 0:
await asyncio.sleep(int(delta) + 1)

text += buffered
# if len(buffered) > 0: for removing the endpoint info from the message
delta = timeout - (time.time() - start)
if delta > 0:
await asyncio.sleep(int(delta) + 1)

text += buffered
msg_text = escape(text)
if text_overflow or len(msg_text) > MAX_TEXT_LENGTH:
text_overflow = True
msg_text = escape(text)
if text_overflow or len(msg_text) > MAX_TEXT_LENGTH:
text_overflow = True
msg_text = escape(text)

msg = await bot.edit_message_text(
text=msg_text,
msg = await bot.edit_message_text(
text=msg_text,
chat_id=reply_msg.chat.id,
message_id=reply_msg.message_id,
parse_mode="MarkdownV2",
disable_web_page_preview=True,
)

if text_overflow:
await bot.send_message(
chat_id=reply_msg.chat.id,
message_id=reply_msg.message_id,
parse_mode="MarkdownV2",
disable_web_page_preview=True,
text=escape(buffered),
reply_to_message_id=msg.message_id,
)

if text_overflow:
await bot.send_message(
chat_id=reply_msg.chat.id,
text=escape(buffered),
reply_to_message_id=msg.message_id,
)

return text


Expand Down
9 changes: 5 additions & 4 deletions src/catgpt/storage/tx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import enum
import os
import time

# import time

from contextvars import ContextVar

Expand Down Expand Up @@ -60,7 +61,7 @@ def decorator(func):
async def wrapper(*args, **kwargs):
token = None
tx = context.get()
start = time.time()
# start = time.time()
if tx is None:
if tx_type == "write":
conn = await storage.datasource.get_write_conn()
Expand All @@ -87,8 +88,8 @@ async def wrapper(*args, **kwargs):
print(e)
raise e
finally:
end = time.time()
print(f"Transaction time: {end} - {start} = {end - start}")
# end = time.time()
# print(f"Transaction time: {end} - {start} = {end - start}")
if token is not None:
context.reset(token)
tx.close()
Expand Down

0 comments on commit bfac84e

Please sign in to comment.