Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from styles import MODEL_SELECTION_CSS
|
|
9 |
from js import GET_LOCAL_STORAGE, UPDATE_LEFT_BTNS_STATE, UPDATE_PLACEHOLDERS
|
10 |
from templates import templates
|
11 |
|
|
|
12 |
from pingpong.context import CtxLastWindowStrategy
|
13 |
|
14 |
TOKEN = os.getenv('HF_TOKEN')
|
@@ -234,6 +235,55 @@ with gr.Blocks(css=MODEL_SELECTION_CSS, theme='gradio/soft') as demo:
|
|
234 |
_js=UPDATE_LEFT_BTNS_STATE
|
235 |
)
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
demo.load(
|
238 |
None,
|
239 |
inputs=None,
|
|
|
9 |
from js import GET_LOCAL_STORAGE, UPDATE_LEFT_BTNS_STATE, UPDATE_PLACEHOLDERS
|
10 |
from templates import templates
|
11 |
|
12 |
+
from pingpong import PingPong
|
13 |
from pingpong.context import CtxLastWindowStrategy
|
14 |
|
15 |
TOKEN = os.getenv('HF_TOKEN')
|
|
|
235 |
_js=UPDATE_LEFT_BTNS_STATE
|
236 |
)
|
237 |
|
238 |
+
for btn in ex_btns:
|
239 |
+
btn.click(
|
240 |
+
set_example,
|
241 |
+
[btn],
|
242 |
+
[instruction_txtbox, example_block]
|
243 |
+
)
|
244 |
+
|
245 |
+
placeholder_txt1.change(
|
246 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
247 |
+
outputs=[template_md],
|
248 |
+
show_progress=False,
|
249 |
+
_js=UPDATE_PLACEHOLDERS,
|
250 |
+
fn=None
|
251 |
+
)
|
252 |
+
|
253 |
+
placeholder_txt2.change(
|
254 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
255 |
+
outputs=[template_md],
|
256 |
+
show_progress=False,
|
257 |
+
_js=UPDATE_PLACEHOLDERS,
|
258 |
+
fn=None
|
259 |
+
)
|
260 |
+
|
261 |
+
placeholder_txt3.change(
|
262 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
263 |
+
outputs=[template_md],
|
264 |
+
show_progress=False,
|
265 |
+
_js=UPDATE_PLACEHOLDERS,
|
266 |
+
fn=None
|
267 |
+
)
|
268 |
+
|
269 |
+
placeholder_txt1.submit(
|
270 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
271 |
+
outputs=[instruction_txtbox, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
272 |
+
fn=get_final_template
|
273 |
+
)
|
274 |
+
|
275 |
+
placeholder_txt2.submit(
|
276 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
277 |
+
outputs=[instruction_txtbox, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
278 |
+
fn=get_final_template
|
279 |
+
)
|
280 |
+
|
281 |
+
placeholder_txt3.submit(
|
282 |
+
inputs=[template_txt, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
283 |
+
outputs=[instruction_txtbox, placeholder_txt1, placeholder_txt2, placeholder_txt3],
|
284 |
+
fn=get_final_template
|
285 |
+
)
|
286 |
+
|
287 |
demo.load(
|
288 |
None,
|
289 |
inputs=None,
|