Procházet zdrojové kódy

Fix an error

Fixes "UnboundLocalError: local variable 'substring_found' referenced before assignment" when loading non-pygmalion models in cai chat mode.
Silver267 před 3 roky
rodič
revize
a85bb5e9a2
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      server.py

+ 2 - 1
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