Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to directories and some added text about why to log #2

Merged
merged 24 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b00570f
Fix CI warnings
Pwuts Jul 12, 2023
21c0cdc
Disable proxy for internal pull requests (#4953)
Pwuts Jul 12, 2023
d4953f6
Add initial share logs page
mlejva Jul 12, 2023
d5e22ea
Fix title sizes
mlejva Jul 12, 2023
3582ada
Add links to github issues in the README and clarify run instructions…
collijk Jul 12, 2023
6dd7e8b
Update share_logs.md
NeonN3mesis Jul 12, 2023
33a5f5d
Merge pull request #1 from NeonN3mesis/patch-1
mlejva Jul 13, 2023
eb430be
Add section on how to share logs using e2b
mlejva Jul 13, 2023
d749108
Fix path to images with sizes
mlejva Jul 13, 2023
077e143
Documentation/collate rearch notes (#4958)
collijk Jul 13, 2023
78831f7
Fix paths to images in docs
mlejva Jul 13, 2023
1cff685
Fix formatting
mlejva Jul 13, 2023
4facf7a
Fix formatting
mlejva Jul 13, 2023
dba0031
Merge branch 'master' into mlejva-docs-share-logs
mlejva Jul 13, 2023
f45bda9
Fix grammar
mlejva Jul 13, 2023
90e5be9
Merge branch 'mlejva-docs-share-logs' of https://github.com/mlejva/Au…
mlejva Jul 13, 2023
4177c37
Refactor/move functions in app to agent (#4957)
collijk Jul 13, 2023
c9adedf
Refactor/rename agent subpackage to agents (#4961)
collijk Jul 13, 2023
a0f5aa9
Fix Netlify preview builds
Pwuts Jul 13, 2023
8144521
Merge branch 'master' into mlejva-docs-share-logs
Pwuts Jul 13, 2023
bf12ffe
Make position in menu more prominent
Pwuts Jul 13, 2023
33df2e4
original log directory was incorrect
NeonN3mesis Jul 13, 2023
a4d011f
Updated the directory for the logs
NeonN3mesis Jul 13, 2023
d850bfa
added some text
NeonN3mesis Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
with:
ref: master

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Set up Python ${{ matrix.config.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config.python-version }}

Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ env.min-python-version }}

Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
fi

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -159,9 +159,10 @@ jobs:
python tests/challenges/utils/build_current_score.py
env:
CI: true
PROXY: ${{ secrets.PROXY }}
AGENT_MODE: ${{ secrets.AGENT_MODE }}
AGENT_TYPE: ${{ secrets.AGENT_TYPE }}
PROXY: ${{ github.event_name == 'pull_request_target' && secrets.PROXY || '' }}
AGENT_MODE: ${{ github.event_name == 'pull_request_target' && secrets.AGENT_MODE || '' }}
AGENT_TYPE: ${{ github.event_name == 'pull_request_target' && secrets.AGENT_TYPE || '' }}
OPENAI_API_KEY: ${{ github.event_name == 'pull_request' && secrets.OPENAI_API_KEY || '' }}
PLAIN_OUTPUT: True

- name: Upload coverage reports to Codecov
Expand Down
3 changes: 0 additions & 3 deletions autogpt/agent/__init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions autogpt/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .agent import Agent

__all__ = ["Agent"]
95 changes: 92 additions & 3 deletions autogpt/agent/agent.py → autogpt/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from autogpt.config import Config
from autogpt.config.ai_config import AIConfig
from autogpt.json_utils.utilities import extract_json_from_response, validate_json
from autogpt.llm import ChatModelResponse
from autogpt.llm.chat import chat_with_ai
from autogpt.llm.providers.openai import OPEN_AI_CHAT_MODELS
from autogpt.llm.utils import count_string_tokens
Expand Down Expand Up @@ -86,9 +87,6 @@ def __init__(
self.smart_token_limit = OPEN_AI_CHAT_MODELS.get(config.smart_llm).max_tokens

def start_interaction_loop(self):
# Avoid circular imports
from autogpt.app import execute_command, extract_command

# Interaction Loop
self.cycle_count = 0
command_name = None
Expand Down Expand Up @@ -307,3 +305,94 @@ def signal_handler(signum, frame):
logger.typewriter_log(
"SYSTEM: ", Fore.YELLOW, "Unable to execute command"
)


def extract_command(
assistant_reply_json: dict, assistant_reply: ChatModelResponse, config: Config
):
"""Parse the response and return the command name and arguments

Args:
assistant_reply_json (dict): The response object from the AI
assistant_reply (ChatModelResponse): The model response from the AI
config (Config): The config object

Returns:
tuple: The command name and arguments

Raises:
json.decoder.JSONDecodeError: If the response is not valid JSON

Exception: If any other error occurs
"""
if config.openai_functions:
if assistant_reply.function_call is None:
return "Error:", "No 'function_call' in assistant reply"
assistant_reply_json["command"] = {
"name": assistant_reply.function_call.name,
"args": json.loads(assistant_reply.function_call.arguments),
}
try:
if "command" not in assistant_reply_json:
return "Error:", "Missing 'command' object in JSON"

if not isinstance(assistant_reply_json, dict):
return (
"Error:",
f"The previous message sent was not a dictionary {assistant_reply_json}",
)

command = assistant_reply_json["command"]
if not isinstance(command, dict):
return "Error:", "'command' object is not a dictionary"

if "name" not in command:
return "Error:", "Missing 'name' field in 'command' object"

command_name = command["name"]

# Use an empty dictionary if 'args' field is not present in 'command' object
arguments = command.get("args", {})

return command_name, arguments
except json.decoder.JSONDecodeError:
return "Error:", "Invalid JSON"
# All other errors, return "Error: + error message"
except Exception as e:
return "Error:", str(e)


def execute_command(
command_name: str,
arguments: dict[str, str],
agent: Agent,
):
"""Execute the command and return the result

Args:
command_name (str): The name of the command to execute
arguments (dict): The arguments for the command
agent (Agent): The agent that is executing the command

Returns:
str: The result of the command
"""
try:
# Execute a native command with the same name or alias, if it exists
if command := agent.command_registry.get_command(command_name):
return command(**arguments, agent=agent)

# Handle non-native commands (e.g. from plugins)
for command in agent.ai_config.prompt_generator.commands:
if (
command_name == command["label"].lower()
or command_name == command["name"].lower()
):
return command["function"](**arguments)

raise RuntimeError(
f"Cannot execute '{command_name}': unknown command."
" Do not try to use this command again."
)
except Exception as e:
return f"Error: {str(e)}"
114 changes: 0 additions & 114 deletions autogpt/app.py

This file was deleted.

2 changes: 1 addition & 1 deletion autogpt/commands/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Callable

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.logs import logger


Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/execute_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from docker.errors import DockerException, ImageNotFound
from docker.models.containers import Container as DockerContainer

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.config import Config
from autogpt.logs import logger
Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path
from typing import Generator, Literal

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.logs import logger
from autogpt.memory.vector import MemoryItem, VectorMemory
Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/git_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from git.repo import Repo

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.url_utils.validators import validate_url

Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/image_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
from PIL import Image

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.logs import logger

Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/task_statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from typing import NoReturn

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.logs import logger

Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/web_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from duckduckgo_search import DDGS

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command

DUCKDUCKGO_MAX_ATTEMPTS = 3
Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/web_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager as EdgeDriverManager

from autogpt.agent.agent import Agent
from autogpt.agents.agent import Agent
from autogpt.command_decorator import command
from autogpt.logs import logger
from autogpt.memory.vector import MemoryItem, get_memory
Expand Down
Loading