mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 19:47:41 +08:00
disable agent message tools for ui background tasks
This commit is contained in:
@@ -79,6 +79,15 @@ class MoviePilotToolFactory:
|
||||
MoviePilot工具工厂
|
||||
"""
|
||||
|
||||
_MESSAGE_TOOL_CLASSES = frozenset(
|
||||
{
|
||||
SendMessageTool,
|
||||
AskUserChoiceTool,
|
||||
SendLocalFileTool,
|
||||
SendVoiceMessageTool,
|
||||
}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _should_enable_choice_tool(channel: str = None) -> bool:
|
||||
if not channel:
|
||||
@@ -100,6 +109,7 @@ class MoviePilotToolFactory:
|
||||
username: str = None,
|
||||
stream_handler: Callable = None,
|
||||
agent_context: dict = None,
|
||||
allow_message_tools: bool = True,
|
||||
) -> List[MoviePilotTool]:
|
||||
"""
|
||||
创建MoviePilot工具列表
|
||||
@@ -181,6 +191,11 @@ class MoviePilotToolFactory:
|
||||
)
|
||||
# 创建内置工具
|
||||
for ToolClass in tool_definitions:
|
||||
if (
|
||||
not allow_message_tools
|
||||
and ToolClass in MoviePilotToolFactory._MESSAGE_TOOL_CLASSES
|
||||
):
|
||||
continue
|
||||
tool = ToolClass(session_id=session_id, user_id=user_id)
|
||||
tool.set_message_attr(channel=channel, source=source, username=username)
|
||||
tool.set_stream_handler(stream_handler=stream_handler)
|
||||
@@ -196,6 +211,11 @@ class MoviePilotToolFactory:
|
||||
tool_classes = plugin_info.get("tools", [])
|
||||
for ToolClass in tool_classes:
|
||||
try:
|
||||
if (
|
||||
not allow_message_tools
|
||||
and ToolClass in MoviePilotToolFactory._MESSAGE_TOOL_CLASSES
|
||||
):
|
||||
continue
|
||||
# 验证工具类是否继承自 MoviePilotTool
|
||||
if not issubclass(ToolClass, MoviePilotTool):
|
||||
logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user