fix(agent/serve): Fix artifact creation

- Link agent-created artifacts to the corresponding step
- Mark agent-created artifacts as such
This commit is contained in:
Reinier van der Leer
2023-12-07 16:21:58 +01:00
parent 1f40d72081
commit 8985b7b01b
2 changed files with 11 additions and 6 deletions

View File

@@ -169,11 +169,6 @@ class AgentProtocolServer:
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 @@ class AgentProtocolServer:
# 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

View File

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