Allow passing your name to the chat API

This commit is contained in:
oobabooga 2023-05-23 18:41:58 -03:00
parent fb6a00f4e5
commit 74aae34beb
3 changed files with 3 additions and 1 deletions

View File

@ -23,6 +23,7 @@ async def run(user_input, history):
'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct'
'character': 'Example', 'character': 'Example',
'instruction_template': 'Vicuna-v1.1', 'instruction_template': 'Vicuna-v1.1',
'your_name': 'You',
'regenerate': False, 'regenerate': False,
'_continue': False, '_continue': False,

View File

@ -17,6 +17,7 @@ def run(user_input, history):
'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct'
'character': 'Example', 'character': 'Example',
'instruction_template': 'Vicuna-v1.1', 'instruction_template': 'Vicuna-v1.1',
'your_name': 'You',
'regenerate': False, 'regenerate': False,
'_continue': False, '_continue': False,

View File

@ -41,7 +41,7 @@ def build_parameters(body, chat=False):
if chat: if chat:
character = body.get('character') character = body.get('character')
instruction_template = body.get('instruction_template') instruction_template = body.get('instruction_template')
name1, name2, _, greeting, context, _ = load_character_memoized(character, shared.settings['name1'], shared.settings['name2'], instruct=False) name1, name2, _, greeting, context, _ = load_character_memoized(character, str(body.get('your_name', shared.setttings['name1'])), shared.settings['name2'], instruct=False)
name1_instruct, name2_instruct, _, _, context_instruct, turn_template = load_character_memoized(instruction_template, '', '', instruct=True) name1_instruct, name2_instruct, _, _, context_instruct, turn_template = load_character_memoized(instruction_template, '', '', instruct=True)
generate_params.update({ generate_params.update({
'stop_at_newline': bool(body.get('stop_at_newline', shared.settings['stop_at_newline'])), 'stop_at_newline': bool(body.get('stop_at_newline', shared.settings['stop_at_newline'])),