Fix web_search tests

This commit is contained in:
Reinier van der Leer
2023-10-17 17:07:37 -07:00
parent 7e7365eac2
commit 3cc8b2abf7
2 changed files with 7 additions and 3 deletions

View File

@@ -58,7 +58,11 @@ def web_search(query: str, agent: Agent, num_results: int = 8) -> str:
attempts += 1
search_results = [
{"title": r["title"], "url": r["href"], "description": r["body"]}
{
"title": r["title"],
"url": r["href"],
**({"description": r["body"]} if r.get("body") else {}),
}
for r in search_results
]

View File

@@ -29,8 +29,8 @@ def test_safe_google_results_invalid_input():
(
"test",
1,
'[\n {\n "title": "Result 1",\n "link": "https://example.com/result1"\n }\n]',
[{"title": "Result 1", "link": "https://example.com/result1"}],
'[\n {\n "title": "Result 1",\n "url": "https://example.com/result1"\n }\n]',
[{"title": "Result 1", "href": "https://example.com/result1"}],
),
("", 1, "[]", []),
("no results", 1, "[]", []),