Spaces:
Running
on
Zero
Running
on
Zero
Mizukiluke
commited on
Commit
•
a6e4c9f
1
Parent(s):
40f5173
Update app.py
Browse files
app.py
CHANGED
@@ -495,27 +495,27 @@ with gr.Blocks(css=css) as demo:
|
|
495 |
[txt_message, chat_bot, app_session]
|
496 |
)
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
|
520 |
chat_tab.select(
|
521 |
select_chat_type,
|
@@ -527,16 +527,16 @@ with gr.Blocks(css=css) as demo:
|
|
527 |
[txt_message, chat_bot, app_session],
|
528 |
[txt_message, chat_bot, app_session, image_input, user_message, assistant_message]
|
529 |
)
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
chat_bot.flushed(
|
541 |
flushed,
|
542 |
outputs=[txt_message]
|
|
|
495 |
[txt_message, chat_bot, app_session]
|
496 |
)
|
497 |
|
498 |
+
with gr.Tab("Few Shot", visible=False) as fewshot_tab:
|
499 |
+
fewshot_tab_label = gr.Textbox(value="Few Shot", interactive=False, visible=False)
|
500 |
+
with gr.Row():
|
501 |
+
with gr.Column(scale=1):
|
502 |
+
image_input = gr.Image(type="filepath", sources=["upload"])
|
503 |
+
with gr.Column(scale=3):
|
504 |
+
user_message = gr.Textbox(label="User")
|
505 |
+
assistant_message = gr.Textbox(label="Assistant")
|
506 |
+
with gr.Row():
|
507 |
+
add_demonstration_button = gr.Button("Add Example")
|
508 |
+
generate_button = gr.Button(value="Generate", variant="primary")
|
509 |
+
add_demonstration_button.click(
|
510 |
+
fewshot_add_demonstration,
|
511 |
+
[image_input, user_message, assistant_message, chat_bot, app_session],
|
512 |
+
[image_input, user_message, assistant_message, chat_bot, app_session]
|
513 |
+
)
|
514 |
+
generate_button.click(
|
515 |
+
fewshot_respond,
|
516 |
+
[image_input, user_message, chat_bot, app_session, params_form],
|
517 |
+
[image_input, user_message, assistant_message, chat_bot, app_session]
|
518 |
+
)
|
519 |
|
520 |
chat_tab.select(
|
521 |
select_chat_type,
|
|
|
527 |
[txt_message, chat_bot, app_session],
|
528 |
[txt_message, chat_bot, app_session, image_input, user_message, assistant_message]
|
529 |
)
|
530 |
+
fewshot_tab.select(
|
531 |
+
select_chat_type,
|
532 |
+
[fewshot_tab_label, app_session],
|
533 |
+
[app_session]
|
534 |
+
)
|
535 |
+
fewshot_tab.select( # do clear
|
536 |
+
clear,
|
537 |
+
[txt_message, chat_bot, app_session],
|
538 |
+
[txt_message, chat_bot, app_session, image_input, user_message, assistant_message]
|
539 |
+
)
|
540 |
chat_bot.flushed(
|
541 |
flushed,
|
542 |
outputs=[txt_message]
|