def task_stack_push( self, task: Task, parent_memid: str = None, chat_effect: bool = False ) -> "TaskNode": """Create a task object in memory, add triples and add to task stack Args: task (Task): The task to be pushed parent_memid (string): Memory ID of the task's parent chat_effect (bool): If the task was a result of a chat, add the triple. Returns: TaskNode: A TaskNode object Examples :: >>> task = Move(agent, {"target": pos_to_np([0, 0 , 0]), "approx" : 3}) >>> parent_memid = '10517cc584844659907ccfa6161e9d32' >>> task_stack_push(task, parent_memid) """ memid = TaskNode.create(self, task) # Relations if parent_memid: self.add_triple(subj=memid, pred_text="_has_parent_task", obj=parent_memid) if chat_effect: chat = self.get_most_recent_incoming_chat() assert chat is not None, "chat_effect=True with no incoming chats" self.add_triple(subj=chat.memid, pred_text="chat_effect_", obj=memid) # Return newly created object return TaskNode(self, memid)
def task_stack_push( self, task: Task, parent_memid: str = None, chat_effect: bool = False ) -> "TaskNode": memid = TaskNode.create(self, task) # Relations if parent_memid: self.add_triple(subj=memid, pred_text="_has_parent_task", obj=parent_memid) if chat_effect: chat = self.get_most_recent_incoming_chat() assert chat is not None, "chat_effect=True with no incoming chats" self.add_triple(subj=chat.memid, pred_text="chat_effect_", obj=memid) # Return newly created object return TaskNode(self, memid)