Skip to content
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions astrbot/core/astr_agent_tool_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SEND_MESSAGE_TO_USER_TOOL,
)
from astrbot.core.cron.events import CronMessageEvent
from astrbot.core.message.components import Image
from astrbot.core.message.message_event_result import (
CommandResult,
MessageChain,
Expand Down Expand Up @@ -165,6 +166,28 @@ async def _execute_handoff(
):
input_ = tool_args.get("input")
image_urls = tool_args.get("image_urls")
if image_urls is None:
image_urls = []
elif isinstance(image_urls, str):
image_urls = [image_urls]
Comment thread
zouyonghe marked this conversation as resolved.
Outdated
else:
try:
image_urls = list(image_urls)
except (TypeError, ValueError):
image_urls = [image_urls]

# 获取当前事件中的图片
event = run_context.context.event
if event.message_obj and event.message_obj.message:
for component in event.message_obj.message:
if isinstance(component, Image):
try:
# 调用组件的 convert_to_file_path 异步方法
path = await component.convert_to_file_path()
if path and path not in image_urls:
image_urls.append(path)
Comment thread
a61995987 marked this conversation as resolved.
Outdated
except Exception as e:
logger.error(f"转换图片失败: {e}")

# Build handoff toolset from registered tools plus runtime computer tools.
toolset = cls._build_handoff_toolset(run_context, tool.agent.tools)
Expand Down