aboutsummaryrefslogtreecommitdiffstats
path: root/bots/todo-py
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-22 06:52:45 +0800
committerGitHub <noreply@github.com>2024-06-22 06:52:45 +0800
commitadfb7c2b49ba4ba691e89683afa700eabbb3388c (patch)
tree730829361b85a15e5dd0d323ae185c00068ce053 /bots/todo-py
parenta799428b397ac7789a91cf94a9c408ee8a2dd6e2 (diff)
downloadllm-functions-docker-adfb7c2b49ba4ba691e89683afa700eabbb3388c.tar.gz
refactor: rename bot to agent (#44)
Diffstat (limited to 'bots/todo-py')
l---------bots/todo-py/index.yaml1
-rw-r--r--bots/todo-py/tools.py62
2 files changed, 0 insertions, 63 deletions
diff --git a/bots/todo-py/index.yaml b/bots/todo-py/index.yaml
deleted file mode 120000
index 0d19c11..0000000
--- a/bots/todo-py/index.yaml
+++ /dev/null
@@ -1 +0,0 @@
-../todo-sh/index.yaml \ No newline at end of file
diff --git a/bots/todo-py/tools.py b/bots/todo-py/tools.py
deleted file mode 100644
index a531b51..0000000
--- a/bots/todo-py/tools.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import json
-import sys
-import os
-from json import JSONDecodeError
-
-
-def add_todo(desc: str):
- """Add a new todo item
- Args:
- desc: The task description
- """
- todos_file = _get_todos_file()
- try:
- with open(todos_file, "r") as f:
- data = json.load(f)
- except (FileNotFoundError, JSONDecodeError):
- data = []
- num = max([item["id"] for item in data] + [0]) + 1
- data.append({"id": num, "desc": desc})
- with open(todos_file, "w") as f:
- json.dump(data, f)
- print(f"Successfully added todo id={num}")
-
-
-def del_todo(id: int):
- """Delete an existing todo item
- Args:
- id: The task id
- """
- todos_file = _get_todos_file()
- try:
- with open(todos_file, "r") as f:
- data = json.load(f)
- except (FileNotFoundError, JSONDecodeError):
- print("Empty todo list")
- return
- data = [item for item in data if item["id"] != id]
- with open(todos_file, "w") as f:
- json.dump(data, f)
- print(f"Successfully deleted todo id={id}")
-
-
-def list_todos():
- """Display the current todo list in json format."""
- todos_file = _get_todos_file()
- try:
- with open(todos_file, "r") as f:
- print(f.read())
- except FileNotFoundError:
- print("[]")
-
-
-def clear_todos():
- """Delete the entire todo list."""
- os.remove(_get_todos_file())
-
-
-def _get_todos_file() -> str:
- cache_dir=os.environ.get("LLM_BOT_CACHE_DIR", "/tmp")
- if not os.path.exists(cache_dir):
- os.makedirs(cache_dir, exist_ok=True)
- return os.path.join(cache_dir, "todos.json")