Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Fix encoding issue when loading i18n json file (#1341)

Mr. Guo699be4887cfe
diff --git a/src/crewai/utilities/i18n.py b/src/crewai/utilities/i18n.py
index b283f57c0..e325834f3 100644
--- a/src/crewai/utilities/i18n.py
+++ b/src/crewai/utilities/i18n.py
@@ -17,13 +17,13 @@ class I18N(BaseModel):
"""Load prompts from a JSON file."""
try:
if self.prompt_file:
- with open(self.prompt_file, "r") as f:
+ with open(self.prompt_file, "r", encoding="utf-8") as f:
self._prompts = json.load(f)
else:
dir_path = os.path.dirname(os.path.realpath(__file__))
prompts_path = os.path.join(dir_path, "../translations/en.json")
- with open(prompts_path, "r") as f:
+ with open(prompts_path, "r", encoding="utf-8") as f:
self._prompts = json.load(f)
except FileNotFoundError:
raise Exception(f"Prompt file '{self.prompt_file}' not found.")