mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-11 23:43:15 +08:00
fix(agent): resolve circular import by lazy-importing Command in run_slash_command and list_slash_commands
This commit is contained in:
@@ -6,7 +6,6 @@ from typing import Optional, Type
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from app.agent.tools.base import MoviePilotTool
|
from app.agent.tools.base import MoviePilotTool
|
||||||
from app.command import Command
|
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +39,8 @@ class ListSlashCommandsTool(MoviePilotTool):
|
|||||||
logger.info(f"执行工具: {self.name}")
|
logger.info(f"执行工具: {self.name}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
from app.command import Command
|
||||||
|
|
||||||
command_obj = Command()
|
command_obj = Command()
|
||||||
all_commands = command_obj.get_commands()
|
all_commands = command_obj.get_commands()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from typing import Optional, Type
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from app.agent.tools.base import MoviePilotTool
|
from app.agent.tools.base import MoviePilotTool
|
||||||
from app.command import Command
|
|
||||||
from app.core.event import eventmanager
|
from app.core.event import eventmanager
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas.types import EventType, MessageChannel
|
from app.schemas.types import EventType, MessageChannel
|
||||||
@@ -57,6 +56,8 @@ class RunSlashCommandTool(MoviePilotTool):
|
|||||||
command = f"/{command}"
|
command = f"/{command}"
|
||||||
|
|
||||||
# 从全局 Command 单例中验证命令是否存在(包含系统预设命令 + 插件命令 + 其他命令)
|
# 从全局 Command 单例中验证命令是否存在(包含系统预设命令 + 插件命令 + 其他命令)
|
||||||
|
from app.command import Command
|
||||||
|
|
||||||
cmd_name = command.split()[0]
|
cmd_name = command.split()[0]
|
||||||
command_obj = Command()
|
command_obj = Command()
|
||||||
matched_command = command_obj.get(cmd_name)
|
matched_command = command_obj.get(cmd_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user