feat: Enhance save button interactivity in Gradio interface for prompt changes
Browse files- interface.py +19 -1
interface.py
CHANGED
|
@@ -833,7 +833,8 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 833 |
save_prompts_button = gr.Button(
|
| 834 |
"💾 Зберегти промпти",
|
| 835 |
variant="primary",
|
| 836 |
-
scale=1
|
|
|
|
| 837 |
)
|
| 838 |
reset_prompts_button = gr.Button(
|
| 839 |
"🔄 Скинути до стандартних",
|
|
@@ -1047,6 +1048,15 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 1047 |
)
|
| 1048 |
|
| 1049 |
# Settings tab event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1050 |
save_prompts_button.click(
|
| 1051 |
fn=save_custom_prompts,
|
| 1052 |
inputs=[
|
|
@@ -1056,6 +1066,10 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 1056 |
analysis_prompt_editor
|
| 1057 |
],
|
| 1058 |
outputs=[prompts_status, session_id_state]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1059 |
)
|
| 1060 |
|
| 1061 |
reset_prompts_button.click(
|
|
@@ -1068,6 +1082,10 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 1068 |
prompts_status,
|
| 1069 |
session_id_state
|
| 1070 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1071 |
)
|
| 1072 |
|
| 1073 |
# Batch testing tab event handlers
|
|
|
|
| 833 |
save_prompts_button = gr.Button(
|
| 834 |
"💾 Зберегти промпти",
|
| 835 |
variant="primary",
|
| 836 |
+
scale=1,
|
| 837 |
+
interactive=False
|
| 838 |
)
|
| 839 |
reset_prompts_button = gr.Button(
|
| 840 |
"🔄 Скинути до стандартних",
|
|
|
|
| 1048 |
)
|
| 1049 |
|
| 1050 |
# Settings tab event handlers
|
| 1051 |
+
|
| 1052 |
+
# Enable save button when any prompt is changed
|
| 1053 |
+
for editor in [system_prompt_editor, lp_prompt_editor, analysis_prompt_editor]:
|
| 1054 |
+
editor.change(
|
| 1055 |
+
fn=lambda: gr.update(interactive=True),
|
| 1056 |
+
inputs=None,
|
| 1057 |
+
outputs=[save_prompts_button]
|
| 1058 |
+
)
|
| 1059 |
+
|
| 1060 |
save_prompts_button.click(
|
| 1061 |
fn=save_custom_prompts,
|
| 1062 |
inputs=[
|
|
|
|
| 1066 |
analysis_prompt_editor
|
| 1067 |
],
|
| 1068 |
outputs=[prompts_status, session_id_state]
|
| 1069 |
+
).then(
|
| 1070 |
+
fn=lambda: gr.update(interactive=False),
|
| 1071 |
+
inputs=None,
|
| 1072 |
+
outputs=[save_prompts_button]
|
| 1073 |
)
|
| 1074 |
|
| 1075 |
reset_prompts_button.click(
|
|
|
|
| 1082 |
prompts_status,
|
| 1083 |
session_id_state
|
| 1084 |
]
|
| 1085 |
+
).then(
|
| 1086 |
+
fn=lambda: gr.update(interactive=False),
|
| 1087 |
+
inputs=None,
|
| 1088 |
+
outputs=[save_prompts_button]
|
| 1089 |
)
|
| 1090 |
|
| 1091 |
# Batch testing tab event handlers
|