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.
Fix orjson encoding text with UTF-8 surrogates (#3666)
ido777c821b294c619
diff --git a/autogpt/memory/vector/memory_item.py b/autogpt/memory/vector/memory_item.pyindex 587a915b44..f7a7fe6e88 100644--- a/autogpt/memory/vector/memory_item.py+++ b/autogpt/memory/vector/memory_item.py@@ -4,6 +4,7 @@ import dataclassesimport jsonfrom typing import Literal+import ftfyimport numpy as npfrom autogpt.config import Config@@ -43,6 +44,9 @@ class MemoryItem:):logger.debug(f"Memorizing text:\n{'-'*32}\n{text}\n{'-'*32}\n")+ # Fix encoding, e.g. removing unicode surrogates (see issue #778)+ text = ftfy.fix_text(text)+chunks = [chunkfor chunk, _ in (diff --git a/requirements.txt b/requirements.txtindex 47aa08a696..4af8bccd91 100644--- a/requirements.txt+++ b/requirements.txt@@ -19,6 +19,7 @@ google-api-python-client #(https://developers.google.com/custom-search/v1/overvipinecone-client==2.2.1redisorjson==3.8.10+ftfy>=6.1.1Pillowselenium==4.1.4webdriver-manager