Update prompt.py

Use UTF-8 encoding on reading prompts from files to allow Unicode characters to load correctly. 
The following examples currently will not load correctly from a file:

Hello, 世界!
😭🤮 💔
This commit is contained in:
skunkworxdark 2023-11-29 09:14:36 +00:00 committed by psychedelicious
parent b0fe57ec80
commit 2a087bf161

View File

@ -82,7 +82,7 @@ class PromptsFromFileInvocation(BaseInvocation):
end_line = start_line + max_prompts end_line = start_line + max_prompts
if max_prompts <= 0: if max_prompts <= 0:
end_line = np.iinfo(np.int32).max end_line = np.iinfo(np.int32).max
with open(file_path) as f: with open(file_path, encoding="utf-8") as f:
for i, line in enumerate(f): for i, line in enumerate(f):
if i >= start_line and i < end_line: if i >= start_line and i < end_line:
prompts.append((pre_prompt or "") + line.strip() + (post_prompt or "")) prompts.append((pre_prompt or "") + line.strip() + (post_prompt or ""))