-
Notifications
You must be signed in to change notification settings - Fork 43.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-bug-2801-2871-2906
- Loading branch information
Showing
2 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from autogpt.agent.agent import Agent | ||
from autogpt.config import AIConfig | ||
from autogpt.llm_utils import create_chat_completion | ||
|
||
|
||
def test_get_self_feedback(mocker): | ||
# Define a sample thoughts dictionary | ||
thoughts = { | ||
"reasoning": "Sample reasoning.", | ||
"plan": "Sample plan.", | ||
"thoughts": "Sample thoughts.", | ||
"criticism": "Sample criticism.", | ||
} | ||
|
||
# Define a fake response for the create_chat_completion function | ||
fake_response = ( | ||
"Y The provided information is suitable for achieving the role's objectives." | ||
) | ||
|
||
# Mock the create_chat_completion function | ||
mock_create_chat_completion = mocker.patch( | ||
"autogpt.agent.agent.create_chat_completion", wraps=create_chat_completion | ||
) | ||
mock_create_chat_completion.return_value = fake_response | ||
|
||
# Create a MagicMock object to replace the Agent instance | ||
agent_mock = mocker.MagicMock(spec=Agent) | ||
|
||
# Mock the config attribute of the Agent instance | ||
agent_mock.config = AIConfig() | ||
|
||
# Call the get_self_feedback method | ||
feedback = Agent.get_self_feedback( | ||
agent_mock, | ||
thoughts, | ||
"gpt-3.5-turbo", | ||
) | ||
|
||
# Check if the response is correct | ||
assert feedback == fake_response |