lewtun HF staff commited on
Commit
b7b16e5
1 Parent(s): a6d4212

Fix bug with empty inputs

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +6 -31
.gitignore CHANGED
@@ -158,3 +158,5 @@ cython_debug/
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
  #.idea/
 
 
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
  #.idea/
161
+
162
+ data/
app.py CHANGED
@@ -19,14 +19,6 @@ client = Client(
19
  headers={"Authorization": f"Bearer {API_TOKEN}"},
20
  )
21
 
22
- # theme = gr.themes.Monochrome(
23
- # primary_hue="indigo",
24
- # secondary_hue="blue",
25
- # neutral_hue="slate",
26
- # radius_size=gr.themes.sizes.radius_sm,
27
- # font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
28
- # )
29
-
30
  if HF_TOKEN:
31
  try:
32
  shutil.rmtree("./data/")
@@ -84,7 +76,7 @@ def generate(
84
  ):
85
  # Don't return meaningless message when the input is empty
86
  if not user_message:
87
- return chatbot, history, user_message, ""
88
 
89
  history.append(user_message)
90
 
@@ -284,10 +276,10 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
284
  interactive=True,
285
  info="The parameter for repetition penalty. 1.0 means no penalty.",
286
  )
287
- # with gr.Group(elem_id="share-btn-container"):
288
- # community_icon = gr.HTML(community_icon_html, visible=True)
289
- # loading_icon = gr.HTML(loading_icon_html, visible=True)
290
- # share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
291
  with gr.Row():
292
  gr.Examples(
293
  examples=examples,
@@ -336,23 +328,6 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
336
  )
337
 
338
  clear_chat_button.click(clear_chat, outputs=[chatbot, history])
339
- # share_button.click(None, [], [], _js=share_js)
340
- # with gr.Row():
341
- # with gr.Column():
342
- # gr.Image("StarCoderBanner.png", elem_id="banner-image", show_label=False)
343
- # with gr.Column():
344
- # gr.Markdown(
345
- # """
346
- # 💻 This demo showcases an instruction fine-tuned model based on **[StarCoder](https://huggingface.co/bigcode/starcoder)**, a 16B parameter model trained on one trillion tokens sourced from 80+ programming languages, GitHub issues, Git commits, and Jupyter notebooks (all permissively licensed).
347
-
348
- # 🤗 With an enterprise-friendly license, 8,192 token context length, and fast large-batch inference via [multi-query attention](https://arxiv.org/abs/1911.02150), **StarCoder** is currently the best open-source choice for code-based applications.
349
-
350
- # 📝 For more details, check out our [blog post]().
351
-
352
- # ⚠️ **Intended Use**: this app and its [supporting model](https://huggingface.co/HuggingFaceH4/starcoderbase-finetuned-oasst1) are provided as educational tools to explain instruction fine-tuning; not to serve as replacement for human expertise. For more details on the model's limitations in terms of factuality and biases, see the [model card](https://huggingface.co/HuggingFaceH4/starcoderbase-finetuned-oasst1#bias-risks-and-limitations).
353
-
354
- # ⚠️ **Data Collection**: by default, we are collecting the prompts entered in this app to further improve and evaluate the model. Do NOT share any personal or sensitive information while using the app! You can opt out of this data collection by removing the checkbox below.
355
- # """
356
- # )
357
 
358
  demo.queue(concurrency_count=16).launch(debug=True)
19
  headers={"Authorization": f"Bearer {API_TOKEN}"},
20
  )
21
 
 
 
 
 
 
 
 
 
22
  if HF_TOKEN:
23
  try:
24
  shutil.rmtree("./data/")
76
  ):
77
  # Don't return meaningless message when the input is empty
78
  if not user_message:
79
+ print("Empty input")
80
 
81
  history.append(user_message)
82
 
276
  interactive=True,
277
  info="The parameter for repetition penalty. 1.0 means no penalty.",
278
  )
279
+ with gr.Group(elem_id="share-btn-container"):
280
+ community_icon = gr.HTML(community_icon_html, visible=True)
281
+ loading_icon = gr.HTML(loading_icon_html, visible=True)
282
+ share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
283
  with gr.Row():
284
  gr.Examples(
285
  examples=examples,
328
  )
329
 
330
  clear_chat_button.click(clear_chat, outputs=[chatbot, history])
331
+ share_button.click(None, [], [], _js=share_js)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
  demo.queue(concurrency_count=16).launch(debug=True)