Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2b5fe9

Browse files
authored
Fixes utf-8 formatting issues in optimization saves (stanfordnlp#8272)
1 parent9b2e1c6 commite2b5fe9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎dspy/primitives/module.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ def save(self, path, save_program=False, modules_to_serialize=None):
218218
f"Saving failed with error:{e}. Please remove the non-picklable attributes from your DSPy program, "
219219
"or consider using state-only saving by setting `save_program=False`."
220220
)
221-
withopen(path/"metadata.json","w")asf:
222-
ujson.dump(metadata,f,indent=2)
221+
withopen(path/"metadata.json","w",encoding="utf-8")asf:
222+
ujson.dump(metadata,f,indent=2,ensure_ascii=False)
223223

224224
return
225225

226226
state=self.dump_state()
227227
state["metadata"]=metadata
228228
ifpath.suffix==".json":
229229
try:
230-
withopen(path,"w")asf:
231-
f.write(ujson.dumps(state,indent=2))
230+
withopen(path,"w",encoding="utf-8")asf:
231+
f.write(ujson.dumps(state,indent=2 ,ensure_ascii=False))
232232
exceptExceptionase:
233233
raiseRuntimeError(
234234
f"Failed to save state to{path} with error:{e}. Your DSPy program may contain non "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp