mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-17 13:04:20 +01:00
Added code to pass the write file test
This commit is contained in:
@@ -88,4 +88,19 @@ class AutoGPTAgent(Agent):
|
||||
multiple steps. Returning a request to continue in the step output, the user can then decide
|
||||
if 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 step
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import os
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi import APIRouter, FastAPI, Response, UploadFile
|
||||
from fastapi import APIRouter, FastAPI, UploadFile
|
||||
from fastapi.responses import FileResponse
|
||||
from hypercorn.asyncio import serve
|
||||
from 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:
|
||||
raise
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 artifacts
|
||||
except 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.
|
||||
|
||||
Reference in New Issue
Block a user