Skip to content

Commit

Permalink
0.0.8 - better handling of current task
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Jul 30, 2023
1 parent 9c28392 commit 9f2548b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions agentagenda/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,20 @@ def create_task(goal, plan=None, steps=None, model="gpt-3.5-turbo-0613"):
created_at = datetime.timestamp(datetime.now())
updated_at = datetime.timestamp(datetime.now())

memories = get_memories("task", filter_metadata={"current": "True"})
for memory in memories:
metadata = memory["metadata"]
metadata["current"] = "False"
update_memory("task", memory["id"], metadata=metadata)

task = {
"created_at": created_at,
"updated_at": updated_at,
"goal": goal,
"plan": plan,
"steps": steps,
"status": "in_progress",
"current": "True",
}

return get_task_by_id(create_memory("task", goal, metadata=task))
Expand Down Expand Up @@ -191,6 +198,7 @@ def finish_task(task):
metadata = memory["metadata"]
metadata["status"] = "complete"
metadata["updated_at"] = updated_at
metadata["current"] = "False"

return update_memory(
"task",
Expand All @@ -216,6 +224,7 @@ def cancel_task(task):
metadata = memory["metadata"]
metadata["status"] = "cancelled"
metadata["updated_at"] = updated_at
metadata["current"] = "False"

return update_memory(
"task",
Expand Down Expand Up @@ -287,7 +296,7 @@ def get_current_task():
The task marked as the current active task. If no current task is found, None is returned.
"""
memory = get_memories(
"task", filter_metadata={"current": True}, include_embeddings=False
"task", filter_metadata={"current": "True"}, include_embeddings=False
)
if len(memory) > 0:
log("Current task: {}".format(memory[0]), log=debug)
Expand All @@ -309,16 +318,16 @@ def set_current_task(task):
task_id = get_task_id

memories = get_memories(
"task", filter_metadata={"current": True}, include_embeddings=False
"task", filter_metadata={"current": "True"}, include_embeddings=False
)

for memory in memories:
metadata = memory["metadata"]
metadata["current"] = False
metadata["current"] = "False"
update_memory("task", memory["id"], metadata=metadata)
log("Setting current task: {}".format(task), log=debug)
metadata = memory["metadata"]
metadata["current"] = True
metadata["current"] = "True"
return update_memory("task", task_id, metadata=metadata)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="agentagenda",
version="0.0.7",
version="0.0.8",
description="A task manager for your agent.",
long_description=long_description, # added this line
long_description_content_type="text/markdown", # and this line
Expand Down

0 comments on commit 9f2548b

Please sign in to comment.