Ejemplo n.º 1
0
 def __init__(self, agent, task_data={}):
     self.agent = agent
     self.run_count = 0
     self.interrupted = False
     self.finished = False
     self.name = None
     self.undone = False
     self.last_stepped_time = None
     self.prio = -1
     self.running = 0
     self.memid = TaskNode.create(self.agent.memory, self)
     # TODO put these in memory in a new table?
     # TODO methods for safely changing these
     i, s, ru, re = get_default_conditions(task_data, agent, self)
     self.init_condition = i
     self.stop_condition = s
     self.run_condition = ru
     self.remove_condition = re
     TripleNode.create(
         self.agent.memory,
         subj=self.memid,
         pred_text="has_name",
         obj_text=self.__class__.__name__.lower(),
     )
     TaskNode(agent.memory, self.memid).update_task(task=self)
Ejemplo n.º 2
0
    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(memid, "_has_parent_task", 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(chat.memid, "chat_effect_", memid)

        # Return newly created object
        return TaskNode(self, memid)