From 74aae34beb17e9d082483d9df5818176275c21eb Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 23 May 2023 18:41:58 -0300 Subject: [PATCH] Allow passing your name to the chat API --- api-example-chat-stream.py | 1 + api-example-chat.py | 1 + extensions/api/util.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api-example-chat-stream.py b/api-example-chat-stream.py index 3ed7f241..337e3136 100644 --- a/api-example-chat-stream.py +++ b/api-example-chat-stream.py @@ -23,6 +23,7 @@ async def run(user_input, history): 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'character': 'Example', 'instruction_template': 'Vicuna-v1.1', + 'your_name': 'You', 'regenerate': False, '_continue': False, diff --git a/api-example-chat.py b/api-example-chat.py index 6d8208bb..97f552e2 100644 --- a/api-example-chat.py +++ b/api-example-chat.py @@ -17,6 +17,7 @@ def run(user_input, history): 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'character': 'Example', 'instruction_template': 'Vicuna-v1.1', + 'your_name': 'You', 'regenerate': False, '_continue': False, diff --git a/extensions/api/util.py b/extensions/api/util.py index 596caee2..3dc317ec 100644 --- a/extensions/api/util.py +++ b/extensions/api/util.py @@ -41,7 +41,7 @@ def build_parameters(body, chat=False): if chat: character = body.get('character') 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) generate_params.update({ 'stop_at_newline': bool(body.get('stop_at_newline', shared.settings['stop_at_newline'])),