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

GenesIA is the personal and constructive complement of the function that you are going to apply #3866

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
241 changes: 0 additions & 241 deletions .env.template

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2.feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ body:
- type: textarea
attributes:
label: Motivation 🔦
description: What are you trying to accomplish? How has the lack of this feature affected you? Providing context helps us come up with a solution that is more useful in the real world.
description: What are you trying to accomplish? How has the lack of this feature affected you? Providing context helps us come up with a solution that is more useful in the real world.
39 changes: 39 additions & 0 deletions autogpt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,42 @@
load_dotenv(verbose=True, override=True)

del load_dotenv


def test_goals_are_always_lists_of_strings(tmp_path):
"""Test if the goals attribute is always a list of strings."""

yaml_content = """
ai_goals:
- Goal 1: Make a sandwich
- Goal 2, Eat the sandwich
- Goal 3 - Go to sleep
- "Goal 4: Wake up"
ai_name: McFamished
ai_role: A hungry AI
api_budget: 0.0
"""
config_file = tmp_path / "ai_settings.yaml"
config_file.write_text(yaml_content)

ai_config = AIConfig.load(config_file)

assert len(ai_config.ai_goals) == 4
assert ai_config.ai_goals[0] == "Goal 1: Make a sandwich"
assert ai_config.ai_goals[1] == "Goal 2, Eat the sandwich"
assert ai_config.ai_goals[2] == "Goal 3 - Go to sleep"
assert ai_config.ai_goals[3] == "Goal 4: Wake up"

config_file.write_text("")
ai_config.save(config_file)

yaml_content2 = """ai_goals:
- 'Goal 1: Make a sandwich'
- Goal 2, Eat the sandwich
- Goal 3 - Go to sleep
- 'Goal 4: Wake up'
ai_name: McFamished
ai_role: A hungry AI
api_budget: 0.0
"""
assert config_file.read_text() == yaml_content2
30 changes: 30 additions & 0 deletions autogpt/commands/command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import importlib
import inspect
from inspect import Parameter
from typing import Any, Callable, Optional

# Unique identifier for auto-gpt commands
Expand Down Expand Up @@ -154,3 +155,32 @@ def wrapper(*args, **kwargs) -> Any:
return wrapper

return decorator


def ignore_unexpected_kwargs(func: Callable[..., Any]) -> Callable[..., Any]:
def filter_kwargs(kwargs: dict) -> dict:
sig = inspect.signature(func)
# Parameter.VAR_KEYWORD - a dict of keyword arguments that aren't bound to any other
if any(map(lambda p: p.kind == Parameter.VAR_KEYWORD, sig.parameters.values())):
# if **kwargs exist, return directly
return kwargs

_params = list(
filter(
lambda p: p.kind
in {Parameter.KEYWORD_ONLY, Parameter.POSITIONAL_OR_KEYWORD},
sig.parameters.values(),
)
)

res_kwargs = {
param.name: kwargs[param.name] for param in _params if param.name in kwargs
}
return res_kwargs

@functools.wraps(func)
def wrapper(*args, **kwargs) -> Any:
kwargs = filter_kwargs(kwargs)
return func(*args, **kwargs)

return wrapper
8 changes: 4 additions & 4 deletions autogpt/commands/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from colorama import Back, Fore
from requests.adapters import HTTPAdapter, Retry

from autogpt.commands.command import command
from autogpt.commands.command import command, ignore_unexpected_kwargs
from autogpt.config import Config
from autogpt.logs import logger
from autogpt.spinner import Spinner
Expand Down Expand Up @@ -271,9 +271,9 @@ def delete_file(filename: str) -> str:
return f"Error: {err}"


@command("list_files", "List Files in Directory", '"directory": "<directory>"')
def list_files(directory: str) -> list[str]:
"""lists files in a directory recursively
@command("search_files", "Search Files", '"directory": "<directory>"')
def search_files(directory: str) -> list[str]:
"""Search for files in a directory

Args:
directory (str): The directory to search in
Expand Down
2 changes: 1 addition & 1 deletion autogpt/prompts/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self) -> None:
"criticism": "constructive self-criticism",
"speak": "thoughts summary to say to user",
},
"command": {"name": "command name", "args": {"arg name": "value"}},
"command": {"name": "command_name", "args": {"arg_name": "value"}},
}

def add_constraint(self, constraint: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion run_continuous.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/bash

./run.sh --continuous $@
Loading