Skip to content

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.

Formatting changes

SwiftyOS7373933a1861
diff --git a/autogpts/forge/forge/sdk/__init__.py b/autogpts/forge/forge/sdk/__init__.py
index c3e29d8833..2145ed5b2e 100644
--- a/autogpts/forge/forge/sdk/__init__.py
+++ b/autogpts/forge/forge/sdk/__init__.py
@@ -5,6 +5,7 @@ core of the Forge.
from .agent import Agent
from .db import AgentDB
from .forge_log import ForgeLogger
+from .llm import chat_completion_request, create_embedding_request, transcribe_audio
from .prompting import PromptEngine
from .schema import (
Artifact,
@@ -21,4 +22,3 @@ from .schema import (
TaskStepsListResponse,
)
from .workspace import LocalWorkspace, Workspace
-from .llm import chat_completion_request, create_embedding_request, transcribe_audio
diff --git a/autogpts/forge/forge/sdk/abilities/file_system/files.py b/autogpts/forge/forge/sdk/abilities/file_system/files.py
index 6584471c87..5a8928fff3 100644
--- a/autogpts/forge/forge/sdk/abilities/file_system/files.py
+++ b/autogpts/forge/forge/sdk/abilities/file_system/files.py
@@ -16,12 +16,13 @@ from ..registry import ability
],
output_type="list[str]",
)
-async def list_files(agent, task_id:str, path: str) -> List[str]:
+async def list_files(agent, task_id: str, path: str) -> List[str]:
"""
List files in a workspace directory
"""
return agent.workspace.list(task_id=task_id, path=path)
+
@ability(
name="write_file",
description="Write data to a file",
@@ -47,9 +48,14 @@ async def write_file(agent, task_id: str, file_path: str, data: bytes) -> None:
"""
if isinstance(data, str):
data = data.encode()
-
+
agent.workspace.write(task_id=task_id, path=file_path, data=data)
- await agent.db.create_artifact(task_id=task_id, file_name=file_path.split('/')[-1], relative_path=file_path, agent_created=True)
+ await agent.db.create_artifact(
+ task_id=task_id,
+ file_name=file_path.split("/")[-1],
+ relative_path=file_path,
+ agent_created=True,
+ )
@ability(
@@ -65,7 +71,7 @@ async def write_file(agent, task_id: str, file_path: str, data: bytes) -> None:
],
output_type="bytes",
)
-async def read_file(agent, task_id: str, file_path: str) -> bytes:
+async def read_file(agent, task_id: str, file_path: str) -> bytes:
"""
Read data from a file
"""
diff --git a/autogpts/forge/forge/sdk/abilities/finish.py b/autogpts/forge/forge/sdk/abilities/finish.py
index a0424bdd16..7524bd8b91 100644
--- a/autogpts/forge/forge/sdk/abilities/finish.py
+++ b/autogpts/forge/forge/sdk/abilities/finish.py
@@ -1,13 +1,14 @@
-from .registry import ability
from ..forge_log import ForgeLogger
+from .registry import ability
logger = ForgeLogger(__name__)
+
@ability(
name="finish",
description="Use this to shut down once you have accomplished all of your goals,"
- " or when there are insurmountable problems that make it impossible"
- " for you to finish your task.",
+ " or when there are insurmountable problems that make it impossible"
+ " for you to finish your task.",
parameters=[
{
"name": "reason",
@@ -16,9 +17,13 @@ logger = ForgeLogger(__name__)
"required": True,
}
],
- output_type="None"
+ output_type="None",
)
-async def finish(agent, task_id: str, reason: str,) -> str:
+async def finish(
+ agent,
+ task_id: str,
+ reason: str,
+) -> str:
"""
A function that takes in a string and exits the program
diff --git a/autogpts/forge/forge/sdk/abilities/registry.py b/autogpts/forge/forge/sdk/abilities/registry.py
index 1c0b84cec2..dddb2d8a66 100644
--- a/autogpts/forge/forge/sdk/abilities/registry.py
+++ b/autogpts/forge/forge/sdk/abilities/registry.py
@@ -135,7 +135,7 @@ class AbilityRegister:
def list_abilities(self) -> List[Ability]:
return self.abilities
-
+
def list_abilities_for_prompt(self) -> List[str]:
return [str(ability) for ability in self.abilities.values()]
@@ -156,7 +156,9 @@ class AbilityRegister:
return abilities_description
- async def run_ability(self, task_id: str, ability_name: str, *args: Any, **kwds: Any) -> Any:
+ async def run_ability(
+ self, task_id: str, ability_name: str, *args: Any, **kwds: Any
+ ) -> Any:
"""
This method runs a specified ability with the provided arguments and keyword arguments.
diff --git a/autogpts/forge/forge/sdk/agent.py b/autogpts/forge/forge/sdk/agent.py
index 701225be0a..3a758b8d68 100644
--- a/autogpts/forge/forge/sdk/agent.py
+++ b/autogpts/forge/forge/sdk/agent.py
@@ -1,17 +1,17 @@
import asyncio
import os
import pathlib
-from uuid import uuid4
-from fastapi.responses import StreamingResponse
from io import BytesIO
+from uuid import uuid4
from fastapi import APIRouter, FastAPI, UploadFile
from fastapi.middleware.cors import CORSMiddleware
-from fastapi.responses import FileResponse, RedirectResponse
+from fastapi.responses import FileResponse, RedirectResponse, StreamingResponse
from fastapi.staticfiles import StaticFiles
from hypercorn.asyncio import serve
from hypercorn.config import Config
+from .abilities.registry import AbilityRegister
from .db import AgentDB
from .errors import NotFoundError
from .forge_log import ForgeLogger
@@ -19,7 +19,6 @@ from .middlewares import AgentMiddleware
from .routes.agent_protocol import base_router
from .schema import *
from .workspace import Workspace
-from .abilities.registry import AbilityRegister
LOG = ForgeLogger(__name__)
@@ -207,4 +206,10 @@ class Agent:
except Exception as e:
raise
- return StreamingResponse(BytesIO(retrieved_artifact), media_type='application/octet-stream', headers={'Content-Disposition': f'attachment; filename={artifact.file_name}'})
+ return StreamingResponse(
+ BytesIO(retrieved_artifact),
+ media_type="application/octet-stream",
+ headers={
+ "Content-Disposition": f"attachment; filename={artifact.file_name}"
+ },
+ )
diff --git a/autogpts/forge/forge/sdk/db.py b/autogpts/forge/forge/sdk/db.py
index 069a7f8364..1a3d98fd5d 100644
--- a/autogpts/forge/forge/sdk/db.py
+++ b/autogpts/forge/forge/sdk/db.py
@@ -150,9 +150,7 @@ class AgentDB:
new_task = TaskModel(
task_id=str(uuid.uuid4()),
input=input,
- additional_input=additional_input
- if additional_input
- else {},
+ additional_input=additional_input if additional_input else {},
)
session.add(new_task)
session.commit()
diff --git a/autogpts/forge/forge/sdk/prompting.py b/autogpts/forge/forge/sdk/prompting.py
index d512ddcbaf..badc004db6 100644
--- a/autogpts/forge/forge/sdk/prompting.py
+++ b/autogpts/forge/forge/sdk/prompting.py
@@ -84,7 +84,7 @@ class PromptEngine:
try:
matches = get_close_matches(target, model_dirs, n=1, cutoff=0.1)
if matches:
- matches_str = ', '.join(matches)
+ matches_str = ", ".join(matches)
LOG.debug(matches_str)
for m in matches:
LOG.info(m)