mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 19:47:41 +08:00
feat: add batch AI re-organize for transfer history and search result recommendation
- Implement batch AI re-organize endpoint for transfer history with progress tracking - Add batch_manual_transfer_redo system task template and prompt generation - Refactor agent_manager to support generic background prompt execution - Add AIRecommendChain for search result recommendation using agent background prompt - Update search endpoints to use new AIRecommendChain and remove legacy code - Enhance test cases for batch manual transfer redo - Minor code cleanup and style fixes
This commit is contained in:
@@ -10,10 +10,10 @@ class AgentInitializer:
|
||||
"""
|
||||
AI智能体初始化器
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self._initialized = False
|
||||
|
||||
|
||||
async def initialize(self) -> bool:
|
||||
"""
|
||||
初始化AI智能体管理器
|
||||
@@ -22,16 +22,16 @@ class AgentInitializer:
|
||||
if not settings.AI_AGENT_ENABLE:
|
||||
logger.info("AI智能体功能未启用")
|
||||
return True
|
||||
|
||||
|
||||
await agent_manager.initialize()
|
||||
self._initialized = True
|
||||
logger.info("AI智能体管理器初始化成功")
|
||||
return True
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"AI智能体管理器初始化失败: {e}")
|
||||
return False
|
||||
|
||||
|
||||
async def cleanup(self) -> None:
|
||||
"""
|
||||
清理AI智能体管理器
|
||||
@@ -39,11 +39,10 @@ class AgentInitializer:
|
||||
try:
|
||||
if not self._initialized:
|
||||
return
|
||||
|
||||
await agent_manager.close()
|
||||
self._initialized = False
|
||||
logger.info("AI智能体管理器已关闭")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"关闭AI智能体管理器时发生错误: {e}")
|
||||
|
||||
@@ -60,7 +59,7 @@ def init_agent():
|
||||
if not settings.AI_AGENT_ENABLE:
|
||||
logger.info("AI智能体功能未启用")
|
||||
return True
|
||||
|
||||
|
||||
# 在新的事件循环中初始化AI智能体管理器
|
||||
def run_init():
|
||||
loop = asyncio.new_event_loop()
|
||||
@@ -77,13 +76,13 @@ def init_agent():
|
||||
return False
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
# 在后台线程中初始化
|
||||
init_thread = threading.Thread(target=run_init, daemon=True)
|
||||
init_thread.start()
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"初始化AI智能体时发生错误: {e}")
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user