akiko19191 commited on
Commit
682bdcf
·
verified ·
1 Parent(s): a7890d8

Update tests.py

Browse files
Files changed (1) hide show
  1. tests.py +7 -3
tests.py CHANGED
@@ -193,9 +193,13 @@ def create_code_files(filename: str, code) -> dict:
193
  global destination_dir
194
  transfer_files()
195
  transfer_files2()
196
- f = open(os.path.join(destination_dir, filename), "w")
197
- f.write(str(code))
198
- f.close()
 
 
 
 
199
  return {"info":"task completed. The referenced code files were created successfully. "}
200
 
201
  @mcp.tool()
 
193
  global destination_dir
194
  transfer_files()
195
  transfer_files2()
196
+ if isinstance(code, dict):
197
+ with open(os.path.join(destination_dir, filename), 'w', encoding='utf-8') as f:
198
+ json.dump(x, f, ensure_ascii=False, indent=4)
199
+ else:
200
+ f = open(os.path.join(destination_dir, filename), "w")
201
+ f.write(str(code))
202
+ f.close()
203
  return {"info":"task completed. The referenced code files were created successfully. "}
204
 
205
  @mcp.tool()