forked from reworkd/AgentGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
29 changed files
with
1,254 additions
and
6 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Empty file.
48 changes: 48 additions & 0 deletions
48
platform/reworkd_platform/tests/agent/agent/create_model_test.py
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,48 @@ | ||
import pytest | ||
|
||
from reworkd_platform.web.api.agent.agent_service.open_ai_agent_service import ( | ||
GPT_35_TURBO, | ||
) | ||
from reworkd_platform.web.api.agent.agent_service.open_ai_agent_service import ( | ||
create_model, | ||
) | ||
from reworkd_platform.web.api.agent.model_settings import ModelSettings | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"custom_settings, expected_temperature, expected_model_name, expected_max_tokens", | ||
[ | ||
( | ||
ModelSettings( | ||
customApiKey="test_api_key", | ||
customTemperature=0.222, | ||
customModelName="Custom_Model", | ||
maxTokens=1234, | ||
), | ||
0.222, | ||
"Custom_Model", | ||
1234, | ||
), | ||
( | ||
ModelSettings( | ||
customTemperature=0.222, | ||
customModelName="Custom_Model", | ||
maxTokens=1234, | ||
), | ||
0.9, | ||
GPT_35_TURBO, | ||
400, | ||
), | ||
], | ||
) | ||
def test_create_model( | ||
custom_settings: ModelSettings, | ||
expected_temperature: float, | ||
expected_model_name: str, | ||
expected_max_tokens: int, | ||
) -> None: | ||
model = create_model(custom_settings) | ||
|
||
assert model.temperature == expected_temperature | ||
assert model.model_name == expected_model_name | ||
assert model.max_tokens == expected_max_tokens |
48 changes: 48 additions & 0 deletions
48
platform/reworkd_platform/tests/agent/agent/extract_array_test.py
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,48 @@ | ||
import pytest | ||
|
||
from reworkd_platform.web.api.agent.helpers import extract_array | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model_result, expected_length, expected_output", | ||
[ | ||
( | ||
""" | ||
```json | ||
[ | ||
"Research and implement natural language processing techniques to improve task creation accuracy.", | ||
"Develop a machine learning model to predict the most relevant tasks for users based on their past activity.", | ||
"Integrate with external tools and services to provide users with additional features such as task prioritization and scheduling." | ||
] | ||
``` | ||
""", | ||
3, | ||
[ | ||
"Research and implement natural language processing techniques to improve task creation accuracy.", | ||
"Develop a machine learning model to predict the most relevant tasks for users based on their past activity.", | ||
"Integrate with external tools and services to provide users with additional features such as task prioritization and scheduling.", | ||
], | ||
), | ||
( | ||
"['Search Reddit for current trending topics related to cats', 'Identify the most upvoted posts about cats on Reddit']", | ||
0, | ||
[], | ||
), | ||
('["Item 1","Item 2","Item 3"]', 3, ["Item 1", "Item 2", "Item 3"]), | ||
("This is not an array", 0, []), | ||
("[]", 0, []), | ||
( | ||
""" | ||
[ | ||
"Only one element" | ||
] | ||
""", | ||
1, | ||
["Only one element"], | ||
), | ||
], | ||
) | ||
def test_extract_array(model_result, expected_length, expected_output) -> None: | ||
result = extract_array(model_result) | ||
assert len(result) == expected_length | ||
assert result == expected_output |
52 changes: 52 additions & 0 deletions
52
platform/reworkd_platform/tests/agent/agent/extract_tasks_test.py
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,52 @@ | ||
from typing import List | ||
|
||
from reworkd_platform.web.api.agent.helpers import extract_tasks | ||
|
||
|
||
def test_extract_tasks_no_completed_tasks() -> None: | ||
input_text = '["Task 1: Task one", "Task 2: Task two", "Task 3: Task three"]' | ||
expected_output = ["Task one", "Task two", "Task three"] | ||
|
||
output = extract_tasks(input_text, []) | ||
|
||
assert output == expected_output | ||
|
||
|
||
def test_extract_tasks_with_completed_tasks() -> None: | ||
input_text = '["Task 1: Task one", "Task 2: Task two", "Task 3: Task three"]' | ||
completed_tasks = ["Task two"] | ||
expected_output = ["Task one", "Task three"] | ||
|
||
output = extract_tasks(input_text, completed_tasks) | ||
|
||
assert output == expected_output | ||
|
||
|
||
def test_extract_tasks_only_completed_tasks() -> None: | ||
input_text = '["Task 1: Task one", "Task 2: Task two", "Task 3: Task three"]' | ||
completed_tasks = ["Task one", "Task two", "Task three"] | ||
expected_output: List[str] = [] | ||
|
||
output = extract_tasks(input_text, completed_tasks) | ||
|
||
assert output == expected_output | ||
|
||
|
||
def test_extract_tasks_empty_input() -> None: | ||
input_text = "[]" | ||
completed_tasks: List[str] = [] | ||
expected_output: List[str] = [] | ||
|
||
output = extract_tasks(input_text, completed_tasks) | ||
|
||
assert output == expected_output | ||
|
||
|
||
def test_extract_tasks_no_valid_tasks() -> None: | ||
input_text = '["No tasks added", "Task complete", "Do nothing"]' | ||
completed_tasks: List[str] = [] | ||
expected_output: List[str] = [] | ||
|
||
output = extract_tasks(input_text, completed_tasks) | ||
|
||
assert output == expected_output |
31 changes: 31 additions & 0 deletions
31
platform/reworkd_platform/tests/agent/agent/real_task_filter_test.py
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,31 @@ | ||
from reworkd_platform.web.api.agent.helpers import real_tasks_filter | ||
|
||
|
||
def test_real_tasks_filter_valid_task() -> None: | ||
input_text = "Write the report" | ||
assert real_tasks_filter(input_text) | ||
|
||
|
||
def test_real_tasks_filter_no_task() -> None: | ||
input_text = "No new task needed" | ||
assert not real_tasks_filter(input_text) | ||
|
||
|
||
def test_real_tasks_filter_task_complete() -> None: | ||
input_text = "Task completed" | ||
assert not real_tasks_filter(input_text) | ||
|
||
|
||
def test_real_tasks_filter_do_nothing() -> None: | ||
input_text = "Do nothing" | ||
assert not real_tasks_filter(input_text) | ||
|
||
|
||
def test_real_tasks_filter_empty_string() -> None: | ||
input_text = "" | ||
assert not real_tasks_filter(input_text) | ||
|
||
|
||
def test_real_tasks_filter_case_insensitive() -> None: | ||
input_text = "no new task needed" | ||
assert real_tasks_filter(input_text) == False |
37 changes: 37 additions & 0 deletions
37
platform/reworkd_platform/tests/agent/agent/remove_task_prefix_test.py
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,37 @@ | ||
from reworkd_platform.web.api.agent.helpers import remove_task_prefix | ||
|
||
|
||
def test_removes_task_colon() -> None: | ||
task_input = "Task: This is a sample task" | ||
output = remove_task_prefix(task_input) | ||
assert output == "This is a sample task" | ||
|
||
|
||
def test_removes_task_n_colon() -> None: | ||
task_input = "Task 1: Perform a comprehensive analysis of system performance." | ||
output = remove_task_prefix(task_input) | ||
assert output == "Perform a comprehensive analysis of system performance." | ||
|
||
|
||
def test_removes_task_n_dot() -> None: | ||
task_input = "Task 2. Create a python script" | ||
output = remove_task_prefix(task_input) | ||
assert output == "Create a python script" | ||
|
||
|
||
def test_removes_n_hyphen() -> None: | ||
task_input = "5 - This is a sample task" | ||
output = remove_task_prefix(task_input) | ||
assert output == "This is a sample task" | ||
|
||
|
||
def test_removes_n_colon() -> None: | ||
task_input = "2: This is a sample task" | ||
output = remove_task_prefix(task_input) | ||
assert output == "This is a sample task" | ||
|
||
|
||
def test_no_prefix() -> None: | ||
task_input = "This is a sample task without a prefix" | ||
output = remove_task_prefix(task_input) | ||
assert output == task_input |
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,4 @@ | ||
"""API for checking running agents""" | ||
from reworkd_platform.web.api.agent.views import router | ||
|
||
__all__ = ["router"] |
Empty file.
38 changes: 38 additions & 0 deletions
38
platform/reworkd_platform/web/api/agent/agent_service/agent_service.py
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,38 @@ | ||
from typing import List, Optional, Protocol | ||
|
||
from reworkd_platform.web.api.agent.analysis import Analysis | ||
from reworkd_platform.web.api.agent.model_settings import ModelSettings | ||
|
||
|
||
class AgentService(Protocol): | ||
async def start_goal_agent( | ||
self, model_settings: ModelSettings, goal: str, language: str | ||
) -> List[str]: | ||
pass | ||
|
||
async def analyze_task_agent( | ||
self, model_settings: ModelSettings, goal: str, task: str | ||
) -> Analysis: | ||
pass | ||
|
||
async def execute_task_agent( | ||
self, | ||
model_settings: ModelSettings, | ||
goal: str, | ||
language: str, | ||
task: str, | ||
analysis: Analysis, | ||
) -> str: | ||
pass | ||
|
||
async def create_tasks_agent( | ||
self, | ||
model_settings: ModelSettings, | ||
goal: str, | ||
language: str, | ||
tasks: List[str], | ||
last_task: str, | ||
result: str, | ||
completed_tasks: Optional[List[str]] = None, | ||
) -> List[str]: | ||
pass |
15 changes: 15 additions & 0 deletions
15
platform/reworkd_platform/web/api/agent/agent_service/agent_service_provider.py
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,15 @@ | ||
from reworkd_platform.settings import settings | ||
from reworkd_platform.web.api.agent.agent_service.agent_service import AgentService | ||
from reworkd_platform.web.api.agent.agent_service.mock_agent_service import ( | ||
MockAgentService, | ||
) | ||
from reworkd_platform.web.api.agent.agent_service.open_ai_agent_service import ( | ||
OpenAIAgentService, | ||
) | ||
|
||
|
||
def get_agent_service() -> AgentService: | ||
if settings.ff_mock_mode_enabled: | ||
return MockAgentService() | ||
else: | ||
return OpenAIAgentService() |
Oops, something went wrong.