feat: QuerySitesTool 增加返回 cookie 字段

This commit is contained in:
jxxghp
2026-03-24 22:53:30 +08:00
parent 4a789297fe
commit dcca318733
+21 -12
View File
@@ -12,11 +12,18 @@ from app.log import logger
class QuerySitesInput(BaseModel): class QuerySitesInput(BaseModel):
"""查询站点工具的输入参数模型""" """查询站点工具的输入参数模型"""
explanation: str = Field(..., description="Clear explanation of why this tool is being used in the current context")
status: Optional[str] = Field("all", explanation: str = Field(
description="Filter sites by status: 'active' for enabled sites, 'inactive' for disabled sites, 'all' for all sites") ...,
name: Optional[str] = Field(None, description="Clear explanation of why this tool is being used in the current context",
description="Filter sites by name (partial match, optional)") )
status: Optional[str] = Field(
"all",
description="Filter sites by status: 'active' for enabled sites, 'inactive' for disabled sites, 'all' for all sites",
)
name: Optional[str] = Field(
None, description="Filter sites by name (partial match, optional)"
)
class QuerySitesTool(MoviePilotTool): class QuerySitesTool(MoviePilotTool):
@@ -28,19 +35,21 @@ class QuerySitesTool(MoviePilotTool):
"""根据查询参数生成友好的提示消息""" """根据查询参数生成友好的提示消息"""
status = kwargs.get("status", "all") status = kwargs.get("status", "all")
name = kwargs.get("name") name = kwargs.get("name")
parts = ["正在查询站点"] parts = ["正在查询站点"]
if status != "all": if status != "all":
status_map = {"active": "已启用", "inactive": "已禁用"} status_map = {"active": "已启用", "inactive": "已禁用"}
parts.append(f"状态: {status_map.get(status, status)}") parts.append(f"状态: {status_map.get(status, status)}")
if name: if name:
parts.append(f"名称: {name}") parts.append(f"名称: {name}")
return " | ".join(parts) if len(parts) > 1 else parts[0] return " | ".join(parts) if len(parts) > 1 else parts[0]
async def run(self, status: Optional[str] = "all", name: Optional[str] = None, **kwargs) -> str: async def run(
self, status: Optional[str] = "all", name: Optional[str] = None, **kwargs
) -> str:
logger.info(f"执行工具: {self.name}, 参数: status={status}, name={name}") logger.info(f"执行工具: {self.name}, 参数: status={status}, name={name}")
try: try:
site_oper = SiteOper() site_oper = SiteOper()
@@ -68,9 +77,10 @@ class QuerySitesTool(MoviePilotTool):
"url": s.url, "url": s.url,
"pri": s.pri, "pri": s.pri,
"is_active": s.is_active, "is_active": s.is_active,
"cookie": s.cookie,
"downloader": s.downloader, "downloader": s.downloader,
"proxy": s.proxy, "proxy": s.proxy,
"timeout": s.timeout "timeout": s.timeout,
} }
simplified_sites.append(simplified) simplified_sites.append(simplified)
result_json = json.dumps(simplified_sites, ensure_ascii=False, indent=2) result_json = json.dumps(simplified_sites, ensure_ascii=False, indent=2)
@@ -79,4 +89,3 @@ class QuerySitesTool(MoviePilotTool):
except Exception as e: except Exception as e:
logger.error(f"查询站点失败: {e}", exc_info=True) logger.error(f"查询站点失败: {e}", exc_info=True)
return f"查询站点时发生错误: {str(e)}" return f"查询站点时发生错误: {str(e)}"