paulcalzada commited on
Commit
3070d9e
·
verified ·
1 Parent(s): 6f2af61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import gradio as gr
3
  from huggingface_hub import hf_hub_download
4
  import importlib.util
 
5
 
6
  # --- Private Repository Information ---
7
  PRIVATE_DATASET_ID = os.getenv("PRIVATE_DATASET_ID")
@@ -25,13 +26,21 @@ except Exception as e:
25
  def show_error(*args):
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)", elem_id="main-title")
31
 
32
- # The logo file component is now hidden
33
- logo_file = gr.File("DeepV_logo.png", visible=False)
34
-
35
  with gr.Row():
36
  with gr.Column(scale=2):
37
  with gr.Row():
@@ -74,11 +83,15 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
74
  )
75
 
76
  with gr.Column(scale=3):
77
- # The logo is now an HTML component for maximum style control
78
- # The HTML source is dynamically updated
79
- logo_html = gr.HTML(
80
- "<div id='deepv-logo-container'><img id='deepv-logo' src='' alt='DeepV Logo'></div>"
81
- )
 
 
 
 
82
 
83
  out_code = gr.Textbox(
84
  label="Generated Verilog",
@@ -95,19 +108,7 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
95
  value="Clear All",
96
  components=[spec, out_code, temperature_tb, top_p_tb, max_new_tokens_tb]
97
  )
98
-
99
- # --- Dynamic Logo Update ---
100
- demo.load(
101
- lambda path: gr.HTML(f"""
102
- <div id='deepv-logo-container'>
103
- <img id='deepv-logo' src='file={path}' alt='DeepV Logo'>
104
- </div>
105
- """),
106
- inputs=logo_file,
107
- outputs=logo_html,
108
- show_progress=False
109
- )
110
-
111
  # --- Wrapper function to handle output from the generation agent ---
112
  def generate_only(
113
  spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens
 
2
  import gradio as gr
3
  from huggingface_hub import hf_hub_download
4
  import importlib.util
5
+ import base64
6
 
7
  # --- Private Repository Information ---
8
  PRIVATE_DATASET_ID = os.getenv("PRIVATE_DATASET_ID")
 
26
  def show_error(*args):
27
  return f"// ERROR: Failed to load core agent code. Details: {e}", "", ""
28
 
29
+ # --- Base64 Encoding for Logo ---
30
+ def get_logo_base64():
31
+ try:
32
+ with open("DeepV_logo.png", "rb") as image_file:
33
+ return base64.b64encode(image_file.read()).decode("utf-8")
34
+ except FileNotFoundError:
35
+ print("Logo file not found. Ensure DeepV_logo.png is in the correct directory.")
36
+ return ""
37
+
38
+ logo_base64 = get_logo_base64()
39
+
40
  # --- Gradio UI setup below ---
41
  with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) as demo:
42
  gr.Markdown("## DeepV for RTL Code Generation — Model-Agnostic (Bring Your Own API Key)", elem_id="main-title")
43
 
 
 
 
44
  with gr.Row():
45
  with gr.Column(scale=2):
46
  with gr.Row():
 
83
  )
84
 
85
  with gr.Column(scale=3):
86
+ # The logo is now embedded directly in the HTML as a Base64 string
87
+ if logo_base64:
88
+ gr.HTML(f"""
89
+ <div id="deepv-logo-container">
90
+ <img id="deepv-logo" src="data:image/png;base64,{logo_base64}" alt="DeepV Logo">
91
+ </div>
92
+ """)
93
+ else:
94
+ gr.Markdown("Logo not found.")
95
 
96
  out_code = gr.Textbox(
97
  label="Generated Verilog",
 
108
  value="Clear All",
109
  components=[spec, out_code, temperature_tb, top_p_tb, max_new_tokens_tb]
110
  )
111
+
 
 
 
 
 
 
 
 
 
 
 
 
112
  # --- Wrapper function to handle output from the generation agent ---
113
  def generate_only(
114
  spec, use_rag, top_k, model_choice, api_key, temperature, top_p, max_new_tokens