Commit 712b891

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-06-13 03:48:27
fix(gpt): fix `PREFIX.GPT` with multiple prefixes
1 parent 5264e7c
Changed files (3)
src
llm
others
subtitles
src/llm/gpt.py
@@ -48,7 +48,7 @@ def is_gpt_conversation(message: Message) -> bool:
         return False
     if BOT_TIPS in info["text"]:
         return False
-    if startswith_prefix(info["text"], prefix=[PREFIX.GPT, PREFIX.GENIMG, "/gpt", "/gemini", "/ds", "/qwen", "/doubao", "/grok"]):
+    if startswith_prefix(info["text"], prefix=[PREFIX.GPT, PREFIX.GENIMG]):
         return True
     # is replying to gpt-bot response message?
     if not message.reply_to_message:
src/others/podcast.py
@@ -99,11 +99,12 @@ async def summary_pods(client: Client):
                 prompt = f"这是播客栏目《{feed_title}》的一期节目详情:\n节目标题: {entry['title']}\n节目播出日期: {pubdate}"
                 prompt += f"\n节目时长: {readable_time(entry['itunes_duration'])}\n节目简介: {desc}"
                 prompt += "\n请解读该播客内容, 只需关注内容本身, 不用概述播客的基本信息, 例如播客的标题, 日期, 时长等"
+                ai_cmd = next((x.strip() for x in PREFIX.GPT.split(",") if x.strip()), "")
                 # Construct a message to call GPT
                 ai_msg = Message(
                     id=rand_number(),
                     chat=message.chat,
-                    text=Str(f"{PREFIX.GPT} {remove_img(prompt)}"),
+                    text=Str(f"{ai_cmd} {remove_img(prompt)}"),
                     reply_to_message=Message(id=rand_number(), chat=message.chat, text=Str(subtitles)),
                 )
                 gpt_res = await gpt_response(client, ai_msg, include_thoughts=False, append_grounding=False)
src/subtitles/subtitle.py
@@ -133,11 +133,12 @@ async def get_subtitle(
         prompt = f"节目标题: {vinfo['title']}\n发布日期: {vinfo['date']:%Y-%m-%d %H:%M:%S}\n节目简介: {description}\n"
         prompt += f"\n这是{matched['platform'].title()}视频作者【{vinfo['author']}】的一期节目详情, 请解读本期节目内容。"
         prompt += "\n注意: 不要复述节目标题、作者、日期、简介等基本信息, 不要进行任何寒暄与问候, 直接输出节目内容解读。"
+        ai_cmd = next((x.strip() for x in PREFIX.GPT.split(",") if x.strip()), "")
         # Construct a message to call GPT
         ai_msg = Message(
             id=subtitle_msg.id,
             chat=subtitle_msg.chat,
-            text=Str(f"{PREFIX.GPT} {prompt}"),
+            text=Str(f"{ai_cmd} {prompt}"),
             from_user=message.from_user,
             reply_to_message=Message(id=rand_number(), chat=subtitle_msg.chat, from_user=message.from_user, text=Str(subtitles)),
         )