mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-24 17:06:53 +01:00
Superboogav2 Quick Fixes (#5089)
This commit is contained in:
parent
2734ce3e4c
commit
485b85ee76
@ -1,14 +1,14 @@
|
|||||||
"""
|
"""
|
||||||
This module is responsible for modifying the chat prompt and history.
|
This module is responsible for modifying the chat prompt and history.
|
||||||
"""
|
"""
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import extensions.superboogav2.parameters as parameters
|
import extensions.superboogav2.parameters as parameters
|
||||||
|
|
||||||
from modules import chat
|
from modules import chat, shared
|
||||||
from modules.text_generation import get_encoded_length
|
from modules.text_generation import get_encoded_length
|
||||||
from modules.logging_colors import logger
|
from modules.logging_colors import logger
|
||||||
|
from modules.chat import load_character_memoized
|
||||||
from extensions.superboogav2.utils import create_context_text, create_metadata_source
|
from extensions.superboogav2.utils import create_context_text, create_metadata_source
|
||||||
|
|
||||||
from .data_processor import process_and_add_to_collector
|
from .data_processor import process_and_add_to_collector
|
||||||
@ -17,14 +17,6 @@ from .chromadb import ChromaCollector
|
|||||||
|
|
||||||
CHAT_METADATA = create_metadata_source('automatic-chat-insert')
|
CHAT_METADATA = create_metadata_source('automatic-chat-insert')
|
||||||
|
|
||||||
INSTRUCT_MODE = 'instruct'
|
|
||||||
CHAT_INSTRUCT_MODE = 'chat-instruct'
|
|
||||||
|
|
||||||
|
|
||||||
def _is_instruct_mode(state: dict):
|
|
||||||
mode = state.get('mode')
|
|
||||||
return mode == INSTRUCT_MODE or mode == CHAT_INSTRUCT_MODE
|
|
||||||
|
|
||||||
|
|
||||||
def _remove_tag_if_necessary(user_input: str):
|
def _remove_tag_if_necessary(user_input: str):
|
||||||
if not parameters.get_is_manual():
|
if not parameters.get_is_manual():
|
||||||
@ -51,17 +43,11 @@ def _format_single_exchange(name, text):
|
|||||||
|
|
||||||
|
|
||||||
def _get_names(state: dict):
|
def _get_names(state: dict):
|
||||||
if _is_instruct_mode(state):
|
default_char = shared.settings.get('character', "Assistant")
|
||||||
user_name = state['name1_instruct']
|
default_user = shared.settings.get('name1', "You")
|
||||||
bot_name = state['name2_instruct']
|
character = state.get('character', default_char)
|
||||||
else:
|
user_name = state.get('name1', default_user)
|
||||||
user_name = state['name1']
|
user_name, bot_name, _, _, _ = load_character_memoized(character, user_name, '')
|
||||||
bot_name = state['name2']
|
|
||||||
|
|
||||||
if not user_name:
|
|
||||||
user_name = 'User'
|
|
||||||
if not bot_name:
|
|
||||||
bot_name = 'Assistant'
|
|
||||||
|
|
||||||
return user_name, bot_name
|
return user_name, bot_name
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ def _remove_special_tokens(string):
|
|||||||
return re.sub(pattern, '', string)
|
return re.sub(pattern, '', string)
|
||||||
|
|
||||||
|
|
||||||
def input_modifier_internal(string, collector):
|
def input_modifier_internal(string, collector, is_chat):
|
||||||
# Sanity check.
|
# Sanity check.
|
||||||
if shared.is_chat():
|
if is_chat:
|
||||||
return string
|
return string
|
||||||
|
|
||||||
# Find the user input
|
# Find the user input
|
||||||
|
@ -167,8 +167,8 @@ def custom_generate_chat_prompt(user_input, state, **kwargs):
|
|||||||
return custom_generate_chat_prompt_internal(user_input, state, collector, **kwargs)
|
return custom_generate_chat_prompt_internal(user_input, state, collector, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def input_modifier(string):
|
def input_modifier(string, state, is_chat=False):
|
||||||
return input_modifier_internal(string, collector)
|
return input_modifier_internal(string, collector, is_chat)
|
||||||
|
|
||||||
|
|
||||||
def ui():
|
def ui():
|
||||||
|
Loading…
Reference in New Issue
Block a user