formatting

This commit is contained in:
SwiftyOS
2023-08-14 18:20:10 +02:00
parent 91a1c3dedd
commit 28714d37f0
3 changed files with 25 additions and 10 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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())
print(read_all())