Skip to content

Commit e62deca

Browse files
committed
change some open fn encoding to utf-8
1 parent 588b22e commit e62deca

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

crazy_functions/Latex_Function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def PDF翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, h
559559
project_folder = move_project(project_folder)
560560

561561
# <-------------- set a hash tag for repeat-checking ------------->
562-
with open(pj(project_folder, hash_tag + '.tag'), 'w') as f:
562+
with open(pj(project_folder, hash_tag + '.tag'), 'w', encoding='utf8') as f:
563563
f.write(hash_tag)
564564
f.close()
565565

request_llms/bridge_llama2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def load_model_and_tokenizer(self):
2626
import platform
2727
huggingface_token, device = get_conf('HUGGINGFACE_ACCESS_TOKEN', 'LOCAL_MODEL_DEVICE')
2828
assert len(huggingface_token) != 0, "没有填写 HUGGINGFACE_ACCESS_TOKEN"
29-
with open(os.path.expanduser('~/.cache/huggingface/token'), 'w') as f:
29+
with open(os.path.expanduser('~/.cache/huggingface/token'), 'w', encoding='utf8') as f:
3030
f.write(huggingface_token)
3131
model_id = 'meta-llama/Llama-2-7b-chat-hf'
3232
with ProxyNetworkActivate('Download_LLM'):

request_llms/bridge_moonshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __converter_file(self, user_input: str):
3131
files.append(f)
3232
for file in files:
3333
if file.split('.')[-1] in ['pdf']:
34-
with open(file, 'r') as fp:
34+
with open(file, 'r', encoding='utf8') as fp:
3535
from crazy_functions.crazy_utils import read_and_clean_pdf_text
3636
file_content, _ = read_and_clean_pdf_text(fp)
3737
what_ask.append({"role": "system", "content": file_content})

themes/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def minimize_js(common_js_path):
2929
os.remove(old_min_js)
3030
# use rjsmin to minimize `common_js_path`
3131
c_jsmin = rjsmin.jsmin
32-
with open(common_js_path, "r") as f:
32+
with open(common_js_path, "r", encoding='utf-8') as f:
3333
js_content = f.read()
3434
if common_js_path == "themes/common.js":
3535
js_content = inject_mutex_button_code(js_content)
@@ -38,7 +38,7 @@ def minimize_js(common_js_path):
3838
sha_hash = hashlib.sha256(minimized_js_content.encode()).hexdigest()[:8]
3939
minimized_js_path = common_js_path + '.min.' + sha_hash + '.js'
4040
# save to minimized js file
41-
with open(minimized_js_path, "w") as f:
41+
with open(minimized_js_path, "w", encoding='utf-8') as f:
4242
f.write(minimized_js_content)
4343
# return minimized js file path
4444
return minimized_js_path

0 commit comments

Comments
 (0)