Load and save character files in UTF-8
This commit is contained in:
@@ -332,7 +332,7 @@ def load_character(_character, name1, name2):
|
|||||||
shared.history['visible'] = []
|
shared.history['visible'] = []
|
||||||
if _character != 'None':
|
if _character != 'None':
|
||||||
shared.character = _character
|
shared.character = _character
|
||||||
data = json.loads(open(Path(f'characters/{_character}.json'), 'r').read())
|
data = json.loads(open(Path(f'characters/{_character}.json'), 'r', encoding='utf-8').read())
|
||||||
name2 = data['char_name']
|
name2 = data['char_name']
|
||||||
if 'char_persona' in data and data['char_persona'] != '':
|
if 'char_persona' in data and data['char_persona'] != '':
|
||||||
context += f"{data['char_name']}'s Persona: {data['char_persona']}\n"
|
context += f"{data['char_name']}'s Persona: {data['char_persona']}\n"
|
||||||
@@ -372,7 +372,7 @@ def upload_character(json_file, img, tavern=False):
|
|||||||
i += 1
|
i += 1
|
||||||
if tavern:
|
if tavern:
|
||||||
outfile_name = f'TavernAI-{outfile_name}'
|
outfile_name = f'TavernAI-{outfile_name}'
|
||||||
with open(Path(f'characters/{outfile_name}.json'), 'w') as f:
|
with open(Path(f'characters/{outfile_name}.json'), 'w', encoding='utf-8') as f:
|
||||||
f.write(json_file)
|
f.write(json_file)
|
||||||
if img is not None:
|
if img is not None:
|
||||||
img = Image.open(io.BytesIO(img))
|
img = Image.open(io.BytesIO(img))
|
||||||
|
|||||||
Reference in New Issue
Block a user