This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
542 additions
and
1,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,4 +168,5 @@ agbenchmark | |
.benchmarks | ||
.mypy_cache | ||
.pytest_cache | ||
.vscode | ||
.vscode | ||
ig_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,106 @@ | ||
import autogpt.sdk.agent | ||
from autogpt.sdk.schema import Step, StepRequestBody | ||
from autogpt.sdk import Agent, AgentDB, Step, StepRequestBody, Workspace | ||
|
||
|
||
class AutoGPTAgent(autogpt.sdk.agent.Agent): | ||
async def create_and_execute_step( | ||
self, task_id: str, step_request: StepRequestBody | ||
) -> Step: | ||
class AutoGPTAgent(Agent): | ||
""" | ||
The goal of the Forge is to take care of the boilerplate code so you can focus on | ||
agent design. | ||
There is a great paper surveying the agent landscape: https://arxiv.org/abs/2308.11432 | ||
Which I would highly recommend reading as it will help you understand the possabilities. | ||
Here is a summary of the key components of an agent: | ||
Anatomy of an agent: | ||
- Profile | ||
- Memory | ||
- Planning | ||
- Action | ||
Profile: | ||
Agents typically perform a task by assuming specific roles. For example, a teacher, | ||
a coder, a planner etc. In using the profile in the llm prompt it has been shown to | ||
improve the quality of the output. https://arxiv.org/abs/2305.14688 | ||
Additionally baed on the profile selected, the agent could be configured to use a | ||
different llm. The possabilities are endless and the profile can be selected selected | ||
dynamically based on the task at hand. | ||
Memory: | ||
Memory is critical for the agent to acculmulate experiences, self-evolve, and behave | ||
in a more consistent, reasonable, and effective manner. There are many approaches to | ||
memory. However, some thoughts: there is long term and short term or working memory. | ||
You may want different approaches for each. There has also been work exploring the | ||
idea of memory reflection, which is the ability to assess its memories and re-evaluate | ||
them. For example, condensting short term memories into long term memories. | ||
Planning: | ||
When humans face a complex task, they first break it down into simple subtasks and then | ||
solve each subtask one by one. The planning module empowers LLM-based agents with the ability | ||
to think and plan for solving complex tasks, which makes the agent more comprehensive, | ||
powerful, and reliable. The two key methods to consider are: Planning with feedback and planning | ||
without feedback. | ||
Action: | ||
Actions translate the agents decisions into specific outcomes. For example, if the agent | ||
decides to write a file, the action would be to write the file. There are many approaches you | ||
could implement actions. | ||
The Forge has a basic module for each of these areas. However, you are free to implement your own. | ||
This is just a starting point. | ||
""" | ||
|
||
def __init__(self, database: AgentDB, workspace: Workspace): | ||
""" | ||
The database is used to store tasks, steps and artifact metadata. The workspace is used to | ||
store artifacts. The workspace is a directory on the file system. | ||
Feel free to create subclasses of the database and workspace to implement your own storage | ||
""" | ||
Create a step for the task and execute it. | ||
super().__init__(database, workspace) | ||
|
||
async def execute_step(self, task_id: str, step_request: StepRequestBody) -> Step: | ||
""" | ||
The agent protocol, which is the core of the Forge, works by creating a task and then | ||
executing steps for that task. This method is called when the agent is asked to execute | ||
a step. | ||
The task that is created contains an input string, for the bechmarks this is the task | ||
the agent has been asked to solve and additional input, which is a dictionary and | ||
could contain anything. | ||
If you want to get the task use: | ||
``` | ||
task = await self.db.get_task(task_id) | ||
``` | ||
The step request body is essentailly the same as the task request and contains an input | ||
string, for the bechmarks this is the task the agent has been asked to solve and | ||
additional input, which is a dictionary and could contain anything. | ||
You need to implement logic that will take in this step input and output the completed step | ||
as a step object. You can do everything in a single step or you can break it down into | ||
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. | ||
""" | ||
return await super().create_and_execute_step(task_id, step_request) | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
The Forge SDK. This is the core of the Forge. It contains the agent protocol, which is the | ||
core of the Forge. | ||
""" | ||
from .agent import Agent | ||
from .db import AgentDB | ||
from .forge_log import ForgeLogger | ||
from .schema import ( | ||
Artifact, | ||
ArtifactUpload, | ||
Pagination, | ||
Status, | ||
Step, | ||
StepInput, | ||
StepOutput, | ||
StepRequestBody, | ||
Task, | ||
TaskArtifactsListResponse, | ||
TaskInput, | ||
TaskListResponse, | ||
TaskRequestBody, | ||
TaskStepsListResponse, | ||
) | ||
from .workspace import LocalWorkspace, Workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.