Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ 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():
|
| 35 |
model_choice = gr.Dropdown(
|
|
@@ -54,8 +54,12 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 54 |
with gr.Row():
|
| 55 |
use_rag = gr.Checkbox(value=True, label="Use Retrieval (RAG)")
|
| 56 |
top_k = gr.Slider(1, 10, value=3, step=1, label="Top-K retrieved examples")
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
| 59 |
temperature = gr.Slider(0.0, 1.5, value=0.2, step=0.05, label="Temperature")
|
| 60 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 61 |
max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
|
|
@@ -96,7 +100,23 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 96 |
spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens
|
| 97 |
)
|
| 98 |
return verilog_code
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
def copy_to_clipboard_fn(text):
|
| 101 |
return text
|
| 102 |
|
|
@@ -121,7 +141,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 121 |
outputs=[run_btn, loading_state]
|
| 122 |
)
|
| 123 |
|
| 124 |
-
# Removed the status bar updates from these functions
|
| 125 |
clear_btn.click(fn=lambda: "Ready", outputs=[])
|
| 126 |
spec.submit(fn=lambda: "Ready", outputs=[])
|
| 127 |
|
|
@@ -144,18 +163,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 144 |
demo.css = """
|
| 145 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
|
| 146 |
|
| 147 |
-
/* NEW: Force flexbox behavior on the main row */
|
| 148 |
-
#main-row {
|
| 149 |
-
display: flex;
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
/* NEW: Fixes the jitter when accordion opens */
|
| 153 |
-
.gr-accordion {
|
| 154 |
-
display: flex;
|
| 155 |
-
flex-direction: column;
|
| 156 |
-
width: 100%;
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
#main-title {
|
| 160 |
font-family: 'Poppins', sans-serif;
|
| 161 |
font-weight: 600;
|
|
|
|
| 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():
|
| 35 |
model_choice = gr.Dropdown(
|
|
|
|
| 54 |
with gr.Row():
|
| 55 |
use_rag = gr.Checkbox(value=True, label="Use Retrieval (RAG)")
|
| 56 |
top_k = gr.Slider(1, 10, value=3, step=1, label="Top-K retrieved examples")
|
| 57 |
+
|
| 58 |
+
# --- New UI for Generation Settings ---
|
| 59 |
+
toggle_btn = gr.Button("Show/Hide Generation Settings", size="sm")
|
| 60 |
|
| 61 |
+
settings_column = gr.Column(visible=False)
|
| 62 |
+
with settings_column:
|
| 63 |
temperature = gr.Slider(0.0, 1.5, value=0.2, step=0.05, label="Temperature")
|
| 64 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 65 |
max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
|
|
|
|
| 100 |
spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens
|
| 101 |
)
|
| 102 |
return verilog_code
|
| 103 |
+
|
| 104 |
+
# --- Event listeners for the UI ---
|
| 105 |
+
toggle_btn.click(
|
| 106 |
+
fn=None,
|
| 107 |
+
inputs=None,
|
| 108 |
+
outputs=settings_column,
|
| 109 |
+
js="""
|
| 110 |
+
(e) => {
|
| 111 |
+
const column = document.getElementById(e.target.dataset.targetId);
|
| 112 |
+
if (column) {
|
| 113 |
+
column.style.display = column.style.display === 'none' ? 'flex' : 'none';
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
""",
|
| 117 |
+
_js_metadata={"targetId": "settings_column"}
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
def copy_to_clipboard_fn(text):
|
| 121 |
return text
|
| 122 |
|
|
|
|
| 141 |
outputs=[run_btn, loading_state]
|
| 142 |
)
|
| 143 |
|
|
|
|
| 144 |
clear_btn.click(fn=lambda: "Ready", outputs=[])
|
| 145 |
spec.submit(fn=lambda: "Ready", outputs=[])
|
| 146 |
|
|
|
|
| 163 |
demo.css = """
|
| 164 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
#main-title {
|
| 167 |
font-family: 'Poppins', sans-serif;
|
| 168 |
font-weight: 600;
|