Skip to content

Commit

Permalink
Add typing indicator when generating response
Browse files Browse the repository at this point in the history
  • Loading branch information
rabilrbl committed Dec 14, 2023
1 parent baf481b commit d64bded
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from telegram import Update, ForceReply
from telegram.ext import ContextTypes, CommandHandler, MessageHandler, filters, Application

from telegram.constants import ChatAction
from dotenv import load_dotenv
load_dotenv()

Expand Down Expand Up @@ -32,6 +33,7 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
text = update.message.text
init_msg = await update.message.reply_text(text="Generating...", reply_to_message_id=update.message.message_id)
inited = True
await update.message.chat.send_action(ChatAction.TYPING)
# Generate a response using the text-generation pipeline
response = model.generate_content(text, stream=True)

Expand Down

0 comments on commit d64bded

Please sign in to comment.