Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,9 @@ except Exception as e:
|
|
| 29 |
with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) as demo:
|
| 30 |
gr.Markdown("## DeepV for RTL Code Generation — Model-Agnostic (Bring Your Own API Key)", elem_id="main-title")
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
with gr.Row():
|
| 33 |
with gr.Column(scale=2):
|
| 34 |
with gr.Row():
|
|
@@ -71,12 +74,12 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 71 |
)
|
| 72 |
|
| 73 |
with gr.Column(scale=3):
|
| 74 |
-
# --- DeepV Logo and "Output" text
|
| 75 |
with gr.Row(elem_id="logo-and-output-row"):
|
| 76 |
# Container for the logo to allow layered animations
|
| 77 |
gr.HTML("""
|
| 78 |
<div id="logo-container">
|
| 79 |
-
<img
|
| 80 |
<div id="deep-part" class="logo-overlay"></div>
|
| 81 |
</div>
|
| 82 |
""")
|
|
@@ -123,9 +126,12 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 123 |
show_progress=False,
|
| 124 |
js="""
|
| 125 |
(e) => {
|
| 126 |
-
document.getElementById('deep-part')
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
-
"""
|
| 129 |
).then(
|
| 130 |
fn=generate_only,
|
| 131 |
inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
|
|
@@ -136,11 +142,14 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 136 |
outputs=[run_btn, loading_state],
|
| 137 |
js="""
|
| 138 |
(e) => {
|
| 139 |
-
document.getElementById('deep-part')
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
-
"""
|
| 144 |
)
|
| 145 |
|
| 146 |
clear_btn.click(fn=lambda: "Ready", outputs=[])
|
|
@@ -152,7 +161,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 152 |
outputs=[],
|
| 153 |
js="""
|
| 154 |
(text) => {
|
| 155 |
-
// Creates and copies a temporary element without using variable declarations
|
| 156 |
(function(el) {
|
| 157 |
el.value = text;
|
| 158 |
document.body.appendChild(el);
|
|
@@ -164,6 +172,16 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 164 |
"""
|
| 165 |
)
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
demo.css = """
|
| 168 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
|
| 169 |
|
|
@@ -207,8 +225,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 207 |
left: 0;
|
| 208 |
width: 100%;
|
| 209 |
height: 100%;
|
| 210 |
-
/* CORRECTED: Use a URL that Gradio can resolve */
|
| 211 |
-
background-image: url('file=DeepV_logo.png');
|
| 212 |
background-size: contain;
|
| 213 |
background-repeat: no-repeat;
|
| 214 |
background-position: center;
|
|
|
|
| 29 |
with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) as demo:
|
| 30 |
gr.Markdown("## DeepV for RTL Code Generation — Model-Agnostic (Bring Your Own API Key)", elem_id="main-title")
|
| 31 |
|
| 32 |
+
# Serve the logo file correctly using gr.File
|
| 33 |
+
logo_file = gr.File("DeepV_logo.png", visible=False, file_id="deepv-logo-file")
|
| 34 |
+
|
| 35 |
with gr.Row():
|
| 36 |
with gr.Column(scale=2):
|
| 37 |
with gr.Row():
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
with gr.Column(scale=3):
|
| 77 |
+
# --- DeepV Logo and "Output" text ---
|
| 78 |
with gr.Row(elem_id="logo-and-output-row"):
|
| 79 |
# Container for the logo to allow layered animations
|
| 80 |
gr.HTML("""
|
| 81 |
<div id="logo-container">
|
| 82 |
+
<img id="deepv-base-logo" alt="DeepV Logo">
|
| 83 |
<div id="deep-part" class="logo-overlay"></div>
|
| 84 |
</div>
|
| 85 |
""")
|
|
|
|
| 126 |
show_progress=False,
|
| 127 |
js="""
|
| 128 |
(e) => {
|
| 129 |
+
var deepPart = document.getElementById('deep-part');
|
| 130 |
+
if (deepPart) {
|
| 131 |
+
deepPart.classList.add('deep-hop-away');
|
| 132 |
+
}
|
| 133 |
}
|
| 134 |
+
"""
|
| 135 |
).then(
|
| 136 |
fn=generate_only,
|
| 137 |
inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
|
|
|
|
| 142 |
outputs=[run_btn, loading_state],
|
| 143 |
js="""
|
| 144 |
(e) => {
|
| 145 |
+
var deepPart = document.getElementById('deep-part');
|
| 146 |
+
if (deepPart) {
|
| 147 |
+
deepPart.classList.remove('deep-hop-away');
|
| 148 |
+
// This line forces the browser to re-render, ensuring the animation resets
|
| 149 |
+
void deepPart.offsetWidth;
|
| 150 |
+
}
|
| 151 |
}
|
| 152 |
+
"""
|
| 153 |
)
|
| 154 |
|
| 155 |
clear_btn.click(fn=lambda: "Ready", outputs=[])
|
|
|
|
| 161 |
outputs=[],
|
| 162 |
js="""
|
| 163 |
(text) => {
|
|
|
|
| 164 |
(function(el) {
|
| 165 |
el.value = text;
|
| 166 |
document.body.appendChild(el);
|
|
|
|
| 172 |
"""
|
| 173 |
)
|
| 174 |
|
| 175 |
+
# --- New JS/CSS to handle the logo paths
|
| 176 |
+
demo.load(None, None, None, js="""
|
| 177 |
+
function setLogoSrc() {
|
| 178 |
+
var logo_url = window.__gradio_space__ + '/file=DeepV_logo.png';
|
| 179 |
+
document.getElementById('deepv-base-logo').src = logo_url;
|
| 180 |
+
document.getElementById('deep-part').style.backgroundImage = 'url(' + logo_url + ')';
|
| 181 |
+
}
|
| 182 |
+
window.addEventListener('load', setLogoSrc);
|
| 183 |
+
""")
|
| 184 |
+
|
| 185 |
demo.css = """
|
| 186 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
|
| 187 |
|
|
|
|
| 225 |
left: 0;
|
| 226 |
width: 100%;
|
| 227 |
height: 100%;
|
|
|
|
|
|
|
| 228 |
background-size: contain;
|
| 229 |
background-repeat: no-repeat;
|
| 230 |
background-position: center;
|