diff --git a/api-examples/api-example-chat-stream.py b/api-examples/api-example-chat-stream.py index 493661c2..2914d451 100644 --- a/api-examples/api-example-chat-stream.py +++ b/api-examples/api-example-chat-stream.py @@ -25,9 +25,15 @@ async def run(user_input, history): 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'character': 'Example', 'instruction_template': 'Vicuna-v1.1', # Will get autodetected if unset - # 'context_instruct': '', # Optional 'your_name': 'You', - + # 'name1': 'name of user', # Optional + # 'name2': 'name of character', # Optional + # 'context': 'character context', # Optional + # 'greeting': 'greeting', # Optional + # 'name1_instruct': 'You', # Optional + # 'name2_instruct': 'Assistant', # Optional + # 'context_instruct': 'context_instruct', # Optional + # 'turn_template': 'turn_template', # Optional 'regenerate': False, '_continue': False, 'stop_at_newline': False, diff --git a/api-examples/api-example-chat.py b/api-examples/api-example-chat.py index 31641815..e2797f1e 100644 --- a/api-examples/api-example-chat.py +++ b/api-examples/api-example-chat.py @@ -19,9 +19,15 @@ def run(user_input, history): 'mode': 'instruct', # Valid options: 'chat', 'chat-instruct', 'instruct' 'character': 'Example', 'instruction_template': 'Vicuna-v1.1', # Will get autodetected if unset - # 'context_instruct': '', # Optional 'your_name': 'You', - + # 'name1': 'name of user', # Optional + # 'name2': 'name of character', # Optional + # 'context': 'character context', # Optional + # 'greeting': 'greeting', # Optional + # 'name1_instruct': 'You', # Optional + # 'name2_instruct': 'Assistant', # Optional + # 'context_instruct': 'context_instruct', # Optional + # 'turn_template': 'turn_template', # Optional 'regenerate': False, '_continue': False, 'stop_at_newline': False, diff --git a/extensions/api/util.py b/extensions/api/util.py index 5cc259db..ef58a70f 100644 --- a/extensions/api/util.py +++ b/extensions/api/util.py @@ -69,14 +69,14 @@ def build_parameters(body, chat=False): 'stop_at_newline': bool(body.get('stop_at_newline', shared.settings['stop_at_newline'])), 'chat_generation_attempts': int(body.get('chat_generation_attempts', shared.settings['chat_generation_attempts'])), 'mode': str(body.get('mode', 'chat')), - 'name1': name1, - 'name2': name2, - 'context': context, - 'greeting': greeting, - 'name1_instruct': name1_instruct, - 'name2_instruct': name2_instruct, - 'context_instruct': body.get('context_instruct', context_instruct), - 'turn_template': turn_template, + 'name1': str(body.get('name1', name1)), + 'name2': str(body.get('name2', name2)), + 'context': str(body.get('context', context)), + 'greeting': str(body.get('greeting', greeting)), + 'name1_instruct': str(body.get('name1_instruct', name1_instruct)), + 'name2_instruct': str(body.get('name2_instruct', name2_instruct)), + 'context_instruct': str(body.get('context_instruct', context_instruct)), + 'turn_template': str(body.get('turn_template', turn_template)), 'chat-instruct_command': str(body.get('chat-instruct_command', shared.settings['chat-instruct_command'])), 'history': body.get('history', {'internal': [], 'visible': []}) })