Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,11 @@ def reset_user_input():
|
|
91 |
|
92 |
def reset_state():
|
93 |
history = gr.State(init_history)
|
94 |
-
return '', '', []
|
|
|
|
|
|
|
|
|
95 |
|
96 |
|
97 |
with gr.Blocks() as demo:
|
@@ -107,7 +111,7 @@ with gr.Blocks() as demo:
|
|
107 |
emptyBtn = gr.Button("Clear History")
|
108 |
|
109 |
five_sample = gr.Textbox(show_label=False, placeholder="五個範例")
|
110 |
-
expand = gr.Dropdown(["1", "2", "3", "4", "5"], label="Step2:進一步擴展的範例")
|
111 |
final_sample = gr.Textbox(show_label=False, placeholder="大綱")
|
112 |
|
113 |
history = gr.State(init_history)
|
@@ -119,14 +123,15 @@ with gr.Blocks() as demo:
|
|
119 |
)
|
120 |
submitBtn.click(reset_user_input, [], [user_input])
|
121 |
submitBtn.click(reset_user_input, [], [final_sample])
|
122 |
-
|
|
|
123 |
expand.select(
|
124 |
fn=predict,
|
125 |
inputs=[expand, max_length, top_p, temperature, history],
|
126 |
-
outputs=final_sample)
|
127 |
|
128 |
emptyBtn.click(reset_state,
|
129 |
-
outputs=[five_sample, final_sample, history],
|
130 |
show_progress=True)
|
131 |
|
132 |
demo.queue().launch(share=False, inbrowser=True)
|
|
|
91 |
|
92 |
def reset_state():
|
93 |
history = gr.State(init_history)
|
94 |
+
return '', '', [], gr.Dropdown.update(value=None, interactive=False)
|
95 |
+
|
96 |
+
|
97 |
+
def allow_user_input():
|
98 |
+
return gr.Dropdown.update(interactive=True)
|
99 |
|
100 |
|
101 |
with gr.Blocks() as demo:
|
|
|
111 |
emptyBtn = gr.Button("Clear History")
|
112 |
|
113 |
five_sample = gr.Textbox(show_label=False, placeholder="五個範例")
|
114 |
+
expand = gr.Dropdown(["1", "2", "3", "4", "5"], label="Step2:進一步擴展的範例", interactive=False)
|
115 |
final_sample = gr.Textbox(show_label=False, placeholder="大綱")
|
116 |
|
117 |
history = gr.State(init_history)
|
|
|
123 |
)
|
124 |
submitBtn.click(reset_user_input, [], [user_input])
|
125 |
submitBtn.click(reset_user_input, [], [final_sample])
|
126 |
+
submitBtn.click(allow_user_input, [], [expand])
|
127 |
+
|
128 |
expand.select(
|
129 |
fn=predict,
|
130 |
inputs=[expand, max_length, top_p, temperature, history],
|
131 |
+
outputs=[final_sample, history])
|
132 |
|
133 |
emptyBtn.click(reset_state,
|
134 |
+
outputs=[five_sample, final_sample, history, expand],
|
135 |
show_progress=True)
|
136 |
|
137 |
demo.queue().launch(share=False, inbrowser=True)
|