File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -1066,14 +1066,15 @@ def _create_completion(
1066
1066
while len (remaining_tokens ) > 0 :
1067
1067
decode_success = False
1068
1068
for i in range (1 , len (remaining_tokens ) + 1 ):
1069
- tokens = remaining_tokens [:i ]
1070
1069
try :
1071
- bs = self .detokenize (tokens )
1072
- text = bs .decode ('utf-8' )
1070
+ bs = self .detokenize (remaining_tokens [: i ] )
1071
+ ts = bs .decode ('utf-8' )
1073
1072
decode_success = True
1074
1073
break
1075
1074
except UnicodeError :
1076
1075
pass
1076
+ else :
1077
+ break
1077
1078
if not decode_success :
1078
1079
# all remaining tokens cannot be decoded to a UTF-8 character
1079
1080
break
@@ -1090,7 +1091,7 @@ def _create_completion(
1090
1091
"model" : model_name ,
1091
1092
"choices" : [
1092
1093
{
1093
- "text" : text ,
1094
+ "text" : ts ,
1094
1095
"index" : 0 ,
1095
1096
"logprobs" : None ,
1096
1097
"finish_reason" : None ,
You can’t perform that action at this time.
0 commit comments