Skip to content

Commit

Permalink
change some open fn encoding to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Nov 19, 2024
1 parent 588b22e commit e62deca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crazy_functions/Latex_Function.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def PDF翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, h
project_folder = move_project(project_folder)

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

Expand Down
2 changes: 1 addition & 1 deletion request_llms/bridge_llama2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def load_model_and_tokenizer(self):
import platform
huggingface_token, device = get_conf('HUGGINGFACE_ACCESS_TOKEN', 'LOCAL_MODEL_DEVICE')
assert len(huggingface_token) != 0, "没有填写 HUGGINGFACE_ACCESS_TOKEN"
with open(os.path.expanduser('~/.cache/huggingface/token'), 'w') as f:
with open(os.path.expanduser('~/.cache/huggingface/token'), 'w', encoding='utf8') as f:
f.write(huggingface_token)
model_id = 'meta-llama/Llama-2-7b-chat-hf'
with ProxyNetworkActivate('Download_LLM'):
Expand Down
2 changes: 1 addition & 1 deletion request_llms/bridge_moonshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __converter_file(self, user_input: str):
files.append(f)
for file in files:
if file.split('.')[-1] in ['pdf']:
with open(file, 'r') as fp:
with open(file, 'r', encoding='utf8') as fp:
from crazy_functions.crazy_utils import read_and_clean_pdf_text
file_content, _ = read_and_clean_pdf_text(fp)
what_ask.append({"role": "system", "content": file_content})
Expand Down
4 changes: 2 additions & 2 deletions themes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def minimize_js(common_js_path):
os.remove(old_min_js)
# use rjsmin to minimize `common_js_path`
c_jsmin = rjsmin.jsmin
with open(common_js_path, "r") as f:
with open(common_js_path, "r", encoding='utf-8') as f:
js_content = f.read()
if common_js_path == "themes/common.js":
js_content = inject_mutex_button_code(js_content)
Expand All @@ -38,7 +38,7 @@ def minimize_js(common_js_path):
sha_hash = hashlib.sha256(minimized_js_content.encode()).hexdigest()[:8]
minimized_js_path = common_js_path + '.min.' + sha_hash + '.js'
# save to minimized js file
with open(minimized_js_path, "w") as f:
with open(minimized_js_path, "w", encoding='utf-8') as f:
f.write(minimized_js_content)
# return minimized js file path
return minimized_js_path
Expand Down

0 comments on commit e62deca

Please sign in to comment.