From 8985b7b01b8746ed5d52a51183523e658fa27e86 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Thu, 7 Dec 2023 16:21:58 +0100 Subject: [PATCH] fix(agent/serve): Fix artifact creation - Link agent-created artifacts to the corresponding step - Mark agent-created artifacts as such --- .../autogpt/autogpt/app/agent_protocol_server.py | 12 +++++++----- autogpts/autogpt/autogpt/app/main.py | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.py index 2e620c1bd7f3..23b7f9d57968 100644 --- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py +++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py @@ -169,11 +169,6 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste app_config=self.app_config, llm_provider=self.llm_provider, ) - agent.workspace.on_write_file = lambda path: self.db.create_artifact( - task_id=task_id, - file_name=path.parts[-1], - relative_path=str(path), - ) # According to the Agent Protocol spec, the first execute_step request contains # the same task input as the parent create_task request. @@ -214,6 +209,13 @@ async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Ste # Execute previously proposed action if execute_command: assert execute_command_args is not None + agent.workspace.on_write_file = lambda path: self.db.create_artifact( + task_id=step.task_id, + step_id=step.step_id, + file_name=path.parts[-1], + agent_created=True, + relative_path=str(path), + ) if step.is_last and execute_command == finish.__name__: assert execute_command_args diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py index f50c22d3abda..43a911a01982 100644 --- a/autogpts/autogpt/autogpt/app/main.py +++ b/autogpts/autogpt/autogpt/app/main.py @@ -346,7 +346,10 @@ async def run_auto_gpt_server( config.plugins = scan_plugins(config) # Set up & start server - database = AgentDB(os.getenv("AP_SERVER_DB_URL", "sqlite:///data/ap_server.db")) + database = AgentDB( + database_string=os.getenv("AP_SERVER_DB_URL", "sqlite:///data/ap_server.db"), + debug_enabled=debug, + ) server = AgentProtocolServer( app_config=config, database=database, llm_provider=llm_provider )