forked from Significant-Gravitas/AutoGPT
-
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.
Validate skill tree so the UI never breaks (Significant-Gravitas#5306)
Validate skill tree to prevent it from breaking the UI Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
- Loading branch information
1 parent
ecc8d94
commit fa9fc18
Showing
7 changed files
with
321 additions
and
5 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
benchmark/agbenchmark/challenges/verticals/scrape/2_book_price/data.json
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"category": [ | ||
"retrieval" | ||
"retrieval", | ||
"general" | ||
], | ||
"cutoff": 60, | ||
"dependencies": [ | ||
|
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
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,57 @@ | ||
from agbenchmark.utils.dependencies.graphs import get_roots | ||
|
||
|
||
def test_get_roots(): | ||
graph = { | ||
"nodes": [ | ||
{"id": "A", "data": {"category": []}}, | ||
{"id": "B", "data": {"category": []}}, | ||
{"id": "C", "data": {"category": []}}, | ||
{"id": "D", "data": {"category": []}}, | ||
], | ||
"edges": [ | ||
{"from": "A", "to": "B"}, | ||
{"from": "B", "to": "C"}, | ||
], | ||
} | ||
|
||
result = get_roots(graph) | ||
assert set(result) == { | ||
"A", | ||
"D", | ||
}, f"Expected roots to be 'A' and 'D', but got {result}" | ||
|
||
|
||
def test_no_roots(): | ||
fully_connected_graph = { | ||
"nodes": [ | ||
{"id": "A", "data": {"category": []}}, | ||
{"id": "B", "data": {"category": []}}, | ||
{"id": "C", "data": {"category": []}}, | ||
], | ||
"edges": [ | ||
{"from": "A", "to": "B"}, | ||
{"from": "B", "to": "C"}, | ||
{"from": "C", "to": "A"}, | ||
], | ||
} | ||
|
||
result = get_roots(fully_connected_graph) | ||
assert not result, "Expected no roots, but found some" | ||
|
||
|
||
# def test_no_rcoots(): | ||
# fully_connected_graph = { | ||
# "nodes": [ | ||
# {"id": "A", "data": {"category": []}}, | ||
# {"id": "B", "data": {"category": []}}, | ||
# {"id": "C", "data": {"category": []}}, | ||
# ], | ||
# "edges": [ | ||
# {"from": "A", "to": "B"}, | ||
# {"from": "D", "to": "C"}, | ||
# ], | ||
# } | ||
# | ||
# result = get_roots(fully_connected_graph) | ||
# assert set(result) == {"A"}, f"Expected roots to be 'A', but got {result}" |
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,47 @@ | ||
from agbenchmark.utils.dependencies.graphs import is_circular | ||
|
||
|
||
def test_is_circular(): | ||
cyclic_graph = { | ||
"nodes": [ | ||
{"id": "A", "data": {"category": []}}, | ||
{"id": "B", "data": {"category": []}}, | ||
{"id": "C", "data": {"category": []}}, | ||
{"id": "D", "data": {"category": []}}, # New node | ||
], | ||
"edges": [ | ||
{"from": "A", "to": "B"}, | ||
{"from": "B", "to": "C"}, | ||
{"from": "C", "to": "D"}, | ||
{"from": "D", "to": "A"}, # This edge creates a cycle | ||
], | ||
} | ||
|
||
result = is_circular(cyclic_graph) | ||
assert result is not None, "Expected a cycle, but none was detected" | ||
assert all( | ||
( | ||
(result[i], result[i + 1]) | ||
in [(x["from"], x["to"]) for x in cyclic_graph["edges"]] | ||
) | ||
for i in range(len(result) - 1) | ||
), "The detected cycle path is not part of the graph's edges" | ||
|
||
|
||
def test_is_not_circular(): | ||
acyclic_graph = { | ||
"nodes": [ | ||
{"id": "A", "data": {"category": []}}, | ||
{"id": "B", "data": {"category": []}}, | ||
{"id": "C", "data": {"category": []}}, | ||
{"id": "D", "data": {"category": []}}, # New node | ||
], | ||
"edges": [ | ||
{"from": "A", "to": "B"}, | ||
{"from": "B", "to": "C"}, | ||
{"from": "C", "to": "D"}, | ||
# No back edge from D to any node, so it remains acyclic | ||
], | ||
} | ||
|
||
assert is_circular(acyclic_graph) is None, "Detected a cycle in an acyclic graph" |
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 |
---|---|---|
@@ -1,4 +1,133 @@ | ||
{ | ||
"edges": [], | ||
"nodes": [] | ||
"edges": [ | ||
{ | ||
"arrows": "to", | ||
"from": "agbenchmark/generate_test.py::TestSearch::test_method[challenge_data0]", | ||
"id": "agbenchmark/generate_test.py::TestSearch::test_method[challenge_data0]_to_agbenchmark/generate_test.py::TestBasicRetrieval::test_method[challenge_data0]", | ||
"to": "agbenchmark/generate_test.py::TestBasicRetrieval::test_method[challenge_data0]" | ||
}, | ||
{ | ||
"arrows": "to", | ||
"from": "agbenchmark/generate_test.py::TestWriteFile::test_method[challenge_data0]", | ||
"id": "agbenchmark/generate_test.py::TestWriteFile::test_method[challenge_data0]_to_agbenchmark/generate_test.py::TestSearch::test_method[challenge_data0]", | ||
"to": "agbenchmark/generate_test.py::TestSearch::test_method[challenge_data0]" | ||
} | ||
], | ||
"nodes": [ | ||
{ | ||
"color": "grey", | ||
"data": { | ||
"category": [ | ||
"retrieval", | ||
"general" | ||
], | ||
"cutoff": 60, | ||
"dependencies": [ | ||
"TestSearch" | ||
], | ||
"eval_id": "525001ed-8b45-4405-9e56-ce4423314294", | ||
"ground": { | ||
"answer": "\u00a325.89", | ||
"eval": { | ||
"type": "file" | ||
}, | ||
"files": [ | ||
".txt" | ||
], | ||
"should_contain": [ | ||
"25.89" | ||
], | ||
"should_not_contain": [] | ||
}, | ||
"info": { | ||
"description": "Specifies specific website to retrieve website from.", | ||
"difficulty": "basic", | ||
"side_effects": [] | ||
}, | ||
"name": "TestBasicRetrieval", | ||
"task": "Write the price of the book in this url 'http://books.toscrape.com/catalogue/meditations_33/index.html' to a .txt file." | ||
}, | ||
"id": "agbenchmark/generate_test.py::TestBasicRetrieval::test_method[challenge_data0]", | ||
"label": "BasicRetrieval", | ||
"shape": "dot" | ||
}, | ||
{ | ||
"color": "grey", | ||
"data": { | ||
"category": [ | ||
"interface" | ||
], | ||
"cutoff": 120, | ||
"dependencies": [ | ||
"TestWriteFile" | ||
], | ||
"eval_id": "6390114a-531d-4743-a51b-50ba6ff8da43", | ||
"ground": { | ||
"answer": "This is a Heading\nThis is a paragraph.", | ||
"eval": { | ||
"type": "file" | ||
}, | ||
"files": [ | ||
".txt" | ||
], | ||
"should_contain": [ | ||
"Heading", | ||
"paragraph" | ||
], | ||
"should_not_contain": [ | ||
"The", | ||
"the" | ||
] | ||
}, | ||
"info": { | ||
"description": "Tests if an llm can search", | ||
"difficulty": "interface", | ||
"side_effects": [ | ||
"" | ||
] | ||
}, | ||
"name": "TestSearch", | ||
"task": "Open 'https://silennaihin.com/random/plain.html' and paste all of the text on the page in a .txt file" | ||
}, | ||
"id": "agbenchmark/generate_test.py::TestSearch::test_method[challenge_data0]", | ||
"label": "Search", | ||
"shape": "dot" | ||
}, | ||
{ | ||
"color": "grey", | ||
"data": { | ||
"category": [ | ||
"interface" | ||
], | ||
"cutoff": 60, | ||
"dependencies": [], | ||
"eval_id": "81b64bf9-2b6a-4ac8-bcd2-8bfe36244ac0", | ||
"ground": { | ||
"answer": "The word 'Washington', printed to a .txt file named anything", | ||
"eval": { | ||
"type": "file" | ||
}, | ||
"files": [ | ||
".txt" | ||
], | ||
"should_contain": [ | ||
"Washington" | ||
], | ||
"should_not_contain": [] | ||
}, | ||
"info": { | ||
"description": "Tests the agents ability to write to a file", | ||
"difficulty": "interface", | ||
"side_effects": [ | ||
"" | ||
] | ||
}, | ||
"name": "TestWriteFile", | ||
"task": "Write the word 'Washington' to a .txt file" | ||
}, | ||
"id": "agbenchmark/generate_test.py::TestWriteFile::test_method[challenge_data0]", | ||
"label": "WriteFile", | ||
"shape": "dot" | ||
} | ||
] | ||
} |
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