H-T-H / Gemini-Telegram-Bot

用Gemini API实现的Telegram机器人 A Telegram Bot using Gemini API
https://railway.app/template/HIsbMv?referralCode=4LyW6R
Apache License 2.0
132 stars 52 forks source link

如何默认使用1.5Pro [How to default the model to Gemini 1.5 pro] #11

Closed zenghaojim33 closed 4 months ago

zenghaojim33 commented 4 months ago

I don't want to add /gemini_pro for every questions I send, is there a way to default the model to 1.5 pro? Thanks!

H-T-H commented 4 months ago

将292行的async def gemini_private_handler(message: Message):函数改成以下内容:

    async def gemini_private_handler(message: Message):
        m = message.text.strip()
        player = None 
        # Check if the player is already in gemini_player_dict.
        if str(message.from_user.id) not in gemini_pro_player_dict:
            player = await make_new_gemini_pro_convo()
            gemini_pro_player_dict[str(message.from_user.id)] = player
        else:
            player =  gemini_pro_player_dict[str(message.from_user.id)]
        # Control the length of the history record.
        if len(player.history) > 10:
            player.history = player.history[2:]
        try:
            sent_message = await bot.reply_to(message, before_generate_info)
            await send_message(player, m)
            try:
                await bot.edit_message_text(escape(player.last.text), chat_id=sent_message.chat.id, message_id=sent_message.message_id, parse_mode="MarkdownV2")
            except:
                await bot.edit_message_text(escape(player.last.text), chat_id=sent_message.chat.id, message_id=sent_message.message_id)
        except Exception:
            traceback.print_exc()
            await bot.reply_to(message, error_info)

但这会产生一个问题,不能在私聊中使用gemini-pro1.0,因为我把私聊中的/gemini命令禁止了,晚点可能会修改一下源代码

H-T-H commented 4 months ago

加了个switch命令,可以用 /switch 更改默认的模型