节点文件夹迁移到jingrow/ai/nodes

This commit is contained in:
jingrow 2025-10-31 21:23:20 +08:00
parent 7ad5b29276
commit 0efe02fafc
43 changed files with 8 additions and 13 deletions

View File

@ -8,14 +8,10 @@ from typing import Dict, Any
class NodeExecutor:
"""节点执行器 - 支持多语言节点执行
迁移至 local_ai_agent 以便与本地AI节点实现保持聚合
"""
"""节点执行器 - 支持多语言节点执行"""
def __init__(self):
# 更新为新的节点路径local_ai_agent/nodes
self.nodes_base_path = "ai/pagetype/local_ai_agent/nodes"
self.nodes_base_path = "ai/nodes"
async def execute_node(self, node_type: str, flow_id: str, context: Dict[str, Any],
inputs: Dict[str, Any], config: Dict[str, Any], session_cookie: str = None) -> Dict[str, Any]:
@ -41,7 +37,6 @@ class NodeExecutor:
"""检测节点实现文件"""
# 获取当前文件所在目录的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建到jingrow根目录的路径 (ai/pagetype/local_ai_agent -> jingrow)
jingrow_root = os.path.dirname(os.path.dirname(os.path.dirname(current_dir)))
node_path = os.path.join(jingrow_root, self.nodes_base_path, node_type)
@ -58,7 +53,7 @@ class NodeExecutor:
"""执行Python节点"""
try:
# 动态导入Python模块
module_path = f"jingrow.ai.pagetype.local_ai_agent.nodes.{node_type}.{node_type}"
module_path = f"jingrow.ai.nodes.{node_type}.{node_type}"
module = importlib.import_module(module_path)
# 设置session_cookie和flow_id到context

View File

@ -12,7 +12,7 @@ router = APIRouter()
@router.post("/jingrow/node-definitions/export")
async def export_node_definition(payload: Dict[str, Any]):
"""
导出节点定义metadata + schema JSON 文件backend/nodes/{type}/{type}.json
导出节点定义metadata + schema JSON 文件
"""
try:
metadata = payload.get("metadata") or {}
@ -25,7 +25,7 @@ async def export_node_definition(payload: Dict[str, Any]):
current_file = Path(__file__).resolve()
jingrow_root = current_file.parents[1] # 修正路径层级
new_root = jingrow_root / "ai" / "pagetype" / "local_ai_agent" / "nodes"
new_root = jingrow_root / "ai" / "nodes"
target = new_root / node_type / f"{node_type}.json"
atomic_write_json(target, export_data)
return {"success": True, "path": str(target)}
@ -41,7 +41,7 @@ async def import_local_node_definitions():
try:
current_file = Path(__file__).resolve()
jingrow_root = current_file.parents[1] # 修正路径层级
nodes_root = jingrow_root / "ai" / "pagetype" / "local_ai_agent" / "nodes"
nodes_root = jingrow_root / "ai" / "nodes"
if not nodes_root.exists():
return {"success": True, "matched": 0, "imported": 0, "skipped_existing": 0}
@ -120,7 +120,7 @@ async def get_all_node_metadata():
try:
current_file = Path(__file__).resolve()
jingrow_root = current_file.parents[1] # 修正路径层级
nodes_root = jingrow_root / "ai" / "pagetype" / "local_ai_agent" / "nodes"
nodes_root = jingrow_root / "ai" / "nodes"
if not nodes_root.exists():
return {"success": True, "data": {}}
@ -169,7 +169,7 @@ async def get_node_schema(node_type: str):
try:
current_file = Path(__file__).resolve()
jingrow_root = current_file.parents[1]
nodes_root = jingrow_root / "ai" / "pagetype" / "local_ai_agent" / "nodes"
nodes_root = jingrow_root / "ai" / "nodes"
json_file = nodes_root / node_type / f"{node_type}.json"
if not json_file.exists():