From a85bb5e9a2c1b32233f50e9a7b4411bf554fa397 Mon Sep 17 00:00:00 2001 From: Silver267 <105079286+Silver267@users.noreply.github.com> Date: Tue, 31 Jan 2023 01:34:10 -0500 Subject: [PATCH 1/2] Fix an error Fixes "UnboundLocalError: local variable 'substring_found' referenced before assignment" when loading non-pygmalion models in cai chat mode. --- server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 29439fb9..02ef8ebe 100644 --- a/server.py +++ b/server.py @@ -373,6 +373,8 @@ if args.chat or args.cai_chat: else: reply = reply[idx + 1 + len(f"{current}:"):] + substring_found = False + if check: reply = reply.split('\n')[0].strip() else: @@ -385,7 +387,6 @@ if args.chat or args.cai_chat: # Detect if something like "\nYo" is generated just before # "\nYou:" is completed tmp = f"\n{other}:" - substring_found = False for j in range(1, len(tmp)): if reply[-j:] == tmp[:j]: substring_found = True From 001ecf95b263c6a78face532d297334d73663600 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 31 Jan 2023 08:14:16 -0300 Subject: [PATCH 2/2] Update server.py --- server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 02ef8ebe..37e45cc6 100644 --- a/server.py +++ b/server.py @@ -364,6 +364,8 @@ if args.chat or args.cai_chat: def extract_message_from_reply(question, reply, current, other, check, extensions=False): next_character_found = False + substring_found = False + previous_idx = [m.start() for m in re.finditer(f"(^|\n){current}:", question)] idx = [m.start() for m in re.finditer(f"(^|\n){current}:", reply)] idx = idx[len(previous_idx)-1] @@ -372,8 +374,6 @@ if args.chat or args.cai_chat: reply = reply[idx + 1 + len(apply_extensions(f"{current}:", "bot_prefix")):] else: reply = reply[idx + 1 + len(f"{current}:"):] - - substring_found = False if check: reply = reply.split('\n')[0].strip()