From 28714d37f01ba32fe03389f0a62d55b037cd1161 Mon Sep 17 00:00:00 2001 From: SwiftyOS Date: Mon, 14 Aug 2023 18:20:10 +0200 Subject: [PATCH] formatting --- autogpt/agent.py | 11 ++++++----- autogpt/db.py | 17 ++++++++++++++--- test.py | 7 +++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/autogpt/agent.py b/autogpt/agent.py index 4328dddf..4f951c2f 100644 --- a/autogpt/agent.py +++ b/autogpt/agent.py @@ -1,11 +1,11 @@ +import time + from agent_protocol import Agent, Step, Task -import time + import autogpt.utils class AutoGPT: - - def __init__(self) -> None: pass @@ -16,12 +16,13 @@ class AutoGPT: autogpt.utils.run(task.input) # print(f"Created Task id: {task.task_id}") return task - async def step_handler(self, step: Step) -> Step: # print(f"step: {step}") agent_step = await Agent.db.get_step(step.task_id, step.step_id) - updated_step: Step = await Agent.db.update_step(agent_step.task_id, agent_step.step_id, status="completed") + updated_step: Step = await Agent.db.update_step( + agent_step.task_id, agent_step.step_id, status="completed" + ) updated_step.output = agent_step.input print(f"Step completed: {updated_step}") return updated_step diff --git a/autogpt/db.py b/autogpt/db.py index 3c85e522..d699a612 100644 --- a/autogpt/db.py +++ b/autogpt/db.py @@ -9,7 +9,7 @@ import sqlite3 from typing import Dict, List, Optional from agent_protocol import Artifact, Step, Task, TaskDB -from agent_protocol.models import TaskInput, Status +from agent_protocol.models import Status, TaskInput class DataNotFoundError(Exception): @@ -135,8 +135,19 @@ class AgentDB(TaskDB): steps = cursor.fetchall() if steps: for step in steps: - status = Status.created if step[3] == "created" else Status.completed - task.steps.append(Step(task_id=step[1], step_id=step[0], name=step[2], status=status, is_last=True if step[4] == 1 else False, additional_properties=step[5])) + status = ( + Status.created if step[3] == "created" else Status.completed + ) + task.steps.append( + Step( + task_id=step[1], + step_id=step[0], + name=step[2], + status=status, + is_last=True if step[4] == 1 else False, + additional_properties=step[5], + ) + ) # print(f"Getting task {task_id}.... Task details: {task}") return task else: diff --git a/test.py b/test.py index 7744e6b1..82072225 100644 --- a/test.py +++ b/test.py @@ -1,7 +1,9 @@ -DATABASE_NAME="agent.db" +DATABASE_NAME = "agent.db" import sqlite3 + # Read all data from database + def read_all(): conn = sqlite3.connect(DATABASE_NAME) cur = conn.cursor() @@ -10,4 +12,5 @@ def read_all(): conn.close() return rows -print(read_all()) \ No newline at end of file + +print(read_all())