slenk commited on
Commit
0a1f3da
·
verified ·
1 Parent(s): 1c4d535

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +1 -0
  2. app.py +7 -3
README.md CHANGED
@@ -6,6 +6,7 @@ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 6.11.0
8
  app_file: app.py
 
9
  pinned: false
10
  license: mit
11
  ---
 
6
  sdk: gradio
7
  sdk_version: 6.11.0
8
  app_file: app.py
9
+ python_version: "3.12"
10
  pinned: false
11
  license: mit
12
  ---
app.py CHANGED
@@ -194,9 +194,7 @@ def generate_spec(
194
  {"role": "user", "content": user_content},
195
  ]
196
 
197
- input_text = tokenizer.apply_chat_template(
198
- messages, tokenize=False, add_generation_prompt=True
199
- )
200
  inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
201
  input_len = inputs["input_ids"].shape[-1]
202
 
@@ -244,7 +242,13 @@ def create_app():
244
  with gr.Column(scale=1):
245
  spec_output = gr.Markdown(label="Generated Specification")
246
 
 
 
 
247
  generate_btn.click(
 
 
 
248
  fn=generate_spec,
249
  inputs=[code_input, temperature, top_p, max_tokens, use_rag],
250
  outputs=spec_output,
 
194
  {"role": "user", "content": user_content},
195
  ]
196
 
197
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
 
 
198
  inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
199
  input_len = inputs["input_ids"].shape[-1]
200
 
 
242
  with gr.Column(scale=1):
243
  spec_output = gr.Markdown(label="Generated Specification")
244
 
245
+ gr.Markdown("*Model loads on first generation (~30s). Subsequent calls are fast.*")
246
+
247
+ loading_msg = "*Generating specification... (loading model if first run)*"
248
  generate_btn.click(
249
+ fn=lambda: gr.update(value=loading_msg),
250
+ outputs=spec_output,
251
+ ).then(
252
  fn=generate_spec,
253
  inputs=[code_input, temperature, top_p, max_tokens, use_rag],
254
  outputs=spec_output,