From d0dd107f3940ba5b9b41b2ed1d9433956a2ac90c Mon Sep 17 00:00:00 2001 From: Jedakiah Date: Fri, 14 Apr 2023 20:00:36 +0200 Subject: [PATCH 1/2] Fixed error when google results might have weird characters --- scripts/commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/commands.py b/scripts/commands.py index fe6f6c30..15e4b2e3 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -61,9 +61,12 @@ def execute_command(command_name, arguments): # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): - return google_official_search(arguments["input"]) + google_result = google_official_search(arguments["input"]) else: - return google_search(arguments["input"]) + google_result = google_search(arguments["input"]) + + safe_message = google_result.encode('utf-8', 'ignore') + return str(safe_message) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": From 02db53e12fe167042f2318af28d7d2f7e2bca228 Mon Sep 17 00:00:00 2001 From: Jedakiah Date: Sat, 15 Apr 2023 17:01:29 +0200 Subject: [PATCH 2/2] Fixed error when google search contains funny characters --- autogpt/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autogpt/app.py b/autogpt/app.py index 0adfde5d..8d9cc9ee 100644 --- a/autogpt/app.py +++ b/autogpt/app.py @@ -105,9 +105,11 @@ def execute_command(command_name: str, arguments): # search method key = CFG.google_api_key if key and key.strip() and key != "your-google-api-key": - return google_official_search(arguments["input"]) + google_result = google_official_search(arguments["input"]) else: - return google_search(arguments["input"]) + google_result = google_search(arguments["input"]) + safe_message = google_result.encode('utf-8', 'ignore') + return str(safe_message) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent":