slenk commited on
Commit
ad1a51d
·
verified ·
1 Parent(s): c406285

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -223,7 +223,12 @@ def generate_spec(
223
  )
224
 
225
  generated = outputs[0][input_len:]
226
- return tokenizer.decode(generated, skip_special_tokens=True)
 
 
 
 
 
227
 
228
  except Exception as e:
229
  return (
@@ -236,20 +241,8 @@ def generate_spec(
236
 
237
 
238
  def create_app():
239
- custom_css = """
240
- .sticky-bar {
241
- position: sticky;
242
- top: 0;
243
- z-index: 100;
244
- background: var(--background-fill-primary);
245
- padding: 8px 0;
246
- border-bottom: 1px solid var(--border-color-primary);
247
- }
248
- """
249
-
250
  with gr.Blocks(
251
  title="CodeWraith - Module-to-Spec Transformer",
252
- css=custom_css,
253
  ) as app:
254
  gr.Markdown(
255
  "# CodeWraith\n"
@@ -268,7 +261,7 @@ def create_app():
268
  temperature = gr.Slider(0.0, 2.0, value=0.7, step=0.1, label="Temperature")
269
  top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p")
270
  max_tokens = gr.Slider(256, 8192, value=2048, step=256, label="Max Tokens")
271
- with gr.Row(elem_classes="sticky-bar"):
272
  use_rag = gr.Checkbox(value=True, label="Use RAG (retrieve similar examples)")
273
  generate_btn = gr.Button("Generate Specification", variant="primary")
274
  clear_btn = gr.Button("Clear", variant="secondary")
 
223
  )
224
 
225
  generated = outputs[0][input_len:]
226
+ result = tokenizer.decode(generated, skip_special_tokens=True)
227
+
228
+ # Replace mermaid blocks with plain text to avoid Gradio rendering errors
229
+ result = result.replace("```mermaid", "```")
230
+
231
+ return result
232
 
233
  except Exception as e:
234
  return (
 
241
 
242
 
243
  def create_app():
 
 
 
 
 
 
 
 
 
 
 
244
  with gr.Blocks(
245
  title="CodeWraith - Module-to-Spec Transformer",
 
246
  ) as app:
247
  gr.Markdown(
248
  "# CodeWraith\n"
 
261
  temperature = gr.Slider(0.0, 2.0, value=0.7, step=0.1, label="Temperature")
262
  top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p")
263
  max_tokens = gr.Slider(256, 8192, value=2048, step=256, label="Max Tokens")
264
+ with gr.Row():
265
  use_rag = gr.Checkbox(value=True, label="Use RAG (retrieve similar examples)")
266
  generate_btn = gr.Button("Generate Specification", variant="primary")
267
  clear_btn = gr.Button("Clear", variant="secondary")