Allow uploading chat history in official pygmalion web ui format
This commit is contained in:
parent
8325e23923
commit
ce4756fb88
1 changed files with 10 additions and 1 deletions
11
server.py
11
server.py
|
@ -392,7 +392,16 @@ if args.chat or args.cai_chat:
|
||||||
global history
|
global history
|
||||||
file = file.decode('utf-8')
|
file = file.decode('utf-8')
|
||||||
try:
|
try:
|
||||||
history = json.loads(file)['data']
|
j = json.loads(file)
|
||||||
|
if 'data' in j:
|
||||||
|
history = j['data']
|
||||||
|
# Compatibility with Pygmalion AI's official web UI
|
||||||
|
elif 'chat' in j:
|
||||||
|
history = [':'.join(x.split(':')[1:]).strip() for x in j['chat']]
|
||||||
|
if len(j['chat']) > 0 and j['chat'][0].startswith(f'{name2}:'):
|
||||||
|
history = [['<|BEGIN-VISIBLE-CHAT|>', history[0]]] + [[history[i], history[i+1]] for i in range(1, len(history)-1, 2)]
|
||||||
|
else:
|
||||||
|
history = [[history[i], history[i+1]] for i in range(0, len(history)-1, 2)]
|
||||||
except:
|
except:
|
||||||
history = tokenize_dialogue(file, name1, name2)
|
history = tokenize_dialogue(file, name1, name2)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue