AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Added code to pass the write file test
SwiftyOS1c93114a998f
diff --git a/autogpt/agent.py b/autogpt/agent.pyindex 99c001df6e..2b5a142415 100644--- a/autogpt/agent.py+++ b/autogpt/agent.py@@ -88,4 +88,19 @@ class AutoGPTAgent(Agent):multiple steps. Returning a request to continue in the step output, the user can then decideif they want the agent to continue or not."""- raise NotImplementedError++ # An example that+ self.workspace.write(task_id=task_id, path="output.txt", data=b"Washington D.C")+ step = await self.db.create_step(+ task_id=task_id, input=step_request, is_last=True+ )+ artifact = await self.db.create_artifact(+ task_id=task_id,+ step_id=step.step_id,+ file_name="output.txt",+ relative_path="",+ agent_created=True,+ )+ step.output = "Washington D.C"++ return stepdiff --git a/autogpt/sdk/agent.py b/autogpt/sdk/agent.pyindex b2c66e5f15..2ca3378baf 100644--- a/autogpt/sdk/agent.py+++ b/autogpt/sdk/agent.py@@ -2,7 +2,7 @@ import asyncioimport osfrom uuid import uuid4-from fastapi import APIRouter, FastAPI, Response, UploadFile+from fastapi import APIRouter, FastAPI, UploadFilefrom fastapi.responses import FileResponsefrom hypercorn.asyncio import servefrom hypercorn.config import Config@@ -116,10 +116,8 @@ class Agent:artifacts, pagination = await self.db.list_artifacts(task_id, page, pageSize)- response = TaskArtifactsListResponse(- artifacts=artifacts, pagination=pagination- )- return Response(content=response.json(), media_type="application/json")+ return TaskArtifactsListResponse(artifacts=artifacts, pagination=pagination)+except Exception as e:raisediff --git a/autogpt/sdk/db.py b/autogpt/sdk/db.pyindex eec3500218..bf5eeb056d 100644--- a/autogpt/sdk/db.py+++ b/autogpt/sdk/db.py@@ -218,7 +218,11 @@ class AgentDB:with self.Session() as session:if (existing_artifact := session.query(ArtifactModel)- .filter_by(relative_path=relative_path)+ .filter_by(+ task_id=task_id,+ file_name=file_name,+ relative_path=relative_path,+ ).first()):session.close()diff --git a/autogpt/sdk/routes/agent_protocol.py b/autogpt/sdk/routes/agent_protocol.pyindex 153239b5e0..ced599081c 100644--- a/autogpt/sdk/routes/agent_protocol.py+++ b/autogpt/sdk/routes/agent_protocol.py@@ -324,7 +324,7 @@ async def list_agent_task_steps(@base_router.post("/agent/tasks/{task_id}/steps", tags=["agent"], response_model=Step)async def execute_agent_task_step(- request: Request, task_id: str, step: StepRequestBody+ request: Request, task_id: str, step: Optional[StepRequestBody] = None) -> Step:"""Executes the next step for a specified task based on the current task status and returns the@@ -367,6 +367,9 @@ async def execute_agent_task_step("""agent = request["agent"]try:+ # An empty step request represents a yes to continue command+ if not step:+ step = StepRequestBody(input="y")step = await agent.execute_step(task_id, step)return Response(content=step.json(),@@ -479,7 +482,10 @@ async def list_agent_task_artifacts("""agent = request["agent"]try:- artifacts = await agent.list_artifacts(task_id, page, page_size)+ artifacts: TaskArtifactsListResponse = await agent.list_artifacts(+ task_id, page, page_size+ )+ LOG.info(f"Artifacts: {artifacts.json()}")return artifactsexcept NotFoundError:LOG.exception("Error whilst trying to list artifacts")@@ -501,7 +507,7 @@ async def list_agent_task_artifacts("/agent/tasks/{task_id}/artifacts", tags=["agent"], response_model=Artifact)async def upload_agent_task_artifacts(- request: Request, task_id: str, file: UploadFile, relative_path: str+ request: Request, task_id: str, file: UploadFile, relative_path: Optional[str] = "") -> Artifact:"""This endpoint is used to upload an artifact associated with a specific task. The artifact is provided as a file.