Skip to content

Commit 41bd9a9

Browse files
committed
encoding fix
1 parent e20547c commit 41bd9a9

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

openevolve/controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _setup_logging(self) -> None:
221221

222222
def _load_initial_program(self) -> str:
223223
"""Load the initial program from file"""
224-
with open(self.initial_program_path, "r") as f:
224+
with open(self.initial_program_path, "r",encoding='utf-8') as f:
225225
return f.read()
226226

227227
async def run(
@@ -291,7 +291,7 @@ async def run(
291291
if numeric_metrics:
292292
avg_score = sum(numeric_metrics) / len(numeric_metrics)
293293
logger.warning(
294-
f"⚠️ No 'combined_score' metric found in evaluation results. "
294+
f"No 'combined_score' metric found in evaluation results. "
295295
f"Using average of all numeric metrics ({avg_score:.4f}) for evolution guidance. "
296296
f"For better evolution results, please modify your evaluator to return a 'combined_score' "
297297
f"metric that properly weights different aspects of program performance."

openevolve/llm/openai.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ async def generate_with_context(
133133
if reasoning_effort is not None:
134134
params["reasoning_effort"] = reasoning_effort
135135

136+
# ModelScope Qwen models require enable_thinking=false for non-streaming requests
137+
if (
138+
isinstance(self.api_base, str)
139+
and "api-inference.modelscope.cn" in self.api_base
140+
):
141+
extra_body = kwargs.get("extra_body") or {}
142+
extra_body.setdefault("enable_thinking", False)
143+
params["extra_body"] = extra_body
144+
136145
# Add seed parameter for reproducibility if configured
137146
# Skip seed parameter for Google AI Studio endpoint as it doesn't support it
138147
seed = kwargs.get("seed", self.random_seed)

openevolve/prompt/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _load_from_directory(self, directory: Path) -> None:
202202
# Load fragments.json if exists
203203
fragments_file = directory / "fragments.json"
204204
if fragments_file.exists():
205-
with open(fragments_file, "r") as f:
205+
with open(fragments_file, "r",encoding='utf-8') as f:
206206
loaded_fragments = json.load(f)
207207
self.fragments.update(loaded_fragments)
208208

0 commit comments

Comments
 (0)