Commit ·
c9c5035
1
Parent(s): 0ae174a
fixing 3
Browse files
app.py
CHANGED
|
@@ -26,18 +26,10 @@ except Exception as e:
|
|
| 26 |
return f"// ERROR: Failed to load core agent code. Details: {e}", "", ""
|
| 27 |
|
| 28 |
# --- Gradio UI setup below ---
|
| 29 |
-
with gr.Blocks(
|
| 30 |
-
title="DeepV for RTL (Model-Agnostic)",
|
| 31 |
-
# Use a single color value for the background fill
|
| 32 |
-
theme=gr.themes.Soft().set(
|
| 33 |
-
background_fill_secondary="#eee", # A light gray that works for both themes
|
| 34 |
-
button_primary_background_fill_dark="#4CAF50",
|
| 35 |
-
button_primary_background_fill_hover_dark="#3e8e41",
|
| 36 |
-
button_primary_text_color_dark="#fff"
|
| 37 |
-
)
|
| 38 |
-
) as demo:
|
| 39 |
gr.Markdown("## DeepV for RTL Code Generation — Model-Agnostic (Bring Your Own API Key)")
|
| 40 |
|
|
|
|
| 41 |
status_bar = gr.Textbox(
|
| 42 |
label="Status",
|
| 43 |
lines=1,
|
|
@@ -78,8 +70,16 @@ with gr.Blocks(
|
|
| 78 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 79 |
max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
|
| 80 |
|
|
|
|
| 81 |
with gr.Row():
|
| 82 |
run_btn = gr.Button("Generate Verilog", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
with gr.Column(scale=3):
|
| 85 |
gr.Markdown("**Output**")
|
|
@@ -111,16 +111,31 @@ with gr.Blocks(
|
|
| 111 |
def copy_to_clipboard_fn(text):
|
| 112 |
return text
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
run_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
fn=run_generation,
|
| 116 |
inputs=[spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens],
|
| 117 |
outputs=[out_code, retrieved_list, retrieved_raw],
|
| 118 |
-
show_progress=True
|
| 119 |
).then(
|
| 120 |
-
fn=
|
| 121 |
-
|
|
|
|
| 122 |
)
|
| 123 |
-
|
|
|
|
| 124 |
clear_btn.click(fn=lambda: "Ready", outputs=[status_bar])
|
| 125 |
spec.submit(fn=lambda: "Ready", outputs=[status_bar])
|
| 126 |
|
|
@@ -150,8 +165,8 @@ with gr.Blocks(
|
|
| 150 |
top: 20px;
|
| 151 |
right: 10px;
|
| 152 |
z-index: 1000;
|
| 153 |
-
background-color: #
|
| 154 |
-
color: #
|
| 155 |
border-radius: 5px;
|
| 156 |
border: none;
|
| 157 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
|
|
| 26 |
return f"// ERROR: Failed to load core agent code. Details: {e}", "", ""
|
| 27 |
|
| 28 |
# --- Gradio UI setup below ---
|
| 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)")
|
| 31 |
|
| 32 |
+
# Status Bar for success/error messages
|
| 33 |
status_bar = gr.Textbox(
|
| 34 |
label="Status",
|
| 35 |
lines=1,
|
|
|
|
| 70 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 71 |
max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
|
| 72 |
|
| 73 |
+
# --- Loading State Components ---
|
| 74 |
with gr.Row():
|
| 75 |
run_btn = gr.Button("Generate Verilog", variant="primary")
|
| 76 |
+
# New loading state components
|
| 77 |
+
loading_state = gr.Textbox(
|
| 78 |
+
value="Generating...",
|
| 79 |
+
show_copy_button=False,
|
| 80 |
+
visible=False,
|
| 81 |
+
container=False,
|
| 82 |
+
)
|
| 83 |
|
| 84 |
with gr.Column(scale=3):
|
| 85 |
gr.Markdown("**Output**")
|
|
|
|
| 111 |
def copy_to_clipboard_fn(text):
|
| 112 |
return text
|
| 113 |
|
| 114 |
+
# Helper function to show loading state
|
| 115 |
+
def show_loading():
|
| 116 |
+
return [gr.update(visible=False), gr.update(visible=True)]
|
| 117 |
+
|
| 118 |
+
# Helper function to hide loading state
|
| 119 |
+
def hide_loading():
|
| 120 |
+
return [gr.update(visible=True), gr.update(visible=False)]
|
| 121 |
+
|
| 122 |
+
# --- Event Handlers ---
|
| 123 |
run_btn.click(
|
| 124 |
+
fn=show_loading,
|
| 125 |
+
inputs=[],
|
| 126 |
+
outputs=[run_btn, loading_state],
|
| 127 |
+
show_progress=False # Disable default progress spinner
|
| 128 |
+
).then(
|
| 129 |
fn=run_generation,
|
| 130 |
inputs=[spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens],
|
| 131 |
outputs=[out_code, retrieved_list, retrieved_raw],
|
|
|
|
| 132 |
).then(
|
| 133 |
+
fn=hide_loading,
|
| 134 |
+
inputs=[],
|
| 135 |
+
outputs=[run_btn, loading_state]
|
| 136 |
)
|
| 137 |
+
|
| 138 |
+
# Status bar updates
|
| 139 |
clear_btn.click(fn=lambda: "Ready", outputs=[status_bar])
|
| 140 |
spec.submit(fn=lambda: "Ready", outputs=[status_bar])
|
| 141 |
|
|
|
|
| 165 |
top: 20px;
|
| 166 |
right: 10px;
|
| 167 |
z-index: 1000;
|
| 168 |
+
background-color: #F0F0F0;
|
| 169 |
+
color: #333;
|
| 170 |
border-radius: 5px;
|
| 171 |
border: none;
|
| 172 |
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|