Jeronymous commited on
Commit
d2ac09c
1 Parent(s): c78a91c

Let the Additional input accordion open by default

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +19 -1
  3. requirements.txt +2 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🗣️🇫🇷💬
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 4.4.1
8
  app_file: app.py
9
  pinned: true
10
  license: cc-by-nc-sa-4.0
 
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
+ # sdk_version: 4.4.1
8
  app_file: app.py
9
  pinned: true
10
  license: cc-by-nc-sa-4.0
app.py CHANGED
@@ -290,6 +290,7 @@ def generate(
290
 
291
 
292
  def claire_text_preproc_message(text):
 
293
  text = format_special_characters(text)
294
  text = collapse_whitespaces(text)
295
  text = replace_brackets(text)
@@ -307,6 +308,20 @@ def replace_brackets(text):
307
  text = re.sub(r"[\]\}]", ")", text)
308
  return text
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
 
311
  def format_special_characters(text):
312
  text = unicodedata.normalize("NFC", text)
@@ -418,7 +433,10 @@ chat_interface = gr.ChatInterface(
418
  textbox=textbox,
419
  examples=examples,
420
  additional_inputs=additional_inputs,
421
- additional_inputs_accordion_name=additional_inputs_name,
 
 
 
422
  autofocus=False,
423
  **gradio_buttons,
424
  )
 
290
 
291
 
292
  def claire_text_preproc_message(text):
293
+ text = format_punctuations_for_french(text)
294
  text = format_special_characters(text)
295
  text = collapse_whitespaces(text)
296
  text = replace_brackets(text)
 
308
  text = re.sub(r"[\]\}]", ")", text)
309
  return text
310
 
311
+ def format_punctuations_for_french(text):
312
+ for before, after in french_punctuation_rules:
313
+ text = re.sub(before, after, text)
314
+ return text
315
+
316
+ french_punctuation_rules = {
317
+ # Add a space before double punctuation marks
318
+ (r"([" + re.escape('?!:;') + r"])", r" \1"),
319
+ # Remove space before simple punctuation marks
320
+ (r"\s+([" + re.escape(',.') + r"])", r"\1"),
321
+ # Add space after punctuation marks
322
+ (r"([" + re.escape('?!:;,') + r"]+)([^ " + re.escape('?!:;,') + r"\d])", r"\1 \2"),
323
+ (r"([" + re.escape('.') + r"]+)([A-Z])", r"\1 \2"),
324
+ }
325
 
326
  def format_special_characters(text):
327
  text = unicodedata.normalize("NFC", text)
 
433
  textbox=textbox,
434
  examples=examples,
435
  additional_inputs=additional_inputs,
436
+ additional_inputs_accordion=gr.Accordion(
437
+ label="Paramètres",
438
+ open=True,
439
+ ),
440
  autofocus=False,
441
  **gradio_buttons,
442
  )
requirements.txt CHANGED
@@ -1,6 +1,7 @@
1
  accelerate==0.24.1
2
  bitsandbytes==0.41.1
3
- gradio==4.4.1
 
4
  optimum==1.14.1
5
  protobuf==3.20.3
6
  scipy==1.11.2
 
1
  accelerate==0.24.1
2
  bitsandbytes==0.41.1
3
+ #gradio==4.4.1
4
+ git+https://github.com/gradio-app/gradio@1bbd6cab3f0abe183b514b82061f0937c8480966
5
  optimum==1.14.1
6
  protobuf==3.20.3
7
  scipy==1.11.2