mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
* fix: handle video attachment for llm * fix: harden llm video attachment handling --------- Co-authored-by: 邹永赫 <1259085392@qq.com>
56 lines
5.1 KiB
Diff
56 lines
5.1 KiB
Diff
From f42066dc5b8eecfb79a4aaf1d29b5ad6ae862871 Mon Sep 17 00:00:00 2001
|
|
From: xunxi <beijinghxn20081218@qq.com>
|
|
Date: Sun, 19 Apr 2026 23:21:51 +0800
|
|
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=A4=84=E7=90=86vi?=
|
|
=?UTF-8?q?deo=E5=AD=97=E6=AE=B5=E7=9A=84=E9=94=99=E8=AF=AF?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
astrbot/core/astr_main_agent.py | 14 +++++++++++++-
|
|
1 file changed, 13 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py
|
|
index 0b74d63c..feafcc0e 100644
|
|
--- a/astrbot/core/astr_main_agent.py
|
|
+++ b/astrbot/core/astr_main_agent.py
|
|
@@ -29,7 +29,7 @@ from astrbot.core.astr_main_agent_resources import (
|
|
TOOL_CALL_PROMPT_SKILLS_LIKE_MODE,
|
|
)
|
|
from astrbot.core.conversation_mgr import Conversation
|
|
-from astrbot.core.message.components import File, Image, Record, Reply
|
|
+from astrbot.core.message.components import File, Image, Record, Reply, Video
|
|
from astrbot.core.persona_error_reply import (
|
|
extract_persona_custom_error_message_from_persona,
|
|
set_persona_custom_error_message_on_event,
|
|
@@ -1278,6 +1278,11 @@ async def build_main_agent(
|
|
text=f"[File Attachment: name {file_name}, path {file_path}]"
|
|
)
|
|
)
|
|
+ elif isinstance(comp, Video):
|
|
+ video_path = await comp.convert_to_file_path()
|
|
+ req.extra_user_content_parts.append(
|
|
+ TextPart(text=f"[Video Attachment: path {video_path}]")
|
|
+ )
|
|
# quoted message attachments
|
|
reply_comps = [
|
|
comp for comp in event.message_obj.message if isinstance(comp, Reply)
|
|
@@ -1316,6 +1321,13 @@ async def build_main_agent(
|
|
)
|
|
)
|
|
)
|
|
+ elif isinstance(reply_comp, Video):
|
|
+ video_path = await reply_comp.convert_to_file_path()
|
|
+ req.extra_user_content_parts.append(
|
|
+ TextPart(
|
|
+ text=f"[Video Attachment in quoted message: path {video_path}]"
|
|
+ )
|
|
+ )
|
|
|
|
# Fallback quoted image extraction for reply-id-only payloads, or when
|
|
# embedded reply chain only contains placeholders (e.g. [Forward Message], [Image]).
|
|
--
|
|
2.53.0.windows.3
|
|
|