Skip to content

Commit

Permalink
Merge pull request #1793 from ickma/fix-google-search-encoding
Browse files Browse the repository at this point in the history
 Fix google api fetch error
  • Loading branch information
BillSchumacher authored Apr 16, 2023
2 parents 2193d64 + 2576b29 commit 5e67722
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions autogpt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ def execute_command(command_name: str, arguments):
key = CFG.google_api_key
if key and key.strip() and key != "your-google-api-key":
google_result = google_official_search(arguments["input"])
return google_result
else:
google_result = google_search(arguments["input"])
safe_message = google_result.encode("utf-8", "ignore")
return str(safe_message)
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":
Expand Down

1 comment on commit 5e67722

@ACSKamloops
Copy link

@ACSKamloops ACSKamloops commented on 5e67722 Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this provide a list of search results? Or is it better to not have it accept a list at all. I don't see anywhere to see the logic if it just takes the first search result or not. The reason I ask is because I made this change and it finds the top 5 results and then picks one based on what link it thinks is the most useful. I don't know if this is considerable worse or what though, thanks!


            # Check if the result is a list and handle it accordingly
            if isinstance(google_result, list):
                # Convert the list to a string and then encode it to UTF-8
                google_result = str(google_result)
            elif isinstance(google_result, str):
                # If it's already a string, proceed with encoding it to UTF-8
                pass
            else:
                raise TypeError("Unexpected data type for google_result")
                
            safe_message = google_result.encode("utf-8", "ignore")
            return str(safe_message)
      
```

Please sign in to comment.