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.

Fix runtime error in the API (#5047)

Tomas Valentaabed282db34a
diff --git a/autogpt/core/runner/cli_web_app/cli.py b/autogpt/core/runner/cli_web_app/cli.py
index ecb4232473..e933739b24 100644
--- a/autogpt/core/runner/cli_web_app/cli.py
+++ b/autogpt/core/runner/cli_web_app/cli.py
@@ -2,12 +2,12 @@ import pathlib
import click
import yaml
-from agent_protocol import Agent
+from agent_protocol import Agent as AgentProtocol
+from autogpt.core.runner.cli_web_app.server.api import task_handler
from autogpt.core.runner.client_lib.shared_click_commands import (
DEFAULT_SETTINGS_FILE,
make_settings,
- status,
)
from autogpt.core.runner.client_lib.utils import coroutine
@@ -19,7 +19,6 @@ def autogpt():
autogpt.add_command(make_settings)
-autogpt.add_command(status)
@autogpt.command()
@@ -33,8 +32,7 @@ autogpt.add_command(status)
def server(port: int) -> None:
"""Run the Auto-GPT runner httpserver."""
click.echo("Running Auto-GPT runner httpserver...")
- port = 8080
- Agent.start(port)
+ AgentProtocol.handle_task(task_handler).start(port)
@autogpt.command()
diff --git a/autogpt/core/runner/cli_web_app/server/api.py b/autogpt/core/runner/cli_web_app/server/api.py
index 90f63e5ad3..2dc3f0101c 100644
--- a/autogpt/core/runner/cli_web_app/server/api.py
+++ b/autogpt/core/runner/cli_web_app/server/api.py
@@ -1,6 +1,5 @@
from pathlib import Path
-from agent_protocol import Agent as AgentProtocol
from agent_protocol import StepHandler, StepResult
from colorama import Fore
@@ -18,21 +17,25 @@ PROJECT_DIR = Path().resolve()
async def task_handler(task_input) -> StepHandler:
- agent = bootstrap_agent(task_input)
+ task = task_input.__root__ if task_input else {}
+ agent = bootstrap_agent(task.get("user_input"), False)
- next_command_name: str | None
- next_command_args: dict[str, str] | None
+ next_command_name: str | None = None
+ next_command_args: dict[str, str] | None = None
async def step_handler(step_input) -> StepResult:
+ step = step_input.__root__ if step_input else {}
+
+ nonlocal next_command_name, next_command_args
+
result = await interaction_step(
agent,
- step_input["user_input"],
- step_input["user_feedback"],
+ step.get("user_input"),
+ step.get("user_feedback"),
next_command_name,
next_command_args,
)
- nonlocal next_command_name, next_command_args
next_command_name = result["next_step_command_name"] if result else None
next_command_args = result["next_step_command_args"] if result else None
@@ -76,19 +79,20 @@ async def interaction_step(
}
-def bootstrap_agent(task):
+def bootstrap_agent(task, continuous_mode) -> Agent:
config = ConfigBuilder.build_config_from_env(workdir=PROJECT_DIR)
- config.continuous_mode = False
+ config.debug_mode = True
+ config.continuous_mode = continuous_mode
config.temperature = 0
config.plain_output = True
command_registry = get_command_registry(config)
config.memory_backend = "no_memory"
- Workspace.set_workspace_directory(config)
- Workspace.build_file_logger_path(config, config.workspace_path)
+ config.workspace_path = Workspace.set_workspace_directory(config)
+ config.file_logger_path = Workspace.build_file_logger_path(config.workspace_path)
ai_config = AIConfig(
ai_name="Auto-GPT",
ai_role="a multi-purpose AI assistant.",
- ai_goals=[task.user_input],
+ ai_goals=[task],
)
ai_config.command_registry = command_registry
return Agent(
@@ -97,7 +101,6 @@ def bootstrap_agent(task):
ai_config=ai_config,
config=config,
triggering_prompt=DEFAULT_TRIGGERING_PROMPT,
- workspace_directory=str(config.workspace_path),
)
@@ -109,6 +112,3 @@ def get_command_registry(config: Config):
for command_category in enabled_command_categories:
command_registry.import_commands(command_category)
return command_registry
-
-
-AgentProtocol.handle_task(task_handler)