mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-06 07:44:35 +01:00
Test Agent.create_agent_feedback (#3209)
This commit is contained in:
40
tests/unit/test_get_self_feedback.py
Normal file
40
tests/unit/test_get_self_feedback.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user