Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Update python_interpreter.py (#8501)

yechao_wucfc54bd53aab
diff --git a/dspy/primitives/base_module.py b/dspy/primitives/base_module.py
index 54bb024ee..5b309b124 100644
--- a/dspy/primitives/base_module.py
+++ b/dspy/primitives/base_module.py
@@ -248,7 +248,7 @@ class BaseModule:
path = Path(path)
if path.suffix == ".json":
- with open(path) as f:
+ with open(path, encoding="utf-8") as f:
state = ujson.loads(f.read())
elif path.suffix == ".pkl":
with open(path, "rb") as f:
diff --git a/dspy/primitives/python_interpreter.py b/dspy/primitives/python_interpreter.py
index c3ba85e71..dccecb30b 100644
--- a/dspy/primitives/python_interpreter.py
+++ b/dspy/primitives/python_interpreter.py
@@ -127,6 +127,7 @@ class PythonInterpreter:
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
+ encoding="UTF-8",
env=os.environ.copy()
)
except FileNotFoundError as e: