mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
fix(agent): Handle artifact modification properly
- When an Artifact's file is modified by the agent, set its `agent_created` attribute to `True` instead of registering a new Artifact - Update the `autogpt-forge` dependency to the newest version, in which `AgentDB.update_artifact` has been implemented
This commit is contained in:
@@ -213,12 +213,8 @@ class AgentProtocolServer:
|
|||||||
# Execute previously proposed action
|
# Execute previously proposed action
|
||||||
if execute_command:
|
if execute_command:
|
||||||
assert execute_command_args is not None
|
assert execute_command_args is not None
|
||||||
agent.workspace.on_write_file = lambda path: self.db.create_artifact(
|
agent.workspace.on_write_file = lambda path: self._on_agent_write_file(
|
||||||
task_id=step.task_id,
|
task=task, step=step, relative_path=path
|
||||||
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__:
|
if step.is_last and execute_command == finish.__name__:
|
||||||
@@ -317,6 +313,30 @@ class AgentProtocolServer:
|
|||||||
agent.state.save_to_json_file(agent.file_manager.state_file_path)
|
agent.state.save_to_json_file(agent.file_manager.state_file_path)
|
||||||
return step
|
return step
|
||||||
|
|
||||||
|
async def _on_agent_write_file(
|
||||||
|
self, task: Task, step: Step, relative_path: pathlib.Path
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Creates an Artifact for the written file, or updates the Artifact if it exists.
|
||||||
|
"""
|
||||||
|
if relative_path.is_absolute():
|
||||||
|
raise ValueError(f"File path '{relative_path}' is not relative")
|
||||||
|
for a in task.artifacts or []:
|
||||||
|
if a.relative_path == str(relative_path):
|
||||||
|
logger.debug(f"Updating Artifact after writing to existing file: {a}")
|
||||||
|
if not a.agent_created:
|
||||||
|
await self.db.update_artifact(a.artifact_id, agent_created=True)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
logger.debug(f"Creating Artifact for new file '{relative_path}'")
|
||||||
|
await self.db.create_artifact(
|
||||||
|
task_id=step.task_id,
|
||||||
|
step_id=step.step_id,
|
||||||
|
file_name=relative_path.parts[-1],
|
||||||
|
agent_created=True,
|
||||||
|
relative_path=str(relative_path),
|
||||||
|
)
|
||||||
|
|
||||||
async def get_step(self, task_id: str, step_id: str) -> Step:
|
async def get_step(self, task_id: str, step_id: str) -> Step:
|
||||||
"""
|
"""
|
||||||
Get a step by ID.
|
Get a step by ID.
|
||||||
|
|||||||
14
autogpts/autogpt/poetry.lock
generated
14
autogpts/autogpt/poetry.lock
generated
@@ -345,8 +345,8 @@ benchmark = ["agbenchmark @ git+https://github.com/Significant-Gravitas/AutoGPT.
|
|||||||
[package.source]
|
[package.source]
|
||||||
type = "git"
|
type = "git"
|
||||||
url = "https://github.com/Significant-Gravitas/AutoGPT.git"
|
url = "https://github.com/Significant-Gravitas/AutoGPT.git"
|
||||||
reference = "HEAD"
|
reference = "b238aba"
|
||||||
resolved_reference = "39fd1d6be1979875c077ef575051867f105dcb18"
|
resolved_reference = "b238abac52a4f945325603d433b7eade5bb92d2a"
|
||||||
subdirectory = "autogpts/forge"
|
subdirectory = "autogpts/forge"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2083,12 +2083,12 @@ files = [
|
|||||||
google-auth = ">=2.14.1,<3.0.dev0"
|
google-auth = ">=2.14.1,<3.0.dev0"
|
||||||
googleapis-common-protos = ">=1.56.2,<2.0.dev0"
|
googleapis-common-protos = ">=1.56.2,<2.0.dev0"
|
||||||
grpcio = [
|
grpcio = [
|
||||||
{version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
|
||||||
{version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
{version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||||
|
{version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
||||||
]
|
]
|
||||||
grpcio-status = [
|
grpcio-status = [
|
||||||
{version = ">=1.33.2,<2.0.dev0", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
|
||||||
{version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
{version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||||
|
{version = ">=1.33.2,<2.0.dev0", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""},
|
||||||
]
|
]
|
||||||
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0"
|
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0"
|
||||||
requests = ">=2.18.0,<3.0.0.dev0"
|
requests = ">=2.18.0,<3.0.0.dev0"
|
||||||
@@ -2221,8 +2221,8 @@ google-cloud-audit-log = ">=0.1.0,<1.0.0dev"
|
|||||||
google-cloud-core = ">=2.0.0,<3.0.0dev"
|
google-cloud-core = ">=2.0.0,<3.0.0dev"
|
||||||
grpc-google-iam-v1 = ">=0.12.4,<1.0.0dev"
|
grpc-google-iam-v1 = ">=0.12.4,<1.0.0dev"
|
||||||
proto-plus = [
|
proto-plus = [
|
||||||
{version = ">=1.22.0,<2.0.0dev", markers = "python_version < \"3.11\""},
|
|
||||||
{version = ">=1.22.2,<2.0.0dev", markers = "python_version >= \"3.11\""},
|
{version = ">=1.22.2,<2.0.0dev", markers = "python_version >= \"3.11\""},
|
||||||
|
{version = ">=1.22.0,<2.0.0dev", markers = "python_version < \"3.11\""},
|
||||||
]
|
]
|
||||||
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0dev"
|
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0dev"
|
||||||
|
|
||||||
@@ -4233,9 +4233,9 @@ files = [
|
|||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
numpy = [
|
numpy = [
|
||||||
{version = ">=1.22.4,<2", markers = "python_version < \"3.11\""},
|
|
||||||
{version = ">=1.23.2,<2", markers = "python_version == \"3.11\""},
|
{version = ">=1.23.2,<2", markers = "python_version == \"3.11\""},
|
||||||
{version = ">=1.26.0,<2", markers = "python_version >= \"3.12\""},
|
{version = ">=1.26.0,<2", markers = "python_version >= \"3.12\""},
|
||||||
|
{version = ">=1.22.4,<2", markers = "python_version < \"3.11\""},
|
||||||
]
|
]
|
||||||
python-dateutil = ">=2.8.2"
|
python-dateutil = ">=2.8.2"
|
||||||
pytz = ">=2020.1"
|
pytz = ">=2020.1"
|
||||||
@@ -7191,4 +7191,4 @@ benchmark = ["agbenchmark"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "e57e40785a96af53fd3977536b7bf2a912073c24034449ec45c95234738f134a"
|
content-hash = "aab84eef0d990d25803675669e775d18cd7801cd03bd0f72f3a92859d24db68b"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ serve = "autogpt.app.cli:serve"
|
|||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
auto-gpt-plugin-template = {git = "https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template", rev = "0.1.0"}
|
auto-gpt-plugin-template = {git = "https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template", rev = "0.1.0"}
|
||||||
# autogpt-forge = { path = "../forge" }
|
# autogpt-forge = { path = "../forge" }
|
||||||
autogpt-forge = {git = "https://github.com/Significant-Gravitas/AutoGPT.git", subdirectory = "autogpts/forge"}
|
autogpt-forge = {git = "https://github.com/Significant-Gravitas/AutoGPT.git", rev = "b238aba", subdirectory = "autogpts/forge"}
|
||||||
beautifulsoup4 = "^4.12.2"
|
beautifulsoup4 = "^4.12.2"
|
||||||
boto3 = "^1.33.6"
|
boto3 = "^1.33.6"
|
||||||
charset-normalizer = "^3.1.0"
|
charset-normalizer = "^3.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user