Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
# app.py
|
2 |
import gradio as gr
|
3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
import torch
|
@@ -145,6 +144,7 @@ h1 {
|
|
145 |
|
146 |
# JavaScript for the copy button
|
147 |
copy_js = """
|
|
|
148 |
function copyCode() {
|
149 |
const codeElement = document.querySelector('.output-box pre');
|
150 |
const codeText = codeElement.innerText;
|
@@ -152,6 +152,7 @@ function copyCode() {
|
|
152 |
alert('Code copied to clipboard!');
|
153 |
});
|
154 |
}
|
|
|
155 |
"""
|
156 |
|
157 |
# Gradio interface for the app
|
@@ -166,6 +167,9 @@ with gr.Blocks(css=custom_css) as demo:
|
|
166 |
gr.Markdown("# Smart Contract Generator")
|
167 |
gr.Markdown("Generate smart contracts using AI.")
|
168 |
|
|
|
|
|
|
|
169 |
# Output box with copy button
|
170 |
with gr.Column():
|
171 |
output_box = gr.HTML(label="Generated Smart Contract", elem_classes="output-box")
|
@@ -183,9 +187,6 @@ with gr.Blocks(css=custom_css) as demo:
|
|
183 |
inputs=[language_dropdown, requirements_input],
|
184 |
outputs=output_box
|
185 |
)
|
186 |
-
|
187 |
-
# Add JavaScript for the copy button
|
188 |
-
demo.load(fn=None, inputs=None, outputs=None, _js=copy_js)
|
189 |
|
190 |
# Launch the Gradio app
|
191 |
demo.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import torch
|
|
|
144 |
|
145 |
# JavaScript for the copy button
|
146 |
copy_js = """
|
147 |
+
<script>
|
148 |
function copyCode() {
|
149 |
const codeElement = document.querySelector('.output-box pre');
|
150 |
const codeText = codeElement.innerText;
|
|
|
152 |
alert('Code copied to clipboard!');
|
153 |
});
|
154 |
}
|
155 |
+
</script>
|
156 |
"""
|
157 |
|
158 |
# Gradio interface for the app
|
|
|
167 |
gr.Markdown("# Smart Contract Generator")
|
168 |
gr.Markdown("Generate smart contracts using AI.")
|
169 |
|
170 |
+
# Inject JavaScript
|
171 |
+
gr.HTML(copy_js)
|
172 |
+
|
173 |
# Output box with copy button
|
174 |
with gr.Column():
|
175 |
output_box = gr.HTML(label="Generated Smart Contract", elem_classes="output-box")
|
|
|
187 |
inputs=[language_dropdown, requirements_input],
|
188 |
outputs=output_box
|
189 |
)
|
|
|
|
|
|
|
190 |
|
191 |
# Launch the Gradio app
|
192 |
demo.launch()
|