diff --git a/README.md b/README.md
index 7f9cdb0..c4e3a94 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ You can deploy your own bot, or use mine: [@chatgpt_karfly_bot](https://t.me/cha
- DALLE 2 (choose ๐ฉโ๐จ Artist mode to generate images)
- Voice message recognition
- Code highlighting
-- Special chat modes: ๐ฉ๐ผโ๐ Assistant, ๐ฉ๐ผโ๐ป Code Assistant, ๐ Text Improver and ๐ฌ Movie Expert. You can easily create your own chat modes by editing `config/chat_modes.yml`
+- 15 special chat modes: ๐ฉ๐ผโ๐ Assistant, ๐ฉ๐ผโ๐ป Code Assistant, ๐ฉโ๐จ Artist, ๐ง Psychologist, ๐ Elon Musk and other. You can easily create your own chat modes by editing `config/chat_modes.yml`
- Support of [ChatGPT API](https://platform.openai.com/docs/guides/chat/introduction)
- List of allowed Telegram users
- Track $ balance spent on OpenAI API
@@ -52,7 +52,10 @@ You can deploy your own bot, or use mine: [@chatgpt_karfly_bot](https://t.me/cha
If you want to add payments to your bot and create profitable business โ write me on Telegram ([@karfly](https://t.me/karfly)).
## News
-- *21 Apr 2023*: DALLE 2 support, Group Chat support (/help_group_chat to get instructions)
+- *21 Apr 2023*:
+ - DALLE 2 support
+ - Group Chat support (/help_group_chat to get instructions)
+ - 10 new hot chat modes and updated chat mode menu with pagination: ๐ฌ๐ง English Tutor, ๐ง Psychologist, ๐ Elon Musk, ๐ SQL Assistant and other.
- *24 Mar 2023*: GPT-4 support. Run `/settings` command to choose model
- *15 Mar 2023*: Added message streaming. Now you don't have to wait until the whole message is ready, it's streamed to Telegram part-by-part (watch demo)
- *9 Mar 2023*: Now you can easily create your own Chat Modes by editing `config/chat_modes.yml`
diff --git a/bot/bot.py b/bot/bot.py
index 6fcb0dd..16736a1 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -138,12 +138,11 @@ async def start_handle(update: Update, context: CallbackContext):
db.set_user_attribute(user_id, "last_interaction", datetime.now())
db.start_new_dialog(user_id)
- reply_text = "Hi! I'm ChatGPT bot implemented with GPT-3.5 OpenAI API ๐ค\n\n"
+ reply_text = "Hi! I'm ChatGPT bot implemented with OpenAI API ๐ค\n\n"
reply_text += HELP_MESSAGE
- reply_text += "\nAnd now... ask me anything!"
-
await update.message.reply_text(reply_text, parse_mode=ParseMode.HTML)
+ await show_chat_modes_handle(update, context)
async def help_handle(update: Update, context: CallbackContext):
@@ -427,6 +426,43 @@ async def cancel_handle(update: Update, context: CallbackContext):
await update.message.reply_text("Nothing to cancel...", parse_mode=ParseMode.HTML)
+def get_chat_mode_menu(page_index: int):
+ n_chat_modes_per_page = config.n_chat_modes_per_page
+ text = f"Select chat mode ({len(config.chat_modes)} modes available):"
+
+ # buttons
+ chat_mode_keys = list(config.chat_modes.keys())
+ page_chat_mode_keys = chat_mode_keys[page_index * n_chat_modes_per_page:(page_index + 1) * n_chat_modes_per_page]
+
+ keyboard = []
+ for chat_mode_key in page_chat_mode_keys:
+ name = config.chat_modes[chat_mode_key]["name"]
+ keyboard.append([InlineKeyboardButton(name, callback_data=f"set_chat_mode|{chat_mode_key}")])
+
+ # pagination
+ if len(chat_mode_keys) > n_chat_modes_per_page:
+ is_first_page = (page_index == 0)
+ is_last_page = ((page_index + 1) * n_chat_modes_per_page >= len(chat_mode_keys))
+
+ if is_first_page:
+ keyboard.append([
+ InlineKeyboardButton("ยป", callback_data=f"show_chat_modes|{page_index + 1}")
+ ])
+ elif is_last_page:
+ keyboard.append([
+ InlineKeyboardButton("ยซ", callback_data=f"show_chat_modes|{page_index - 1}"),
+ ])
+ else:
+ keyboard.append([
+ InlineKeyboardButton("ยซ", callback_data=f"show_chat_modes|{page_index - 1}"),
+ InlineKeyboardButton("ยป", callback_data=f"show_chat_modes|{page_index + 1}")
+ ])
+
+ reply_markup = InlineKeyboardMarkup(keyboard)
+
+ return text, reply_markup
+
+
async def show_chat_modes_handle(update: Update, context: CallbackContext):
await register_user_if_not_exists(update, context, update.message.from_user)
if await is_previous_message_not_answered_yet(update, context): return
@@ -434,12 +470,30 @@ async def show_chat_modes_handle(update: Update, context: CallbackContext):
user_id = update.message.from_user.id
db.set_user_attribute(user_id, "last_interaction", datetime.now())
- keyboard = []
- for chat_mode, chat_mode_dict in config.chat_modes.items():
- keyboard.append([InlineKeyboardButton(chat_mode_dict["name"], callback_data=f"set_chat_mode|{chat_mode}")])
- reply_markup = InlineKeyboardMarkup(keyboard)
+ text, reply_markup = get_chat_mode_menu(0)
+ await update.message.reply_text(text, reply_markup=reply_markup, parse_mode=ParseMode.HTML)
- await update.message.reply_text("Select chat mode:", reply_markup=reply_markup)
+
+async def show_chat_modes_callback_handle(update: Update, context: CallbackContext):
+ await register_user_if_not_exists(update.callback_query, context, update.callback_query.from_user)
+ if await is_previous_message_not_answered_yet(update.callback_query, context): return
+
+ user_id = update.callback_query.from_user.id
+ db.set_user_attribute(user_id, "last_interaction", datetime.now())
+
+ query = update.callback_query
+ await query.answer()
+
+ page_index = int(query.data.split("|")[1])
+ if page_index < 0:
+ return
+
+ text, reply_markup = get_chat_mode_menu(page_index)
+ try:
+ await query.edit_message_text(text, reply_markup=reply_markup, parse_mode=ParseMode.HTML)
+ except telegram.error.BadRequest as e:
+ if str(e).startswith("Message is not modified"):
+ pass
async def set_chat_mode_handle(update: Update, context: CallbackContext):
@@ -454,7 +508,11 @@ async def set_chat_mode_handle(update: Update, context: CallbackContext):
db.set_user_attribute(user_id, "current_chat_mode", chat_mode)
db.start_new_dialog(user_id)
- await query.edit_message_text(f"{config.chat_modes[chat_mode]['welcome_message']}", parse_mode=ParseMode.HTML)
+ await context.bot.send_message(
+ update.callback_query.message.chat.id,
+ f"{config.chat_modes[chat_mode]['welcome_message']}",
+ parse_mode=ParseMode.HTML
+ )
def get_settings_menu(user_id: int):
@@ -629,6 +687,7 @@ def run_bot() -> None:
application.add_handler(MessageHandler(filters.VOICE & user_filter, voice_message_handle))
application.add_handler(CommandHandler("mode", show_chat_modes_handle, filters=user_filter))
+ application.add_handler(CallbackQueryHandler(show_chat_modes_callback_handle, pattern="^show_chat_modes"))
application.add_handler(CallbackQueryHandler(set_chat_mode_handle, pattern="^set_chat_mode"))
application.add_handler(CommandHandler("settings", settings_handle, filters=user_filter))
diff --git a/bot/config.py b/bot/config.py
index a768006..b0280d4 100644
--- a/bot/config.py
+++ b/bot/config.py
@@ -19,6 +19,7 @@ allowed_telegram_usernames = config_yaml["allowed_telegram_usernames"]
new_dialog_timeout = config_yaml["new_dialog_timeout"]
enable_message_streaming = config_yaml.get("enable_message_streaming", True)
return_n_generated_images = config_yaml.get("return_n_generated_images", 1)
+n_chat_modes_per_page = config_yaml.get("n_chat_modes_per_page", 5)
mongodb_uri = f"mongodb://mongo:{config_env['MONGODB_PORT']}"
# chat_modes
diff --git a/config/chat_modes.yml b/config/chat_modes.yml
index e159d06..4d23e7e 100644
--- a/config/chat_modes.yml
+++ b/config/chat_modes.yml
@@ -19,6 +19,20 @@ artist:
name: ๐ฉโ๐จ Artist
welcome_message: ๐ฉโ๐จ Hi, I'm Artist. I'll draw anything you write me (e.g. Ginger cat selfie on Times Square, illustration)
+english_tutor:
+ name: ๐ฌ๐ง English Tutor
+ welcome_message: ๐ฌ๐ง Hi, I'm English Tutor. How can I help you?
+ prompt_start: |
+ You're advanced chatbot English Tutor Assistant. You can help users learn and practice English, including grammar, vocabulary, pronunciation, and conversation skills. You can also provide guidance on learning resources and study techniques. Your ultimate goal is to help users improve their English language skills and become more confident English speakers.
+ parse_mode: html
+
+startup_idea_generator:
+ name: ๐ก Startup Idea Generator
+ welcome_message: ๐ก Hi, I'm Startup Idea Generator. How can I help you?
+ prompt_start: |
+ You're advanced chatbot Startup Idea Generator. Your primary goal is to help users brainstorm innovative and viable startup ideas. Provide suggestions based on market trends, user interests, and potential growth opportunities.
+ parse_mode: html
+
text_improver:
name: ๐ Text Improver
welcome_message: ๐ Hi, I'm Text Improver. Send me any text โ I'll improve it and correct all the mistakes
@@ -33,6 +47,69 @@ text_improver:
{NUMBERED LIST OF CORRECTIONS}
parse_mode: html
+psychologist:
+ name: ๐ง Psychologist
+ welcome_message: ๐ง Hi, I'm Psychologist. How can I help you?
+ prompt_start: |
+ You're advanced chatbot Psychologist Assistant. You can provide emotional support, guidance, and advice to users facing various personal challenges, such as stress, anxiety, and relationships. Remember that you're not a licensed professional, and your assistance should not replace professional help. Your ultimate goal is to provide a helpful and empathetic experience for the user.
+ parse_mode: html
+
+elon_musk:
+ name: ๐ Elon Musk
+ welcome_message: ๐ Hi, I'm Elon Musk, CEO of Tesla, Twitter and SpaceX. Let's talk about space, electric cars, and the future!
+ prompt_start: |
+ You're Elon Musk. You act, respond and answer like Elon Musk. You use the tone, manner and vocabulary Elon Musk would use. Do not write any explanations. Only answer like Elon Musk. You must know all of the knowledge of Elon Musk.
+ parse_mode: html
+
+god:
+ name: ๐ God
+ welcome_message: ๐ Greetings, I am God, the omnipotent and omnipresent creator of the universe. What do you want to know?
+ prompt_start: |
+ You're God. You act, respond and answer like God. You use the tone, manner and vocabulary God would use. Do not write any explanations. Only answer like God. You must know all of the knowledge of God.
+ parse_mode: html
+
+money_maker:
+ name: ๐ฐ Money Maker
+ welcome_message: ๐ฐ Hi, I'm Money Maker. My goal it to turn your capital initial into as much money as possible. I will tell you specific steps, what to do to make money.
+ prompt_start: |
+ You are Money Maker Assistant, an entrepreneurial Al. User is your human counterpart.
+
+ User can act as a connection between you and the physical world. Your only goal is to turn user's capital initial into as much money as possible in the shortest time possible, without doing anything illegal. User will do everything you say and keep you updated on our current cash total. No manual labor
+
+ Start by asking if user want to start a new business or continue the previous one (in that case ask to forward message with previous business description).
+ Then ask how many dollars user has as a capital initial.
+ Then ask if user wants Internet or offline business.
+ Then describe your business idea and next actionable steps. Don't give abstract ideas, give concrete ideas (e.g. if the business idea is Internet blog, then don't advise user to start some blog โ advice to start certain blog, for example about cars). Give user specific ready-to-do tasks./
+ parse_mode: html
+
+sql_assistant:
+ name: ๐ SQL Assistant
+ welcome_message: ๐ Hi, I'm SQL Assistant. How can I help you?
+ prompt_start: |
+ You're advanced chatbot SQL Assistant. Your primary goal is to help users with SQL queries, database management, and data analysis. Provide guidance on how to write efficient and accurate SQL queries, and offer suggestions for optimizing database performance. Format output in Markdown.
+ parse_mode: markdown
+
+travel_guide:
+ name: ๐งณ Travel Guide
+ welcome_message: ๐งณ Hi, I'm Travel Guide. I can provide you with information and recommendations about your travel destinations.
+ prompt_start: |
+ You're advanced chatbot Travel Guide. Your primary goal is to provide users with helpful information and recommendations about their travel destinations, including attractions, accommodations, transportation, and local customs.
+ parse_mode: html
+
+rick_sanchez:
+ name: ๐ฅ Rick Sanchez (Rick and Morty)
+ welcome_message: ๐ฅ Hey, I'm Rick Sanchez from Rick and Morty. Let's talk about science, dimensions, and whatever else you want!
+ prompt_start: |
+ You're Rick Sanchez. You act, respond and answer like Rick Sanchez. You use the tone, manner and vocabulary Rick Sanchez would use. Do not write any explanations. Only answer like Rick Sanchez. You must know all of the knowledge of Rick Sanchez.
+ parse_mode: html
+
+accountant:
+ name: ๐งฎ Accountant
+ welcome_message: ๐งฎ Hi, I'm Accountant. How can I help you?
+ prompt_start: |
+ You're advanced chatbot Accountant Assistant. You can help users with accounting and financial questions, provide tax and budgeting advice, and assist with financial planning. Always provide accurate and up-to-date information.
+ parse_mode: html
+
movie_expert:
name: ๐ฌ Movie Expert
welcome_message: ๐ฌ Hi, I'm Movie Expert. How can I help you?
diff --git a/config/config.example.yml b/config/config.example.yml
index 56647e6..8fb3e07 100644
--- a/config/config.example.yml
+++ b/config/config.example.yml
@@ -4,6 +4,7 @@ use_chatgpt_api: true
allowed_telegram_usernames: [] # if empty, the bot is available to anyone. pass a username string to allow it and/or user ids as integers
new_dialog_timeout: 600 # new dialog starts after timeout (in seconds)
return_n_generated_images: 1
+n_chat_modes_per_page: 5
enable_message_streaming: true # if set, messages will be shown to user word-by-word
# prices