Spaces:
Sleeping
Sleeping
Commit
Β·
75694c7
1
Parent(s):
ca2ecfb
Adding spinner
Browse files
app.py
CHANGED
@@ -43,15 +43,40 @@ def generate_code(prompt, style="Clean & Pythonic"):
|
|
43 |
spinner.update(visible=False)
|
44 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
45 |
|
46 |
-
demo = gr.Interface(
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
demo.launch()
|
|
|
43 |
spinner.update(visible=False)
|
44 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
45 |
|
46 |
+
# demo = gr.Interface(
|
47 |
+
# fn=generate_code,
|
48 |
+
# inputs=[
|
49 |
+
# gr.Textbox(label="How shall Codice Da Vinci help today?", lines=3),
|
50 |
+
# gr.Dropdown(["Clean & Pythonic", "Verbose like a 15th-century manuscript"], label="Code Style")
|
51 |
+
# ],
|
52 |
+
# outputs=gr.Code(label="π§Ύ Leonardo's Work"),
|
53 |
+
# title="Codice Da Vinci ππ»",
|
54 |
+
# description="Your Renaissance coding assistant. Fluent in algorithms and Latin. Powered by LLM."
|
55 |
+
# )
|
56 |
+
|
57 |
+
with gr.Blocks() as demo:
|
58 |
+
gr.Markdown("<h1 style='text-align:center;'>Codice Da Vinci ππ»</h1>")
|
59 |
+
|
60 |
+
with gr.Row():
|
61 |
+
prompt = gr.Textbox(label="How shall Codice Da Vinci help today?", lines=3)
|
62 |
+
style = gr.Dropdown(["Clean & Pythonic", "Verbose like a 15th-century manuscript"], label="Code Style")
|
63 |
+
|
64 |
+
generate_btn = gr.Button("Generate")
|
65 |
+
|
66 |
+
# Spinner with your custom GIF
|
67 |
+
spinner = gr.HTML(
|
68 |
+
"<div style='text-align:center;'><img src='file/assets/my_spinner.gif' width='100'></div>",
|
69 |
+
visible=False
|
70 |
+
)
|
71 |
+
|
72 |
+
output = gr.Code(label="π§Ύ Leonardo's Work")
|
73 |
+
|
74 |
+
def wrapped_generate(prompt, style):
|
75 |
+
spinner.visible = True
|
76 |
+
result = generate_code(prompt, style)
|
77 |
+
spinner.visible = False
|
78 |
+
return result
|
79 |
+
|
80 |
+
generate_btn.click(fn=wrapped_generate, inputs=[prompt, style], outputs=output)
|
81 |
|
82 |
demo.launch()
|