Luigi commited on
Commit
d183913
·
verified ·
1 Parent(s): d2eff3b

Fix language switching err

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -187,8 +187,8 @@ def create_interface():
187
  interactive=True
188
  )
189
 
190
- # Main interface components
191
- title_md = gr.Markdown("# Restaurant Reservation Info Extractor")
192
  description_md = gr.Markdown("Use AI to automatically extract reservation information from messages")
193
 
194
  with gr.Row():
@@ -202,6 +202,7 @@ def create_interface():
202
 
203
  examples_title_md = gr.Markdown("### Examples")
204
  chinese_examples_title_md = gr.Markdown("### Chinese Examples")
 
205
  gr.Examples(
206
  examples=chinese_examples,
207
  inputs=input_text,
@@ -223,8 +224,9 @@ def create_interface():
223
  lines=3
224
  )
225
 
226
- # Info panel
227
- with gr.Accordion("ℹ️ Instructions", open=False) as instructions_accordion:
 
228
  instructions_md = gr.Markdown("""**Supported information:**
229
  - 👥 Number of people (num_people)
230
  - 📅 Reservation date/time (reservation_date)
@@ -248,7 +250,7 @@ def create_interface():
248
  texts['button_text'], # submit_btn
249
  gr.update(label=texts['json_label']), # json_output
250
  gr.update(label=texts['raw_label']), # raw_output
251
- texts['instructions_title'], # instructions_accordion
252
  texts['instructions'], # instructions_md
253
  texts['footer'], # footer_md
254
  f"### {texts['examples_title']}", # examples_title_md
@@ -274,8 +276,8 @@ def create_interface():
274
  submit_btn,
275
  json_output,
276
  raw_output,
277
- instructions_accordion,
278
- instructions_md,
279
  footer_md,
280
  examples_title_md,
281
  chinese_examples_title_md,
 
187
  interactive=True
188
  )
189
 
190
+ # Create components that will be updated based on language
191
+ title_md = gr.Markdown("# 🍽️ Restaurant Reservation Info Extractor")
192
  description_md = gr.Markdown("Use AI to automatically extract reservation information from messages")
193
 
194
  with gr.Row():
 
202
 
203
  examples_title_md = gr.Markdown("### Examples")
204
  chinese_examples_title_md = gr.Markdown("### Chinese Examples")
205
+ # Examples components don't need updates as they are static
206
  gr.Examples(
207
  examples=chinese_examples,
208
  inputs=input_text,
 
224
  lines=3
225
  )
226
 
227
+ # Info panel - Accordion is created separately from its content
228
+ instructions_accordion = gr.Accordion("ℹ️ Instructions", open=False)
229
+ with instructions_accordion:
230
  instructions_md = gr.Markdown("""**Supported information:**
231
  - 👥 Number of people (num_people)
232
  - 📅 Reservation date/time (reservation_date)
 
250
  texts['button_text'], # submit_btn
251
  gr.update(label=texts['json_label']), # json_output
252
  gr.update(label=texts['raw_label']), # raw_output
253
+ texts['instructions_title'], # instructions_accordion label
254
  texts['instructions'], # instructions_md
255
  texts['footer'], # footer_md
256
  f"### {texts['examples_title']}", # examples_title_md
 
276
  submit_btn,
277
  json_output,
278
  raw_output,
279
+ instructions_accordion, # This updates the Accordion label
280
+ instructions_md, # This updates the Markdown inside Accordion
281
  footer_md,
282
  examples_title_md,
283
  chinese_examples_title_md,