Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -64,28 +64,32 @@ def copy_to_clipboard(text):
|
|
64 |
pyperclip.copy(text)
|
65 |
return "Text copied to clipboard!"
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
iface = gr.Interface(
|
68 |
fn=generate,
|
69 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
70 |
outputs=gr.Textbox(visible=False),
|
71 |
title="Chuunibyou Text Generator",
|
72 |
-
description="Transform text into an elaborate and formal style with a Chuunibyou tone."
|
73 |
-
live=False
|
74 |
)
|
75 |
|
76 |
-
|
77 |
-
return gr.update(value=text, visible=True)
|
78 |
-
|
79 |
-
iface_after_submit = iface.set_event_handlers(
|
80 |
-
submit=lambda x: update_output(generate(x))
|
81 |
-
)
|
82 |
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
89 |
|
90 |
if __name__ == "__main__":
|
91 |
-
|
|
|
64 |
pyperclip.copy(text)
|
65 |
return "Text copied to clipboard!"
|
66 |
|
67 |
+
def update_output_and_copy(text):
|
68 |
+
response_text = generate(text)
|
69 |
+
pyperclip.copy(response_text)
|
70 |
+
return gr.update(value=response_text, visible=True), "Text copied to clipboard!"
|
71 |
+
|
72 |
iface = gr.Interface(
|
73 |
fn=generate,
|
74 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
75 |
outputs=gr.Textbox(visible=False),
|
76 |
title="Chuunibyou Text Generator",
|
77 |
+
description="Transform text into an elaborate and formal style with a Chuunibyou tone."
|
|
|
78 |
)
|
79 |
|
80 |
+
iface_with_button = gr.Blocks()
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
with iface_with_button:
|
83 |
+
textbox = gr.Textbox(lines=2, placeholder="Enter text here...")
|
84 |
+
output = gr.Textbox(visible=False)
|
85 |
+
submit_button = gr.Button("Submit")
|
86 |
+
copy_message = gr.Textbox(visible=False)
|
87 |
|
88 |
+
submit_button.click(
|
89 |
+
fn=update_output_and_copy,
|
90 |
+
inputs=textbox,
|
91 |
+
outputs=[output, copy_message]
|
92 |
+
)
|
93 |
|
94 |
if __name__ == "__main__":
|
95 |
+
iface_with_button.launch()
|