mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
Allow for permanent hijacking
This commit is contained in:
parent
111b5d42e7
commit
67623a52b7
@ -9,15 +9,16 @@ from modules.bot_picture import caption_image
|
|||||||
params = {
|
params = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# If 'state' is True, will hijack the next chatbot wrapper call
|
# If 'state' is 'temporary' or 'permanent', will hijack the next
|
||||||
# with a custom input text
|
# chatbot wrapper call with a custom input text and optionally
|
||||||
|
# custom output text
|
||||||
input_hijack = {
|
input_hijack = {
|
||||||
'state': False,
|
'state': 'off',
|
||||||
'value': ["", ""]
|
'value': []
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_hijack = {
|
prompt_hijack = {
|
||||||
'state': False,
|
'state': 'off',
|
||||||
'value': ""
|
'value': ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +91,9 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
|
|||||||
visible_text = None
|
visible_text = None
|
||||||
prompt = None
|
prompt = None
|
||||||
for extension, _ in extensions_module.iterator():
|
for extension, _ in extensions_module.iterator():
|
||||||
if hasattr(extension, 'input_hijack') and extension.input_hijack['state'] == True:
|
if hasattr(extension, 'input_hijack') and extension.input_hijack['state'] in ['temporary', 'permanent']:
|
||||||
extension.input_hijack['state'] = False
|
if extension.input_hijack['state'] == 'temporary':
|
||||||
|
extension.input_hijack['state'] = 'off'
|
||||||
values = extension.input_hijack['value']
|
values = extension.input_hijack['value']
|
||||||
if len(values) == 2:
|
if len(values) == 2:
|
||||||
text, visible_text = values
|
text, visible_text = values
|
||||||
@ -102,7 +103,9 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
|
|||||||
shared.history['internal'].append([text, reply])
|
shared.history['internal'].append([text, reply])
|
||||||
shared.history['visible'].append([visible_text, visible_reply])
|
shared.history['visible'].append([visible_text, visible_reply])
|
||||||
return shared.history['visible']
|
return shared.history['visible']
|
||||||
if hasattr(extension, 'prompt_hijack') and extension.prompt_hijack['state'] == True:
|
if hasattr(extension, 'prompt_hijack') and extension.prompt_hijack['state'] in ['temporary', 'permanent']:
|
||||||
|
if extension.prompt_hijack['state'] == 'temporary':
|
||||||
|
extension.prompt_hijack['state'] = 'off'
|
||||||
prompt = extension.prompt_hijack['value']
|
prompt = extension.prompt_hijack['value']
|
||||||
|
|
||||||
just_started = True
|
just_started = True
|
||||||
|
Loading…
Reference in New Issue
Block a user