Update app.py
Browse files
app.py
CHANGED
|
@@ -94,8 +94,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
|
|
| 94 |
)
|
| 95 |
# The copy button is added here
|
| 96 |
copy_button = gr.Button("📋", scale=0)
|
| 97 |
-
# You can use a more explicit label if you prefer:
|
| 98 |
-
# copy_button = gr.Button("Copy Code", scale=0)
|
| 99 |
|
| 100 |
with gr.Tab("Retrieved Items (names + scores)"):
|
| 101 |
retrieved_list = gr.Textbox(
|
|
@@ -112,13 +110,21 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
|
|
| 112 |
outputs=[out_code, retrieved_list, retrieved_raw]
|
| 113 |
)
|
| 114 |
|
| 115 |
-
#
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
| 124 |
if 'agent_module' in locals():
|
|
|
|
| 94 |
)
|
| 95 |
# The copy button is added here
|
| 96 |
copy_button = gr.Button("📋", scale=0)
|
|
|
|
|
|
|
| 97 |
|
| 98 |
with gr.Tab("Retrieved Items (names + scores)"):
|
| 99 |
retrieved_list = gr.Textbox(
|
|
|
|
| 110 |
outputs=[out_code, retrieved_list, retrieved_raw]
|
| 111 |
)
|
| 112 |
|
| 113 |
+
# Use the `on_event` method to add the copy functionality
|
| 114 |
+
copy_button.click(None, [out_code], None, _js="""
|
| 115 |
+
(text) => {
|
| 116 |
+
if (navigator.clipboard) {
|
| 117 |
+
navigator.clipboard.writeText(text);
|
| 118 |
+
return;
|
| 119 |
+
}
|
| 120 |
+
const el = document.createElement('textarea');
|
| 121 |
+
el.value = text;
|
| 122 |
+
document.body.appendChild(el);
|
| 123 |
+
el.select();
|
| 124 |
+
document.execCommand('copy');
|
| 125 |
+
document.body.removeChild(el);
|
| 126 |
+
}
|
| 127 |
+
""")
|
| 128 |
|
| 129 |
if __name__ == "__main__":
|
| 130 |
if 'agent_module' in locals():
|