mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge pull request #279 from ebolam/UI2
Chat mode stopper fix, Class Split Adjustments
This commit is contained in:
29
aiserver.py
29
aiserver.py
@@ -2505,18 +2505,7 @@ def patch_transformers():
|
||||
if 'completed' not in self.__dict__:
|
||||
self.completed = [False]*len(input_ids)
|
||||
for i in range(len(input_ids)):
|
||||
if input_ids[i][-2] == null_character:
|
||||
input_ids[i][-1] = null_character
|
||||
elif data[i][-1*(len(koboldai_vars.chatname)+1):] == koboldai_vars.chatname + ":":
|
||||
#We now have the user name in chat mode with a :. We want to remove that from the data
|
||||
#We do need to check if the first token includes more than the chatname (Ie " You") so we don't loose the extra data
|
||||
chatname_tokens = len(tokenizer.encode(koboldai_vars.chatname+":"))
|
||||
if input_ids[i][-1*chatname_tokens] != koboldai_vars.chatname[0]:
|
||||
input_ids[i][-1*chatname_tokens] = tokenizer.encode(tokenizer.decode(input_ids[i][-1*chatname_tokens]))[0]
|
||||
else:
|
||||
input_ids[i][-1*chatname_tokens] = null_character
|
||||
for j in range(len(koboldai_vars.chatname)+1):
|
||||
input_ids[i][-j] = tokenizer.encode(chr(0))[0]
|
||||
if data[i][-1*(len(koboldai_vars.chatname)+1):] == koboldai_vars.chatname + ":":
|
||||
self.completed[i] = True
|
||||
if all(self.completed):
|
||||
koboldai_vars.generated_tkns = koboldai_vars.genamt
|
||||
@@ -2872,7 +2861,7 @@ def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=Fal
|
||||
else:
|
||||
tokenizer_id = {
|
||||
"Colab": "EleutherAI/gpt-neo-2.7B",
|
||||
"CLUSTER": koboldai_vars.cluster_requested_models[0],
|
||||
"CLUSTER": koboldai_vars.cluster_requested_models[0] if len(koboldai_vars.cluster_requested_models) > 0 else "gpt2",
|
||||
"OAI": "gpt2",
|
||||
}[koboldai_vars.model]
|
||||
|
||||
@@ -8679,6 +8668,8 @@ def UI_2_Pinning(data):
|
||||
@socketio.on('back')
|
||||
@logger.catch
|
||||
def UI_2_back(data):
|
||||
if koboldai_vars.aibusy:
|
||||
return
|
||||
if koboldai_vars.debug:
|
||||
print("back")
|
||||
koboldai_vars.actions.clear_unused_options()
|
||||
@@ -8690,6 +8681,8 @@ def UI_2_back(data):
|
||||
@socketio.on('redo')
|
||||
@logger.catch
|
||||
def UI_2_redo(data):
|
||||
if koboldai_vars.aibusy:
|
||||
return
|
||||
if len(koboldai_vars.actions.get_current_options()) == 1:
|
||||
koboldai_vars.actions.use_option(0)
|
||||
|
||||
@@ -8700,7 +8693,8 @@ def UI_2_redo(data):
|
||||
@socketio.on('retry')
|
||||
@logger.catch
|
||||
def UI_2_retry(data):
|
||||
|
||||
if koboldai_vars.aibusy:
|
||||
return
|
||||
if len(koboldai_vars.actions.get_current_options_no_edits()) == 0:
|
||||
ignore = koboldai_vars.actions.pop(keep=True)
|
||||
koboldai_vars.actions.clear_unused_options()
|
||||
@@ -9943,7 +9937,12 @@ def text2img_api(prompt, art_guide="") -> Image.Image:
|
||||
logger.debug(final_imgen_params)
|
||||
|
||||
try:
|
||||
submit_req = requests.post(url=apiaddress, data=payload_json)
|
||||
logger.info("Gen Image API: Username: {}".format(koboldai_vars.img_gen_api_username))
|
||||
if koboldai_vars.img_gen_api_username != "":
|
||||
basic = requests.auth.HTTPBasicAuth(koboldai_vars.img_gen_api_username, koboldai_vars.img_gen_api_password)
|
||||
submit_req = requests.post(url=apiaddress, data=payload_json, auth=basic)
|
||||
else:
|
||||
submit_req = requests.post(url=apiaddress, data=payload_json)
|
||||
except requests.exceptions.ConnectionError:
|
||||
show_error_notification(
|
||||
"SD Web API Failure",
|
||||
|
Reference in New Issue
Block a user