AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
AutoGPT: Improve output format of web commands
Reinier van der Leere75073b4958f
diff --git a/autogpts/autogpt/autogpt/commands/web_search.py b/autogpts/autogpt/autogpt/commands/web_search.pyindex 82b8824075..de77d5d1e0 100644--- a/autogpts/autogpt/autogpt/commands/web_search.py+++ b/autogpts/autogpt/autogpt/commands/web_search.py@@ -57,6 +57,11 @@ def web_search(query: str, agent: Agent, num_results: int = 8) -> str:time.sleep(1)attempts += 1+ search_results = [+ {"title": r["title"], "url": r["href"], "description": r["body"]}+ for r in search_results+ ]+results = json.dumps(search_results, ensure_ascii=False, indent=4)return safe_google_results(results)diff --git a/autogpts/autogpt/autogpt/commands/web_selenium.py b/autogpts/autogpt/autogpt/commands/web_selenium.pyindex 2175694cec..a60dd911ec 100644--- a/autogpts/autogpt/autogpt/commands/web_selenium.py+++ b/autogpts/autogpt/autogpt/commands/web_selenium.py@@ -111,11 +111,12 @@ async def read_webpage(url: str, agent: Agent, question: str = "") -> str:links = links[:LINKS_TO_RETURN]text_fmt = f"'''{text}'''" if "\n" in text else f"'{text}'"+ links_fmt = "\n".join(f"- {link}" for link in links)return (f"Page content{' (summary)' if summarized else ''}:"if return_literal_contentelse "Answer gathered from webpage:"- ) + f" {text_fmt}\n\nLinks: {links}"+ ) + f" {text_fmt}\n\nLinks:\n{links_fmt}"except WebDriverException as e:# These errors are often quite long and include lots of context.diff --git a/autogpts/autogpt/autogpt/processing/html.py b/autogpts/autogpt/autogpt/processing/html.pyindex 81387b12ad..73c65b9c99 100644--- a/autogpts/autogpt/autogpt/processing/html.py+++ b/autogpts/autogpt/autogpt/processing/html.py@@ -30,4 +30,4 @@ def format_hyperlinks(hyperlinks: list[tuple[str, str]]) -> list[str]:Returns:List[str]: The formatted hyperlinks"""- return [f"{link_text} ({link_url})" for link_text, link_url in hyperlinks]+ return [f"{link_text.strip()} ({link_url})" for link_text, link_url in hyperlinks]