mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-24 23:58:15 +00:00
Fix encoding issue when loading i18n json file (#1341)
Co-authored-by: João Moura <joaomdmoura@gmail.com>
This commit is contained in:
@@ -17,13 +17,13 @@ class I18N(BaseModel):
|
|||||||
"""Load prompts from a JSON file."""
|
"""Load prompts from a JSON file."""
|
||||||
try:
|
try:
|
||||||
if self.prompt_file:
|
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)
|
self._prompts = json.load(f)
|
||||||
else:
|
else:
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
prompts_path = os.path.join(dir_path, "../translations/en.json")
|
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)
|
self._prompts = json.load(f)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise Exception(f"Prompt file '{self.prompt_file}' not found.")
|
raise Exception(f"Prompt file '{self.prompt_file}' not found.")
|
||||||
|
|||||||
Reference in New Issue
Block a user