From 6ea6bb88e55429968cf99ad5e769cbeebdf80532 Mon Sep 17 00:00:00 2001 From: shouldnotappearcalm <1191465097@qq.com> Date: Tue, 27 Feb 2024 00:21:11 +0800 Subject: [PATCH 1/2] fix: Solve word spelling problems --- .project_hierarchy.json | 4 ++-- XAgent/data_structure/plan.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.project_hierarchy.json b/.project_hierarchy.json index af54982..defa4bb 100644 --- a/.project_hierarchy.json +++ b/.project_hierarchy.json @@ -6774,7 +6774,7 @@ "code_end_line": 152, "parent": null, "have_return": true, - "code_content": "class Plan():\n \"\"\"Class representing a task plan.\n\n Attributes:\n father (Optional[Plan]): Parent task plan.\n children (List[Plan]): List of child task plans.\n data (TaskSaveItem): Data items related to the task plan.\n process_node (ToolNode): Node responsible for the task plan processing.\n \"\"\"\n \n def __init__(self, data: TaskSaveItem):\n \"\"\"Initialises a Plan object.\n\n Args:\n data (TaskSaveItem): Data related to the task plan.\n \"\"\"\n self.father: Optional[Plan] = None\n self.children: List[Plan] = []\n self.data: TaskSaveItem = data\n self.process_node: ToolNode = None \n \n def to_json(self, posterior=True):\n \"\"\"Converts Plan object to JSON.\n\n Args:\n posterior (bool): Determines whether the task's posterior data \n is also returned.\n\n Returns:\n root_json (dict): JSON format representation of the Plan object.\n \"\"\"\n root_json = self.data.to_json(posterior=posterior)\n if self.process_node:\n root_json[\"submit_result\"] = self.process_node.data[\"command\"][\"properties\"]\n\n # if self.father != None:\n root_json[\"task_id\"] = self.get_subtask_id(to_str=True)\n if len(self.children) > 0:\n root_json[\"subtask\"] = [ subtask.to_json() for subtask in self.children]\n return root_json\n \n def get_subtask_id(self, to_str=False):\n \"\"\"Gets the subtask ID.\n\n Args:\n to_str (bool): Determines if returned ID is string.\n\n Returns:\n subtask_id_list (list): List of subtask IDs.\n \"\"\"\n subtask_id_list = self.get_subtask_id_list()\n if to_str:\n subtask_id_list = [str(cont) for cont in subtask_id_list]\n return \".\".join(subtask_id_list)\n else:\n return subtask_id_list\n\n def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n fahter_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n fahter_subtask_id.append(child_id)\n return fahter_subtask_id\n \n @classmethod\n def make_relation(cls, father, child):\n \"\"\"Establishes a parent-child relationship between two plans.\n\n Args:\n father: Parent plan.\n child: Child plan.\n \"\"\"\n father.children.append(child)\n child.father = father\n\n def get_root(self):\n \"\"\"Fetches the root of the Plan tree.\n\n Returns:\n Root Plan object.\n \"\"\"\n if self.father == None:\n return self\n return self.father.get_root()\n\n def get_depth(self):\n \"\"\"Returns the depth of the Plan tree.\n\n Returns:\n Tree depth as an integer.\n \"\"\"\n if self.father == None:\n return 1\n return 1 + self.father.get_depth()\n\n @classmethod\n def get_inorder_travel(cls, now_plan):\n \"\"\"Performs an inorder traversal of the plan tree.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n All plans in the tree in inorder.\n \"\"\"\n result_list = [now_plan]\n for child in now_plan.children:\n result_list.extend(Plan.get_inorder_travel(child))\n return result_list\n\n @classmethod\n def pop_next_subtask(cls, now_plan):\n \"\"\"Fetches the next subtask in the queue.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Next subtask in the queue.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n for subtask in all_plans[order_id + 1:]:\n if subtask.data.status == TaskStatusCode.TODO:\n return subtask\n return None\n\n @classmethod\n def get_remaining_subtask(cls, now_plan):\n \"\"\"Gets all remaining subtasks from a given point.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Array of all remaining subtasks.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n return all_plans[order_id:]", + "code_content": "class Plan():\n \"\"\"Class representing a task plan.\n\n Attributes:\n father (Optional[Plan]): Parent task plan.\n children (List[Plan]): List of child task plans.\n data (TaskSaveItem): Data items related to the task plan.\n process_node (ToolNode): Node responsible for the task plan processing.\n \"\"\"\n \n def __init__(self, data: TaskSaveItem):\n \"\"\"Initialises a Plan object.\n\n Args:\n data (TaskSaveItem): Data related to the task plan.\n \"\"\"\n self.father: Optional[Plan] = None\n self.children: List[Plan] = []\n self.data: TaskSaveItem = data\n self.process_node: ToolNode = None \n \n def to_json(self, posterior=True):\n \"\"\"Converts Plan object to JSON.\n\n Args:\n posterior (bool): Determines whether the task's posterior data \n is also returned.\n\n Returns:\n root_json (dict): JSON format representation of the Plan object.\n \"\"\"\n root_json = self.data.to_json(posterior=posterior)\n if self.process_node:\n root_json[\"submit_result\"] = self.process_node.data[\"command\"][\"properties\"]\n\n # if self.father != None:\n root_json[\"task_id\"] = self.get_subtask_id(to_str=True)\n if len(self.children) > 0:\n root_json[\"subtask\"] = [ subtask.to_json() for subtask in self.children]\n return root_json\n \n def get_subtask_id(self, to_str=False):\n \"\"\"Gets the subtask ID.\n\n Args:\n to_str (bool): Determines if returned ID is string.\n\n Returns:\n subtask_id_list (list): List of subtask IDs.\n \"\"\"\n subtask_id_list = self.get_subtask_id_list()\n if to_str:\n subtask_id_list = [str(cont) for cont in subtask_id_list]\n return \".\".join(subtask_id_list)\n else:\n return subtask_id_list\n\n def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n father_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n father_subtask_id.append(child_id)\n return father_subtask_id\n \n @classmethod\n def make_relation(cls, father, child):\n \"\"\"Establishes a parent-child relationship between two plans.\n\n Args:\n father: Parent plan.\n child: Child plan.\n \"\"\"\n father.children.append(child)\n child.father = father\n\n def get_root(self):\n \"\"\"Fetches the root of the Plan tree.\n\n Returns:\n Root Plan object.\n \"\"\"\n if self.father == None:\n return self\n return self.father.get_root()\n\n def get_depth(self):\n \"\"\"Returns the depth of the Plan tree.\n\n Returns:\n Tree depth as an integer.\n \"\"\"\n if self.father == None:\n return 1\n return 1 + self.father.get_depth()\n\n @classmethod\n def get_inorder_travel(cls, now_plan):\n \"\"\"Performs an inorder traversal of the plan tree.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n All plans in the tree in inorder.\n \"\"\"\n result_list = [now_plan]\n for child in now_plan.children:\n result_list.extend(Plan.get_inorder_travel(child))\n return result_list\n\n @classmethod\n def pop_next_subtask(cls, now_plan):\n \"\"\"Fetches the next subtask in the queue.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Next subtask in the queue.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n for subtask in all_plans[order_id + 1:]:\n if subtask.data.status == TaskStatusCode.TODO:\n return subtask\n return None\n\n @classmethod\n def get_remaining_subtask(cls, now_plan):\n \"\"\"Gets all remaining subtasks from a given point.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Array of all remaining subtasks.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n return all_plans[order_id:]", "name_column": 6 }, "__init__": { @@ -6818,7 +6818,7 @@ "code_end_line": 73, "parent": "Plan", "have_return": true, - "code_content": " def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n fahter_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n fahter_subtask_id.append(child_id)\n return fahter_subtask_id\n", + "code_content": " def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n father_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n father_subtask_id.append(child_id)\n return father_subtask_id\n", "name_column": 8 }, "make_relation": { diff --git a/XAgent/data_structure/plan.py b/XAgent/data_structure/plan.py index 011057a..d64d5ad 100644 --- a/XAgent/data_structure/plan.py +++ b/XAgent/data_structure/plan.py @@ -67,10 +67,10 @@ def get_subtask_id_list(self): """ if self.father == None: return [1] - fahter_subtask_id = self.father.get_subtask_id() + father_subtask_id = self.father.get_subtask_id() child_id = self.father.children.index(self) + 1 - fahter_subtask_id.append(child_id) - return fahter_subtask_id + father_subtask_id.append(child_id) + return father_subtask_id @classmethod def make_relation(cls, father, child): From 9313feaa0242a22e3beae8d02b4f9e55da831e24 Mon Sep 17 00:00:00 2001 From: shouldnotappearcalm <1191465097@qq.com> Date: Sat, 6 Apr 2024 23:35:33 +0800 Subject: [PATCH 2/2] fix(): fix get cookie url --- ToolServer/README.md | 2 +- ToolServer/README_ZH.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ToolServer/README.md b/ToolServer/README.md index ac019a9..4c8ec13 100644 --- a/ToolServer/README.md +++ b/ToolServer/README.md @@ -36,7 +36,7 @@ docker compose up Note that you should install `docker` and `docker-compose` first. ## 🧩 API Documentation -### /get_cookies +### /get_cookie This path will return a cookie that contains the node_id of the ToolServerNode instance. All the following requests should use this cookie to identify the ToolServerNode instance. diff --git a/ToolServer/README_ZH.md b/ToolServer/README_ZH.md index e6cd164..3b43bae 100644 --- a/ToolServer/README_ZH.md +++ b/ToolServer/README_ZH.md @@ -36,7 +36,7 @@ docker compose up 请注意,你需要提前安装`docker`和`docker-compose`。 ## 🧩 API说明 -### /get_cookies +### /get_cookie 该路径将返回一个cookie,其中包含ToolServerNode实例的node_id。 所有后续的请求都需要使用该cookie来识别ToolServerNode实例。