@@ -97,7 +97,7 @@ def extract_message_from_reply(question, reply, name1, name2, check, impersonate
97
97
def stop_everything_event ():
98
98
shared .stop_everything = True
99
99
100
- def chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 , regenerate = False ):
100
+ def chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 , regenerate = False ):
101
101
shared .stop_everything = False
102
102
just_started = True
103
103
eos_token = '\n ' if check else None
@@ -133,7 +133,7 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
133
133
# Generate
134
134
reply = ''
135
135
for i in range (chat_generation_attempts ):
136
- for reply in generate_reply (f"{ prompt } { ' ' if len (reply ) > 0 else '' } { reply } " , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , eos_token = eos_token , stopping_string = f"\n { name1 } :" ):
136
+ for reply in generate_reply (f"{ prompt } { ' ' if len (reply ) > 0 else '' } { reply } " , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , eos_token = eos_token , stopping_string = f"\n { name1 } :" ):
137
137
138
138
# Extracting the reply
139
139
reply , next_character_found = extract_message_from_reply (prompt , reply , name1 , name2 , check )
@@ -160,7 +160,7 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
160
160
161
161
yield shared .history ['visible' ]
162
162
163
- def impersonate_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
163
+ def impersonate_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
164
164
eos_token = '\n ' if check else None
165
165
166
166
if 'pygmalion' in shared .model_name .lower ():
@@ -172,26 +172,26 @@ def impersonate_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typ
172
172
# Yield *Is typing...*
173
173
yield shared .processing_message
174
174
for i in range (chat_generation_attempts ):
175
- for reply in generate_reply (prompt + reply , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , eos_token = eos_token , stopping_string = f"\n { name2 } :" ):
175
+ for reply in generate_reply (prompt + reply , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , eos_token = eos_token , stopping_string = f"\n { name2 } :" ):
176
176
reply , next_character_found = extract_message_from_reply (prompt , reply , name1 , name2 , check , impersonate = True )
177
177
yield reply
178
178
if next_character_found :
179
179
break
180
180
yield reply
181
181
182
- def cai_chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
183
- for _history in chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts ):
182
+ def cai_chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
183
+ for _history in chatbot_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts ):
184
184
yield generate_chat_html (_history , name1 , name2 , shared .character )
185
185
186
- def regenerate_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
186
+ def regenerate_wrapper (text , max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts = 1 ):
187
187
if (shared .character != 'None' and len (shared .history ['visible' ]) == 1 ) or len (shared .history ['internal' ]) == 0 :
188
188
yield generate_chat_output (shared .history ['visible' ], name1 , name2 , shared .character )
189
189
else :
190
190
last_visible = shared .history ['visible' ].pop ()
191
191
last_internal = shared .history ['internal' ].pop ()
192
192
# Yield '*Is typing...*'
193
193
yield generate_chat_output (shared .history ['visible' ]+ [[last_visible [0 ], shared .processing_message ]], name1 , name2 , shared .character )
194
- for _history in chatbot_wrapper (last_internal [0 ], max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts , regenerate = True ):
194
+ for _history in chatbot_wrapper (last_internal [0 ], max_new_tokens , do_sample , temperature , top_p , typical_p , repetition_penalty , encoder_repetition_penalty , top_k , min_length , no_repeat_ngram_size , num_beams , penalty_alpha , length_penalty , early_stopping , name1 , name2 , context , check , chat_prompt_size , chat_generation_attempts , regenerate = True ):
195
195
if shared .args .cai_chat :
196
196
shared .history ['visible' ][- 1 ] = [last_visible [0 ], _history [- 1 ][1 ]]
197
197
else :
0 commit comments