From d38d3920d797f1ee208c1f47b5349db634522554 Mon Sep 17 00:00:00 2001 From: SwiftyOS Date: Mon, 14 Aug 2023 18:16:19 +0200 Subject: [PATCH] Fixed issues with benchmarking --- .env.example | 12 +++++++----- autogpt/__main__.py | 2 ++ autogpt/agent.py | 4 +++- autogpt/db.py | 11 +++++++++-- run | 6 ++++++ 5 files changed, 27 insertions(+), 8 deletions(-) create mode 100755 run diff --git a/.env.example b/.env.example index 251b51f2..088ff34f 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,11 @@ # Your OpenAI API Key. If GPT-4 is available it will use that, otherwise will use 3.5-turbo -OPENAI_API_KEY=MY-API-KEY - +OPENAI_API_KEY=abc # If you want to enable Helicone proxy and caching -# HELICONE_KEY=MY-HELICONE-KEY -# OPENAI_API_BASE=https://oai.hconeai.com/v1 +HELICONE_KEY=abc +OPENAI_API_BASE=https://oai.hconeai.com/v1 # Control log level -LOG_LEVEL=INFO \ No newline at end of file +LOG_LEVEL=INFO +DATABASE_NAME="./agent.db" +PORT=8000 +AGENT_WORKSPACE="agbenchmark/workspace" \ No newline at end of file diff --git a/autogpt/__main__.py b/autogpt/__main__.py index c2ec5493..8c27bcac 100644 --- a/autogpt/__main__.py +++ b/autogpt/__main__.py @@ -11,9 +11,11 @@ if __name__ == "__main__": load_dotenv() database_name = os.getenv("DATABASE_NAME") port = os.getenv("PORT") + workspace = os.getenv("AGENT_WORKSPACE") auto_gpt = autogpt.agent.AutoGPT() database = autogpt.db.AgentDB(database_name) agent = Agent.setup_agent(auto_gpt.task_handler, auto_gpt.step_handler) agent.db = database + agent.workspace = workspace agent.start(port=port) diff --git a/autogpt/agent.py b/autogpt/agent.py index aee46576..4328dddf 100644 --- a/autogpt/agent.py +++ b/autogpt/agent.py @@ -14,10 +14,12 @@ class AutoGPT: await Agent.db.create_step(task.task_id, task.input, is_last=True) time.sleep(2) 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.input}") + # 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.output = agent_step.input diff --git a/autogpt/db.py b/autogpt/db.py index 1597f264..3c85e522 100644 --- a/autogpt/db.py +++ b/autogpt/db.py @@ -137,7 +137,7 @@ class AgentDB(TaskDB): 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])) - print(f"Task: {task}") + # print(f"Getting task {task_id}.... Task details: {task}") return task else: raise DataNotFoundError("Task not found") @@ -149,7 +149,14 @@ class AgentDB(TaskDB): "SELECT * FROM steps WHERE task_id=? AND step_id=?", (task_id, step_id) ) if step := cursor.fetchone(): - return Step(task_id=task_id, step_id=step_id, name=step[2], status=step[3]) + return Step( + task_id=task_id, + step_id=step_id, + name=step[2], + status=step[3], + is_last=step[4] == 1, + additional_properties=step[5], + ) else: raise DataNotFoundError("Step not found") diff --git a/run b/run new file mode 100755 index 00000000..11a3c11e --- /dev/null +++ b/run @@ -0,0 +1,6 @@ +#!/bin/bash + +export PYTHONPATH=$PYTHONPATH:$PWD + +python -m autogpt "$@" +