Fix an error

Fixes "UnboundLocalError: local variable 'substring_found' referenced before assignment" when loading non-pygmalion models in cai chat mode.
This commit is contained in:
Silver267 2023-01-31 01:34:10 -05:00 committed by GitHub
parent 5b0bbfa6e8
commit a85bb5e9a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -373,6 +373,8 @@ if args.chat or args.cai_chat:
else: else:
reply = reply[idx + 1 + len(f"{current}:"):] reply = reply[idx + 1 + len(f"{current}:"):]
substring_found = False
if check: if check:
reply = reply.split('\n')[0].strip() reply = reply.split('\n')[0].strip()
else: else:
@ -385,7 +387,6 @@ if args.chat or args.cai_chat:
# Detect if something like "\nYo" is generated just before # Detect if something like "\nYo" is generated just before
# "\nYou:" is completed # "\nYou:" is completed
tmp = f"\n{other}:" tmp = f"\n{other}:"
substring_found = False
for j in range(1, len(tmp)): for j in range(1, len(tmp)):
if reply[-j:] == tmp[:j]: if reply[-j:] == tmp[:j]:
substring_found = True substring_found = True