Spaces:
Runtime error
Runtime error
Commit
·
1265a5f
1
Parent(s):
ac63b1e
Update with h2oGPT hash 61aa7c5504e243b9d2100968375942e0f78ec8c2
Browse files- gradio_runner.py +44 -40
gradio_runner.py
CHANGED
|
@@ -21,6 +21,7 @@ def go_gradio(**kwargs):
|
|
| 21 |
admin_pass = kwargs['admin_pass']
|
| 22 |
model_state0 = kwargs['model_state0']
|
| 23 |
score_model_state0 = kwargs['score_model_state0']
|
|
|
|
| 24 |
|
| 25 |
# easy update of kwargs needed for evaluate() etc.
|
| 26 |
kwargs.update(locals())
|
|
@@ -485,9 +486,9 @@ def go_gradio(**kwargs):
|
|
| 485 |
outputs=[score_text_nochat],
|
| 486 |
)
|
| 487 |
if not kwargs['auto_score']:
|
| 488 |
-
score_event = score_btn.click(**score_args, queue=
|
| 489 |
-
.then(**score_args2, queue=
|
| 490 |
-
score_event_nochat = score_btn_nochat.click(**score_args_nochat, queue=
|
| 491 |
api_name='score_nochat' if allow_api else None)
|
| 492 |
|
| 493 |
def user(*args, undo=False, sanitize_user_prompt=True, model2=False):
|
|
@@ -636,65 +637,65 @@ def go_gradio(**kwargs):
|
|
| 636 |
if kwargs['auto_score']:
|
| 637 |
# in case 2nd model, consume instruction first, so can clear quickly
|
| 638 |
# bot doesn't consume instruction itself, just history from user, so why works
|
| 639 |
-
submit_event = instruction.submit(**user_args, queue=
|
| 640 |
api_name='instruction' if allow_api else None) \
|
| 641 |
-
.then(**user_args2,
|
| 642 |
.then(clear_instruct, None, instruction) \
|
| 643 |
.then(clear_instruct, None, iinput) \
|
| 644 |
-
.then(**bot_args, api_name='instruction_bot' if allow_api else None) \
|
| 645 |
-
.then(**score_args, api_name='instruction_bot_score' if allow_api else None) \
|
| 646 |
-
.then(**bot_args2, api_name='instruction_bot2' if allow_api else None) \
|
| 647 |
-
.then(**score_args2, api_name='instruction_bot_score2' if allow_api else None) \
|
| 648 |
.then(clear_torch_cache)
|
| 649 |
-
submit_event2 = submit.click(**user_args,
|
| 650 |
-
.then(**user_args2,
|
| 651 |
.then(clear_instruct, None, instruction) \
|
| 652 |
.then(clear_instruct, None, iinput) \
|
| 653 |
-
.then(**bot_args, api_name='submit_bot' if allow_api else None) \
|
| 654 |
-
.then(**score_args, api_name='submit_bot_score' if allow_api else None) \
|
| 655 |
-
.then(**bot_args2, api_name='submit_bot2' if allow_api else None) \
|
| 656 |
-
.then(**score_args2, api_name='submit_bot_score2' if allow_api else None) \
|
| 657 |
.then(clear_torch_cache)
|
| 658 |
-
submit_event3 = retry.click(**user_args,
|
| 659 |
-
.then(**user_args2,
|
| 660 |
.then(clear_instruct, None, instruction) \
|
| 661 |
.then(clear_instruct, None, iinput) \
|
| 662 |
-
.then(**retry_bot_args, api_name='retry_bot' if allow_api else None) \
|
| 663 |
-
.then(**score_args, api_name='retry_bot_score' if allow_api else None) \
|
| 664 |
-
.then(**retry_bot_args2, api_name='retry_bot2' if allow_api else None) \
|
| 665 |
-
.then(**score_args2, api_name='retry_bot_score2' if allow_api else None) \
|
| 666 |
.then(clear_torch_cache)
|
| 667 |
-
submit_event4 = undo.click(**undo_user_args,
|
| 668 |
-
.then(**undo_user_args2,
|
| 669 |
.then(clear_instruct, None, instruction) \
|
| 670 |
.then(clear_instruct, None, iinput) \
|
| 671 |
.then(**score_args, api_name='undo_score' if allow_api else None) \
|
| 672 |
.then(**score_args2, api_name='undo_score2' if allow_api else None)
|
| 673 |
else:
|
| 674 |
-
submit_event = instruction.submit(**user_args,
|
| 675 |
api_name='instruction' if allow_api else None) \
|
| 676 |
-
.then(**user_args2,
|
| 677 |
.then(clear_instruct, None, instruction) \
|
| 678 |
.then(clear_instruct, None, iinput) \
|
| 679 |
-
.then(**bot_args, api_name='instruction_bot' if allow_api else None) \
|
| 680 |
-
.then(**bot_args2, api_name='instruction_bot2' if allow_api else None) \
|
| 681 |
.then(clear_torch_cache)
|
| 682 |
-
submit_event2 = submit.click(**user_args,
|
| 683 |
-
.then(**user_args2,
|
| 684 |
.then(clear_instruct, None, instruction) \
|
| 685 |
.then(clear_instruct, None, iinput) \
|
| 686 |
-
.then(**bot_args, api_name='submit_bot' if allow_api else None) \
|
| 687 |
-
.then(**bot_args2, api_name='submit_bot2' if allow_api else None) \
|
| 688 |
.then(clear_torch_cache)
|
| 689 |
-
submit_event3 = retry.click(**user_args,
|
| 690 |
-
.then(**user_args2,
|
| 691 |
.then(clear_instruct, None, instruction) \
|
| 692 |
.then(clear_instruct, None, iinput) \
|
| 693 |
-
.then(**retry_bot_args, api_name='retry_bot' if allow_api else None) \
|
| 694 |
-
.then(**retry_bot_args2, api_name='retry_bot2' if allow_api else None) \
|
| 695 |
.then(clear_torch_cache)
|
| 696 |
-
submit_event4 = undo.click(**undo_user_args,
|
| 697 |
-
.then(**undo_user_args2,
|
| 698 |
|
| 699 |
# does both models
|
| 700 |
clear.click(lambda: None, None, text_output, queue=False, api_name='clear' if allow_api else None) \
|
|
@@ -703,8 +704,9 @@ def go_gradio(**kwargs):
|
|
| 703 |
# because score for nochat consumes actual textbox, while chat consumes chat history filled by user()
|
| 704 |
submit_event_nochat = submit_nochat.click(fun, inputs=[model_state] + inputs_list,
|
| 705 |
outputs=text_output_nochat,
|
|
|
|
| 706 |
api_name='submit_nochat' if allow_api else None) \
|
| 707 |
-
.then(**score_args_nochat, api_name='instruction_bot_score_nochat' if allow_api else None) \
|
| 708 |
.then(clear_instruct, None, instruction_nochat) \
|
| 709 |
.then(clear_instruct, None, iinput_nochat) \
|
| 710 |
.then(clear_torch_cache)
|
|
@@ -845,9 +847,11 @@ def go_gradio(**kwargs):
|
|
| 845 |
|
| 846 |
# callback for logging flagged input/output
|
| 847 |
callback.setup(inputs_list + [text_output, text_output2], "flagged_data_points")
|
| 848 |
-
flag_btn.click(lambda *args: callback.flag(args), inputs_list + [text_output, text_output2], None,
|
|
|
|
| 849 |
api_name='flag' if allow_api else None)
|
| 850 |
-
flag_btn_nochat.click(lambda *args: callback.flag(args), inputs_list + [text_output_nochat], None,
|
|
|
|
| 851 |
api_name='flag_nochat' if allow_api else None)
|
| 852 |
|
| 853 |
def get_system_info():
|
|
|
|
| 21 |
admin_pass = kwargs['admin_pass']
|
| 22 |
model_state0 = kwargs['model_state0']
|
| 23 |
score_model_state0 = kwargs['score_model_state0']
|
| 24 |
+
queue = True
|
| 25 |
|
| 26 |
# easy update of kwargs needed for evaluate() etc.
|
| 27 |
kwargs.update(locals())
|
|
|
|
| 486 |
outputs=[score_text_nochat],
|
| 487 |
)
|
| 488 |
if not kwargs['auto_score']:
|
| 489 |
+
score_event = score_btn.click(**score_args, queue=queue, api_name='score' if allow_api else None) \
|
| 490 |
+
.then(**score_args2, queue=queue, api_name='score2' if allow_api else None)
|
| 491 |
+
score_event_nochat = score_btn_nochat.click(**score_args_nochat, queue=queue,
|
| 492 |
api_name='score_nochat' if allow_api else None)
|
| 493 |
|
| 494 |
def user(*args, undo=False, sanitize_user_prompt=True, model2=False):
|
|
|
|
| 637 |
if kwargs['auto_score']:
|
| 638 |
# in case 2nd model, consume instruction first, so can clear quickly
|
| 639 |
# bot doesn't consume instruction itself, just history from user, so why works
|
| 640 |
+
submit_event = instruction.submit(**user_args, queue=queue,
|
| 641 |
api_name='instruction' if allow_api else None) \
|
| 642 |
+
.then(**user_args2, api_name='instruction2' if allow_api else None) \
|
| 643 |
.then(clear_instruct, None, instruction) \
|
| 644 |
.then(clear_instruct, None, iinput) \
|
| 645 |
+
.then(**bot_args, api_name='instruction_bot' if allow_api else None, queue=queue) \
|
| 646 |
+
.then(**score_args, api_name='instruction_bot_score' if allow_api else None, queue=queue) \
|
| 647 |
+
.then(**bot_args2, api_name='instruction_bot2' if allow_api else None, queue=queue) \
|
| 648 |
+
.then(**score_args2, api_name='instruction_bot_score2' if allow_api else None, queue=queue) \
|
| 649 |
.then(clear_torch_cache)
|
| 650 |
+
submit_event2 = submit.click(**user_args, api_name='submit' if allow_api else None) \
|
| 651 |
+
.then(**user_args2, api_name='submit2' if allow_api else None) \
|
| 652 |
.then(clear_instruct, None, instruction) \
|
| 653 |
.then(clear_instruct, None, iinput) \
|
| 654 |
+
.then(**bot_args, api_name='submit_bot' if allow_api else None, queue=queue) \
|
| 655 |
+
.then(**score_args, api_name='submit_bot_score' if allow_api else None, queue=queue) \
|
| 656 |
+
.then(**bot_args2, api_name='submit_bot2' if allow_api else None, queue=queue) \
|
| 657 |
+
.then(**score_args2, api_name='submit_bot_score2' if allow_api else None, queue=queue) \
|
| 658 |
.then(clear_torch_cache)
|
| 659 |
+
submit_event3 = retry.click(**user_args, api_name='retry' if allow_api else None) \
|
| 660 |
+
.then(**user_args2, api_name='retry2' if allow_api else None) \
|
| 661 |
.then(clear_instruct, None, instruction) \
|
| 662 |
.then(clear_instruct, None, iinput) \
|
| 663 |
+
.then(**retry_bot_args, api_name='retry_bot' if allow_api else None, queue=queue) \
|
| 664 |
+
.then(**score_args, api_name='retry_bot_score' if allow_api else None, queue=queue) \
|
| 665 |
+
.then(**retry_bot_args2, api_name='retry_bot2' if allow_api else None, queue=queue) \
|
| 666 |
+
.then(**score_args2, api_name='retry_bot_score2' if allow_api else None, queue=queue) \
|
| 667 |
.then(clear_torch_cache)
|
| 668 |
+
submit_event4 = undo.click(**undo_user_args, api_name='undo' if allow_api else None) \
|
| 669 |
+
.then(**undo_user_args2, api_name='undo2' if allow_api else None) \
|
| 670 |
.then(clear_instruct, None, instruction) \
|
| 671 |
.then(clear_instruct, None, iinput) \
|
| 672 |
.then(**score_args, api_name='undo_score' if allow_api else None) \
|
| 673 |
.then(**score_args2, api_name='undo_score2' if allow_api else None)
|
| 674 |
else:
|
| 675 |
+
submit_event = instruction.submit(**user_args,
|
| 676 |
api_name='instruction' if allow_api else None) \
|
| 677 |
+
.then(**user_args2, api_name='instruction2' if allow_api else None) \
|
| 678 |
.then(clear_instruct, None, instruction) \
|
| 679 |
.then(clear_instruct, None, iinput) \
|
| 680 |
+
.then(**bot_args, api_name='instruction_bot' if allow_api else None, queue=queue) \
|
| 681 |
+
.then(**bot_args2, api_name='instruction_bot2' if allow_api else None, queue=queue) \
|
| 682 |
.then(clear_torch_cache)
|
| 683 |
+
submit_event2 = submit.click(**user_args, api_name='submit' if allow_api else None) \
|
| 684 |
+
.then(**user_args2, api_name='submit2' if allow_api else None) \
|
| 685 |
.then(clear_instruct, None, instruction) \
|
| 686 |
.then(clear_instruct, None, iinput) \
|
| 687 |
+
.then(**bot_args, api_name='submit_bot' if allow_api else None, queue=queue) \
|
| 688 |
+
.then(**bot_args2, api_name='submit_bot2' if allow_api else None, queue=queue) \
|
| 689 |
.then(clear_torch_cache)
|
| 690 |
+
submit_event3 = retry.click(**user_args, api_name='retry' if allow_api else None) \
|
| 691 |
+
.then(**user_args2, api_name='retry2' if allow_api else None) \
|
| 692 |
.then(clear_instruct, None, instruction) \
|
| 693 |
.then(clear_instruct, None, iinput) \
|
| 694 |
+
.then(**retry_bot_args, api_name='retry_bot' if allow_api else None, queue=queue) \
|
| 695 |
+
.then(**retry_bot_args2, api_name='retry_bot2' if allow_api else None, queue=queue) \
|
| 696 |
.then(clear_torch_cache)
|
| 697 |
+
submit_event4 = undo.click(**undo_user_args, api_name='undo' if allow_api else None) \
|
| 698 |
+
.then(**undo_user_args2, api_name='undo2' if allow_api else None)
|
| 699 |
|
| 700 |
# does both models
|
| 701 |
clear.click(lambda: None, None, text_output, queue=False, api_name='clear' if allow_api else None) \
|
|
|
|
| 704 |
# because score for nochat consumes actual textbox, while chat consumes chat history filled by user()
|
| 705 |
submit_event_nochat = submit_nochat.click(fun, inputs=[model_state] + inputs_list,
|
| 706 |
outputs=text_output_nochat,
|
| 707 |
+
queue=queue,
|
| 708 |
api_name='submit_nochat' if allow_api else None) \
|
| 709 |
+
.then(**score_args_nochat, api_name='instruction_bot_score_nochat' if allow_api else None, queue=queue) \
|
| 710 |
.then(clear_instruct, None, instruction_nochat) \
|
| 711 |
.then(clear_instruct, None, iinput_nochat) \
|
| 712 |
.then(clear_torch_cache)
|
|
|
|
| 847 |
|
| 848 |
# callback for logging flagged input/output
|
| 849 |
callback.setup(inputs_list + [text_output, text_output2], "flagged_data_points")
|
| 850 |
+
flag_btn.click(lambda *args: callback.flag(args), inputs_list + [text_output, text_output2], None,
|
| 851 |
+
preprocess=False,
|
| 852 |
api_name='flag' if allow_api else None)
|
| 853 |
+
flag_btn_nochat.click(lambda *args: callback.flag(args), inputs_list + [text_output_nochat], None,
|
| 854 |
+
preprocess=False,
|
| 855 |
api_name='flag_nochat' if allow_api else None)
|
| 856 |
|
| 857 |
def get_system_info():
|