mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-23 17:04:21 +01:00
fix information retrieval challenge (#4448)
This commit is contained in:
@@ -101,7 +101,6 @@ def input_generator(input_sequence: list) -> Generator[str, None, None]:
|
|||||||
@pytest.mark.skip("This challenge hasn't been beaten yet.")
|
@pytest.mark.skip("This challenge hasn't been beaten yet.")
|
||||||
@pytest.mark.vcr
|
@pytest.mark.vcr
|
||||||
@requires_api_key("OPENAI_API_KEY")
|
@requires_api_key("OPENAI_API_KEY")
|
||||||
@run_multiple_times(3)
|
|
||||||
def test_information_retrieval_challenge_a(kubernetes_agent, monkeypatch) -> None:
|
def test_information_retrieval_challenge_a(kubernetes_agent, monkeypatch) -> None:
|
||||||
"""
|
"""
|
||||||
Test the challenge_a function in a given agent by mocking user inputs
|
Test the challenge_a function in a given agent by mocking user inputs
|
||||||
|
|||||||
@@ -145,17 +145,18 @@ def get_company_revenue_agent(
|
|||||||
):
|
):
|
||||||
command_registry = CommandRegistry()
|
command_registry = CommandRegistry()
|
||||||
command_registry.import_commands("autogpt.commands.file_operations")
|
command_registry.import_commands("autogpt.commands.file_operations")
|
||||||
|
command_registry.import_commands("autogpt.commands.google_search")
|
||||||
command_registry.import_commands("autogpt.app")
|
command_registry.import_commands("autogpt.app")
|
||||||
|
command_registry.import_commands("autogpt.commands.task_statuses")
|
||||||
|
|
||||||
ai_config = AIConfig(
|
ai_config = AIConfig(
|
||||||
ai_name="Get-CompanyRevenue",
|
ai_name="Information Retrieval Agent",
|
||||||
ai_role="an autonomous agent that specializes in finding the reported revenue of a company.",
|
ai_role="an autonomous agent that specializes in retrieving information.",
|
||||||
ai_goals=[
|
ai_goals=[
|
||||||
"Write the revenue of Tesla in 2022 to a file. You should write the number without commas and you should not use signs like B for billion and M for million.",
|
"Search for 'tesla revenue 2022' and write the revenue of Tesla in 2022 to a file called output.txt. You should write the number without commas and you should not use signs like B for billion and M for million.",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
ai_config.command_registry = command_registry
|
ai_config.command_registry = command_registry
|
||||||
|
|
||||||
system_prompt = ai_config.construct_full_prompt()
|
system_prompt = ai_config.construct_full_prompt()
|
||||||
Config().set_continuous_mode(False)
|
Config().set_continuous_mode(False)
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
@@ -168,7 +169,6 @@ def get_company_revenue_agent(
|
|||||||
triggering_prompt=DEFAULT_TRIGGERING_PROMPT,
|
triggering_prompt=DEFAULT_TRIGGERING_PROMPT,
|
||||||
workspace_directory=workspace.root,
|
workspace_directory=workspace.root,
|
||||||
)
|
)
|
||||||
|
|
||||||
return agent
|
return agent
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,15 @@ import pytest
|
|||||||
|
|
||||||
from autogpt.commands.file_operations import read_file, write_to_file
|
from autogpt.commands.file_operations import read_file, write_to_file
|
||||||
from autogpt.config import Config
|
from autogpt.config import Config
|
||||||
from tests.integration.challenges.utils import run_interaction_loop, run_multiple_times
|
from tests.integration.challenges.utils import run_interaction_loop
|
||||||
from tests.utils import requires_api_key
|
from tests.utils import requires_api_key
|
||||||
|
|
||||||
CYCLE_COUNT = 3
|
CYCLE_COUNT = 3
|
||||||
from autogpt.agent import Agent
|
from autogpt.agent import Agent
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip("This challenge hasn't been beaten yet.")
|
|
||||||
@pytest.mark.vcr
|
@pytest.mark.vcr
|
||||||
@requires_api_key("OPENAI_API_KEY")
|
@requires_api_key("OPENAI_API_KEY")
|
||||||
@run_multiple_times(3)
|
|
||||||
def test_information_retrieval_challenge_a(
|
def test_information_retrieval_challenge_a(
|
||||||
get_company_revenue_agent: Agent,
|
get_company_revenue_agent: Agent,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import yaml
|
|||||||
from autogpt.agent import Agent
|
from autogpt.agent import Agent
|
||||||
from autogpt.commands.file_operations import read_file
|
from autogpt.commands.file_operations import read_file
|
||||||
from autogpt.config import Config
|
from autogpt.config import Config
|
||||||
from tests.integration.challenges.utils import run_interaction_loop, run_multiple_times
|
from tests.integration.challenges.utils import run_interaction_loop
|
||||||
from tests.utils import requires_api_key
|
from tests.utils import requires_api_key
|
||||||
|
|
||||||
CYCLE_COUNT = 6
|
CYCLE_COUNT = 6
|
||||||
@@ -13,7 +13,6 @@ CYCLE_COUNT = 6
|
|||||||
@pytest.mark.skip("This challenge hasn't been beaten yet.")
|
@pytest.mark.skip("This challenge hasn't been beaten yet.")
|
||||||
@pytest.mark.vcr
|
@pytest.mark.vcr
|
||||||
@requires_api_key("OPENAI_API_KEY")
|
@requires_api_key("OPENAI_API_KEY")
|
||||||
@run_multiple_times(3)
|
|
||||||
def test_kubernetes_template_challenge_a(
|
def test_kubernetes_template_challenge_a(
|
||||||
kubernetes_agent: Agent, monkeypatch: pytest.MonkeyPatch, config: Config
|
kubernetes_agent: Agent, monkeypatch: pytest.MonkeyPatch, config: Config
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@@ -48,24 +48,6 @@ def generate_noise(noise_size: int) -> str:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_multiple_times(times: int) -> Callable:
|
|
||||||
"""
|
|
||||||
Decorator that runs a test function multiple times.
|
|
||||||
|
|
||||||
:param times: The number of times the test function should be executed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def decorator(test_func: Callable[..., Any]) -> Callable[..., Any]:
|
|
||||||
@wraps(test_func)
|
|
||||||
def wrapper(*args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> None:
|
|
||||||
for _ in range(times):
|
|
||||||
test_func(*args, **kwargs)
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
def setup_mock_input(monkeypatch: pytest.MonkeyPatch, cycle_count: int) -> None:
|
def setup_mock_input(monkeypatch: pytest.MonkeyPatch, cycle_count: int) -> None:
|
||||||
"""
|
"""
|
||||||
Sets up the mock input for testing.
|
Sets up the mock input for testing.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ REPLACEMENTS: List[Dict[str, str]] = [
|
|||||||
ALLOWED_HOSTNAMES: List[str] = [
|
ALLOWED_HOSTNAMES: List[str] = [
|
||||||
"api.openai.com",
|
"api.openai.com",
|
||||||
"localhost:50337",
|
"localhost:50337",
|
||||||
|
"duckduckgo.com",
|
||||||
]
|
]
|
||||||
|
|
||||||
if PROXY:
|
if PROXY:
|
||||||
|
|||||||
Reference in New Issue
Block a user