Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
badgeir committed Aug 22, 2024
1 parent 6d53563 commit f899bfc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
20 changes: 10 additions & 10 deletions examples/notebooks/simple_task_manager.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
" status: Literal[\"todo\", \"doing\", \"done\"] = \"todo\"\n",
"\n",
"# (for demonstration purposes) Define a list of tasks\n",
"TASKS: list[BaseModel] = []"
"TASKS: list[Task] = []"
]
},
{
Expand Down Expand Up @@ -125,7 +125,7 @@
"@agent.tool\n",
"def remove_task(task_id: int):\n",
" print(f\"** Removing task {task_id}\")\n",
" for task in TASKS:\n",
" for task in TASKS[:]:\n",
" if task.id == task_id:\n",
" TASKS.remove(task)\n",
" return f\"OK - removed task {task_id}\"\n",
Expand Down Expand Up @@ -176,7 +176,7 @@
"output_type": "stream",
"text": [
"** Listing tasks\n",
"** Bot: You don't have any tasks listed at the moment. Would you like to add some tasks?\n"
"** Bot: You currently have no tasks listed. Would you like to add a new task?\n"
]
},
{
Expand Down Expand Up @@ -240,7 +240,7 @@
"output_type": "stream",
"text": [
"** Adding task 'Grocery Shopping' with status 'todo'\n",
"** Bot (message_handler): 'I've added a grocery shopping task to buy eggs, bacon, bread, tomatoes, and orange juice. If you need anything else, just let me know!'\n"
"** Bot (message_handler): 'Ive added a grocery shopping task to buy eggs, bacon, bread, tomatoes, and orange juice. If you need anything else, just let me know!'\n"
]
},
{
Expand Down Expand Up @@ -270,14 +270,14 @@
"output_type": "stream",
"text": [
"** Adding task 'Clean the House' with status 'todo'\n",
"** Bot (message_handler): 'I've added a task to clean the house. If there's anything else you'd like to do, feel free to ask!'\n"
"** Bot (message_handler): 'I've added a task to clean the house. If there's anything more you would like to do, feel free to ask!'\n"
]
},
{
"data": {
"text/plain": [
"[Task(id=1, name='Grocery Shopping', description='Buy eggs, bacon, bread, tomatoes, and orange juice.', status='todo'),\n",
" Task(id=2, name='Clean the House', description='Thoroughly clean all rooms, including dusting and vacuuming.', status='todo')]"
" Task(id=2, name='Clean the House', description='Thoroughly clean the house, including vacuuming and dusting.', status='todo')]"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -308,7 +308,7 @@
"data": {
"text/plain": [
"[Task(id=1, name='Grocery Shopping', description='Buy eggs, bacon, bread, tomatoes, orange juice, and milk.', status='todo'),\n",
" Task(id=2, name='Clean the House', description='Thoroughly clean all rooms, including dusting and vacuuming.', status='todo')]"
" Task(id=2, name='Clean the House', description='Thoroughly clean the house, including vacuuming and dusting.', status='todo')]"
]
},
"execution_count": 10,
Expand Down Expand Up @@ -339,7 +339,7 @@
"data": {
"text/plain": [
"[Task(id=1, name='Grocery Shopping', description='Buy eggs, bacon, bread, tomatoes, orange juice, and milk.', status='done'),\n",
" Task(id=2, name='Clean the House', description='Thoroughly clean all rooms, including dusting and vacuuming.', status='todo')]"
" Task(id=2, name='Clean the House', description='Thoroughly clean the house, including vacuuming and dusting.', status='todo')]"
]
},
"execution_count": 11,
Expand All @@ -364,13 +364,13 @@
"text": [
"** Listing tasks\n",
"** Removing task 1\n",
"** Bot (message_handler): 'The completed task \"Grocery Shopping\" has been removed. If you need further assistance, feel free to ask!'\n"
"** Bot (message_handler): 'The completed task \"Grocery Shopping\" has been removed. If you need any further assistance, feel free to ask!'\n"
]
},
{
"data": {
"text/plain": [
"[Task(id=2, name='Clean the House', description='Thoroughly clean all rooms, including dusting and vacuuming.', status='todo')]"
"[Task(id=2, name='Clean the House', description='Thoroughly clean the house, including vacuuming and dusting.', status='todo')]"
]
},
"execution_count": 12,
Expand Down
16 changes: 11 additions & 5 deletions examples/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Task(BaseModel):
status: Literal["todo", "doing", "done"] = "todo"


TASKS: list[BaseModel] = []
TASKS: list[Task] = []


# Define an agent
Expand All @@ -40,7 +40,9 @@ def list_tasks():

# Define a tool to add a task
@agent.tool
def add_task(name: str, description: str, status: Literal["todo", "doing", "done"] = "todo"):
def add_task(
name: str, description: str, status: Literal["todo", "doing", "done"] = "todo"
):
print(f"** Adding task '{name}' with status '{status}'")
task_id = len(TASKS) + 1
TASKS.append(Task(id=task_id, name=name, description=description, status=status))
Expand All @@ -49,7 +51,11 @@ def add_task(name: str, description: str, status: Literal["todo", "doing", "done

# Define a tool to update a task
@agent.tool
def update_task(task_id: int, status: Literal["todo", "doing", "done"] | None = None, description: str | None = None):
def update_task(
task_id: int,
status: Literal["todo", "doing", "done"] | None = None,
description: str | None = None,
):
print(f"** Updating task {task_id}")
for task in TASKS:
if task.id == task_id:
Expand All @@ -63,15 +69,15 @@ def update_task(task_id: int, status: Literal["todo", "doing", "done"] | None =
@agent.tool
def remove_task(task_id: int):
print(f"** Removing task {task_id}")
for task in TASKS:
for task in TASKS[:]:
if task.id == task_id:
TASKS.remove(task)
return f"OK - removed task {task_id}"
return "Task not found"


async def main() -> None:
history = []
history: list[llmio.Message] = []

while True:
agent_messages, history = await agent.speak(input(">>> "), history=history)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ disable = [

[tool.ruff]
line-length = 120

[tool.black]
extend-exclude = "examples/notebooks"

0 comments on commit f899bfc

Please sign in to comment.