Skip to content

Commit

Permalink
Merge branch 'kpczerwinski/open-745-clean-forge' into kpczerwinski/op…
Browse files Browse the repository at this point in the history
…en-428-clean-autogpt
  • Loading branch information
kcze committed May 8, 2024
2 parents f574569 + cf3119b commit 79ab731
Show file tree
Hide file tree
Showing 138 changed files with 1,970 additions and 3,181 deletions.
6 changes: 6 additions & 0 deletions .pr_agent.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pr_reviewer]
num_code_suggestions=0

[pr_code_suggestions]
commitable_code_suggestions=false
num_code_suggestions=0
7 changes: 5 additions & 2 deletions autogpts/autogpt/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
### AutoGPT - GENERAL SETTINGS
################################################################################

## OPENAI_API_KEY - OpenAI API Key (Example: my-openai-api-key)
OPENAI_API_KEY=your-openai-api-key
## OPENAI_API_KEY - OpenAI API Key (Example: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
# OPENAI_API_KEY=

## ANTHROPIC_API_KEY - Anthropic API Key (Example: sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
# ANTHROPIC_API_KEY=

## TELEMETRY_OPT_IN - Share telemetry on errors and other issues with the AutoGPT team, e.g. through Sentry.
## This helps us to spot and solve problems earlier & faster. (Default: DISABLED)
Expand Down
5 changes: 5 additions & 0 deletions autogpts/autogpt/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ repos:
- id: black
language_version: python3.10

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: 'v1.3.0'
# hooks:
Expand Down
12 changes: 7 additions & 5 deletions autogpts/autogpt/agbenchmark_config/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import sys
from pathlib import Path

from forge.config.ai_profile import AIProfile
from forge.config.config import ConfigBuilder
from forge.file_storage import FileStorageBackendName, get_storage
from forge.logging.config import configure_logging

from autogpt.agent_manager.agent_manager import AgentManager
from autogpt.agents.agent import Agent, AgentConfiguration, AgentSettings
from autogpt.app.main import _configure_openai_provider, run_interaction_loop
from autogpt.config import AIProfile, ConfigBuilder
from autogpt.file_storage import FileStorageBackendName, get_storage
from autogpt.logs.config import configure_logging
from autogpt.app.main import _configure_llm_provider, run_interaction_loop

LOG_DIR = Path(__file__).parent / "logs"

Expand Down Expand Up @@ -59,7 +61,7 @@ def bootstrap_agent(task: str, continuous_mode: bool) -> Agent:

agent = Agent(
settings=agent_settings,
llm_provider=_configure_openai_provider(config),
llm_provider=_configure_llm_provider(config),
file_storage=file_storage,
legacy_config=config,
)
Expand Down
6 changes: 4 additions & 2 deletions autogpts/autogpt/autogpt/agent_factory/configurators.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Optional

from forge.config import AIDirectives, AIProfile, Config
from forge.config.ai_directives import AIDirectives
from forge.config.ai_profile import AIProfile
from forge.config.config import Config
from forge.file_storage.base import FileStorage
from forge.llm.providers import ChatModelProvider

from autogpt.agents.agent import Agent, AgentConfiguration, AgentSettings
from autogpt.core.resource.model_providers import ChatModelProvider


def create_agent(
Expand Down
6 changes: 3 additions & 3 deletions autogpts/autogpt/autogpt/agent_factory/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from typing import TYPE_CHECKING

from forge.config import AIDirectives
from forge.config.ai_directives import AIDirectives
from forge.file_storage.base import FileStorage

if TYPE_CHECKING:
from autogpt.agents.agent import Agent
from autogpt.config import Config
from autogpt.core.resource.model_providers.schema import ChatModelProvider
from forge.config.config import Config
from forge.llm.providers.schema import ChatModelProvider

from .configurators import _configure_agent
from .profile_generator import generate_agent_profile_for_task
Expand Down
13 changes: 5 additions & 8 deletions autogpts/autogpt/autogpt/agent_factory/profile_generator.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import json
import logging

from forge.config import AIDirectives, AIProfile, Config
from forge.config.ai_directives import AIDirectives
from forge.config.ai_profile import AIProfile
from forge.config.config import Config
from forge.config.schema import SystemConfiguration, UserConfigurable
from forge.json.schema import JSONSchema

from autogpt.core.prompting import (
ChatPrompt,
LanguageModelClassification,
PromptStrategy,
)
from autogpt.core.resource.model_providers.schema import (
from forge.llm.providers.schema import (
AssistantChatMessage,
ChatMessage,
ChatModelProvider,
CompletionModelFunction,
)
from forge.prompts import ChatPrompt, LanguageModelClassification, PromptStrategy

logger = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion autogpts/autogpt/autogpt/agents/README.md

This file was deleted.

37 changes: 37 additions & 0 deletions autogpts/autogpt/autogpt/agents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 🤖 Agents

Agent is composed of [🧩 Components](./components.md) and responsible for executing pipelines and some additional logic. The base class for all agents is `BaseAgent`, it has the necessary logic to collect components and execute protocols.

## Important methods

`BaseAgent` provides two abstract methods needed for any agent to work properly:
1. `propose_action`: This method is responsible for proposing an action based on the current state of the agent, it returns `ThoughtProcessOutput`.
2. `execute`: This method is responsible for executing the proposed action, returns `ActionResult`.

## AutoGPT Agent

`Agent` is the main agent provided by AutoGPT. It's a subclass of `BaseAgent`. It has all the [Built-in Components](./built-in-components.md). `Agent` implements the essential abstract methods from `BaseAgent`: `propose_action` and `execute`.

## Building your own Agent

The easiest way to build your own agent is to extend the `Agent` class and add additional components. By doing this you can reuse the existing components and the default logic for executing [⚙️ Protocols](./protocols.md).

```py
class MyComponent(AgentComponent):
pass

class MyAgent(Agent):
def __init__(
self,
settings: AgentSettings,
llm_provider: ChatModelProvider,
file_storage: FileStorage,
legacy_config: Config,
):
# Call the parent constructor to bring in the default components
super().__init__(settings, llm_provider, file_storage, legacy_config)
# Add your custom component
self.my_component = MyComponent()
```

For more customization, you can override the `propose_action` and `execute` or even subclass `BaseAgent` directly. This way you can have full control over the agent's components and behavior. Have a look at the [implementation of Agent](https://github.com/Significant-Gravitas/AutoGPT/tree/master/autogpts/autogpt/autogpt/agents/agent.py) for more details.
7 changes: 7 additions & 0 deletions autogpts/autogpt/autogpt/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .agent import Agent
from .prompt_strategies.one_shot import OneShotAgentActionProposal

__all__ = [
"Agent",
"OneShotAgentActionProposal",
]

0 comments on commit 79ab731

Please sign in to comment.