Skip to content

Commit

Permalink
Filter for status
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Jul 26, 2023
1 parent 09b5af3 commit 5eb688d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions easytask/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,32 @@ def create_task(goal, plan=None, steps=None):
"goal": goal,
"plan": plan,
"steps": steps,
"status": "in progress",
"status": "in_progress",
}

create_memory("task", goal, metadata=task)

return


def list_tasks():
def list_tasks(status="in_progress"):
debug = os.environ.get("DEBUG", False)
memories = get_memories(
"task", filter_metadata={"status": "in progress"}, include_embeddings=False
"task", filter_metadata={"status": status}, include_embeddings=False
)
log("Found {} tasks".format(len(memories)), log=debug)
return memories


def search_tasks(search_term):
def search_tasks(search_term, status="in_progress"):
# return tasks whose goal is most relevant to the search term
memories = search_memory("task", search_term, include_embeddings=False, include_distances=False)
memories = search_memory(
"task",
search_term,
filter_metadata={"status": "in_progress"},
include_embeddings=False,
include_distances=False,
)
log("Found {} tasks".format(len(memories)), log=debug)
return memories

Expand Down
6 changes: 3 additions & 3 deletions easytask/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup():
"goal": goal,
"plan": plan,
"steps": steps,
"status": "in progress",
"status": "in_progress",
}

create_memory("task", goal, metadata=task)
Expand All @@ -96,7 +96,7 @@ def test_create_task():
assert "plan" in task["metadata"]
assert "steps" in task["metadata"]
assert "status" in task["metadata"]
assert task["metadata"]["status"] == "in progress"
assert task["metadata"]["status"] == "in_progress"
teardown()


Expand All @@ -105,7 +105,7 @@ def test_list_tasks():
tasks = list_tasks()
assert isinstance(tasks, list)
# check that the task document is in the list of tasks' docments
assert task['document'] in [task['document'] for task in tasks]
assert task["document"] in [task["document"] for task in tasks]
teardown()


Expand Down

0 comments on commit 5eb688d

Please sign in to comment.