Skip to content

Commit

Permalink
fix(agent/serve): Fix artifact creation
Browse files Browse the repository at this point in the history
- Link agent-created artifacts to the corresponding step
- Mark agent-created artifacts as such
  • Loading branch information
Pwuts committed Dec 7, 2023
1 parent 1f40d72 commit 8985b7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions autogpts/autogpt/autogpt/app/agent_protocol_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion autogpts/autogpt/autogpt/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 8985b7b

Please sign in to comment.