Commit 22bcb36

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-06-18 14:20:32
fix(podcast): fix AI summary
1 parent 20e78bc
Changed files (1)
src
others
src/others/podcast.py
@@ -94,22 +94,24 @@ async def summary_pods(client: Client):
                     subtitle_caption += f"\n⚡️[即时预览]({telegraph_url})"
                 await send2tg(client, message, texts=remove_img(audio_caption), media=media, reply_msg_id=-1)  # Telegram DO NOT allow img tag in messages
                 with io.BytesIO(subtitles.encode("utf-8")) as f:
-                    await client.send_document(message.chat.id, f, file_name=f"{entry['title']}.txt", caption=subtitle_caption)
+                    txt_msg: Message = await client.send_document(message.chat.id, f, file_name=f"{entry['title']}.txt", caption=subtitle_caption)  # type: ignore
 
                 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
+                cache.delete(f"parse_msg-{txt_msg.chat.id}-{txt_msg.id}")
                 ai_msg = Message(
-                    id=rand_number(),
-                    chat=message.chat,
+                    id=txt_msg.id,
+                    chat=txt_msg.chat,
                     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)
+                gpt_res = await gpt_response(client, ai_msg, include_thoughts=False, append_grounding=False, show_progress=True)
+                cache.delete(f"parse_msg-{txt_msg.chat.id}-{txt_msg.id}")
                 feed_item = match_item(feed_xml, entry)
-                update_item(save_feed_xml, feed_item, prefix_desc=gpt_res["texts"])
+                update_item(save_feed_xml, feed_item, prefix_desc=gpt_res.get("texts", ""))
                 await set_cf_r2(entry["db_key"], data={"title": entry["title"], "url": entry["link"], "file": enclosure})
                 has_update = True
             except Exception as e: