Explorar o código

修复ji_meng参数

kevin.yang hai 4 días
pai
achega
49a1e561c3

+ 15 - 0
data/groups.json

@@ -16,6 +16,21 @@
         "runcomfy_stop_env"
       ],
       "usage_example": "1. 使用 launch_comfy_env 启动云端环境,获取 server_id\n2. 使用 runcomfy_workflow_executor 在该环境上执行工作流,传入 server_id\n3. 使用 runcomfy_stop_env 停止环境释放资源,传入 server_id"
+    },
+    {
+      "group_id": "ji_meng_task_lifecycle",
+      "name": "即梦任务(创建与查询)",
+      "description": "先创建任务获取 task_id,再查询结果",
+      "category": "local",
+      "tool_ids": [
+        "ji_meng_add_task",
+        "ji_meng_query_task"
+      ],
+      "usage_order": [
+        "ji_meng_add_task",
+        "ji_meng_query_task"
+      ],
+      "usage_example": "1. 调用 ji_meng_add_task 传入 prompt,得到 task_id\n2. 轮询 ji_meng_query_task 传入 task_id,直到完成"
     }
   ],
   "version": "1.0"

+ 34 - 11
data/registry.json

@@ -384,21 +384,31 @@
     {
       "tool_id": "ji_meng_add_task",
       "name": "即梦-创建任务",
+      "tool_slug_ids": [],
       "category": "cv",
-      "description": "提交异步任务到上游(POST 转发 JI_MENG_API_BASE + add_task 路径)。",
+      "description": "提交异步任务到上游(本地服务转发 JI_MENG_API_BASE,POST /add_task)。需配置 tools/local/ji_meng/.env。",
       "input_schema": {
         "type": "object",
         "properties": {
+          "task_type": {
+            "type": "string",
+            "enum": [
+              "image",
+              "video"
+            ],
+            "description": "任务类型:图生/文生图或视频"
+          },
           "prompt": {
             "type": "string",
             "description": "任务描述 / 提示词"
           },
-          "extra": {
-            "type": "object",
-            "description": "可选,合并进上游 JSON body"
+          "image_url": {
+            "type": "string",
+            "description": "可选,图生类任务时的参考图 URL"
           }
         },
         "required": [
+          "task_type",
           "prompt"
         ]
       },
@@ -406,7 +416,8 @@
         "type": "object",
         "properties": {
           "task_id": {
-            "type": "string"
+            "type": "string",
+            "description": "任务 ID,用于 ji_meng_query_task"
           },
           "status": {
             "type": "string"
@@ -416,20 +427,22 @@
       "stream_support": false,
       "status": "active",
       "backend_runtime": "local",
-      "group_ids": [],
-      "tool_slug_ids": []
+      "group_ids": [
+        "ji_meng_task_lifecycle"
+      ]
     },
     {
       "tool_id": "ji_meng_query_task",
       "name": "即梦-查询任务",
+      "tool_slug_ids": [],
       "category": "cv",
-      "description": "按 task_id 查询上游任务状态与结果(POST 转发 query_task 路径)。",
+      "description": "按 task_id 查询任务状态与结果(本地服务转发上游,POST /query_task)。",
       "input_schema": {
         "type": "object",
         "properties": {
           "task_id": {
             "type": "string",
-            "description": "创建任务返回的任务 ID"
+            "description": "ji_meng_add_task 返回的任务 ID"
           }
         },
         "required": [
@@ -444,14 +457,24 @@
           },
           "status": {
             "type": "string"
+          },
+          "message": {
+            "type": "string"
+          },
+          "images": {
+            "type": "array",
+            "items": {
+              "type": "string"
+            }
           }
         }
       },
       "stream_support": false,
       "status": "active",
       "backend_runtime": "local",
-      "group_ids": [],
-      "tool_slug_ids": []
+      "group_ids": [
+        "ji_meng_task_lifecycle"
+      ]
     }
   ],
   "version": "2.0"

+ 0 - 6
data/sources.json

@@ -76,9 +76,6 @@
         "host_dir": "tools/local/ji_meng",
         "container_id": "",
         "image": "",
-        "remote_url": "",
-        "remote_path": "",
-        "remote_api_key": "",
         "hub_url": "",
         "hub_tool_path": "",
         "hub_api_key": "",
@@ -93,9 +90,6 @@
         "host_dir": "tools/local/ji_meng",
         "container_id": "",
         "image": "",
-        "remote_url": "",
-        "remote_path": "",
-        "remote_api_key": "",
         "hub_url": "",
         "hub_tool_path": "",
         "hub_api_key": "",

+ 3 - 1
tools/local/ji_meng/ji_meng_client.py

@@ -28,9 +28,11 @@ class JiMengClient:
             h["Authorization"] = f"Bearer {self.api_key}"
         return h
 
-    def submit_task(self, task_type: Literal['image', 'video'], prompt: str) -> dict[str, Any]:
+    def submit_task(self, task_type: Literal['image', 'video'], prompt: str, image_url: str | None = None) -> dict[str, Any]:
         url = f"{self.base}{self.add_path if self.add_path.startswith('/') else '/' + self.add_path}"
         body: dict[str, Any] = {"task_type": task_type, "prompt": prompt}
+        if image_url:
+            body["image_url"] = image_url
         resp = requests.post(url, json=body, headers=self._headers(), timeout=120)
         resp.raise_for_status()
         return resp.json()

+ 2 - 1
tools/local/ji_meng/main.py

@@ -30,6 +30,7 @@ app = FastAPI(title="Ji Meng Task API")
 class AddTaskRequest(BaseModel):
     task_type: Literal['image', 'video'] = Field(default=..., description="任务类型")
     prompt: str = Field(..., description="任务描述 / 提示词")
+    image_url: str | None = Field(default=None, description="图片 URL")
 
 
 class QueryTaskRequest(BaseModel):
@@ -45,7 +46,7 @@ def health() -> dict:
 def add_task(req: AddTaskRequest) -> dict:
     try:
         client = JiMengClient()
-        return client.submit_task(task_type=req.task_type, prompt=req.prompt)
+        return client.submit_task(task_type=req.task_type, prompt=req.prompt, image_url=req.image_url)
     except ValueError as e:
         raise HTTPException(status_code=503, detail=str(e)) from e
     except Exception as e: