seawolf2357 commited on
Commit
54328d4
Β·
verified Β·
1 Parent(s): 980bf52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -289,7 +289,6 @@ css = """
289
  footer {visibility: hidden;}
290
  """
291
 
292
- # Gradio μΈν„°νŽ˜μ΄μŠ€ μˆ˜μ •
293
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as iface:
294
  gr.Markdown("검색어λ₯Ό μž…λ ₯ν•˜κ³  μ›ν•˜λŠ” κ΅­κ°€(67개ꡭ)λ₯Ό μ„ νƒν•˜λ©΄, 검색어와 μΌμΉ˜ν•˜λŠ” 24μ‹œκ°„ 이내 λ‰΄μŠ€λ₯Ό μ΅œλŒ€ 100개 좜λ ₯ν•©λ‹ˆλ‹€.")
295
  gr.Markdown("κ΅­κ°€ 선택후 검색어에 'ν•œκΈ€'을 μž…λ ₯ν•˜λ©΄ ν˜„μ§€ μ–Έμ–΄λ‘œ λ²ˆμ—­λ˜μ–΄ κ²€μƒ‰ν•©λ‹ˆλ‹€. 예: 'Taiwan' κ΅­κ°€ 선택후 'μ‚Όμ„±' μž…λ ₯μ‹œ 'δΈ‰ζ˜Ÿ'으둜 μžλ™ 검색 ")
@@ -299,7 +298,10 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as
299
  query = gr.Textbox(label="검색어")
300
  country = gr.Dropdown(MAJOR_COUNTRIES, label="κ΅­κ°€", value="South Korea")
301
 
302
- # λ²ˆμ—­ κ²°κ³Όλ₯Ό λ³΄μ—¬μ£ΌλŠ” μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€
 
 
 
303
  translated_query_display = gr.Markdown(visible=False)
304
 
305
  search_button = gr.Button("검색", variant="primary")
@@ -326,6 +328,9 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as
326
  })
327
 
328
  def search_and_display(query, country, articles_state, progress=gr.Progress()):
 
 
 
329
  progress(0, desc="검색어 λ²ˆμ—­ 쀑...")
330
 
331
  # 검색어 λ²ˆμ—­
@@ -336,7 +341,10 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as
336
  error_message, articles = serphouse_search(query, country)
337
  progress(0.5, desc="κ²°κ³Ό 처리 쀑...")
338
 
339
- outputs = [gr.update(value=translated_display, visible=True)] # λ²ˆμ—­ κ²°κ³Ό ν‘œμ‹œ
 
 
 
340
 
341
  if error_message:
342
  outputs.append(gr.update(value=error_message, visible=True))
@@ -373,9 +381,18 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as
373
  progress(1.0, desc="μ™„λ£Œ!")
374
  outputs.append(articles_state)
375
  outputs.append(gr.update(visible=False))
 
 
 
 
 
376
  return outputs
377
 
378
- search_outputs = [translated_query_display, gr.Markdown(visible=False)] # λ²ˆμ—­ κ²°κ³Ό μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€
 
 
 
 
379
  for comp in article_components:
380
  search_outputs.extend([comp['group'], comp['title'], comp['image'],
381
  comp['snippet'], comp['info']])
 
289
  footer {visibility: hidden;}
290
  """
291
 
 
292
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, title="NewsAI μ„œλΉ„μŠ€") as iface:
293
  gr.Markdown("검색어λ₯Ό μž…λ ₯ν•˜κ³  μ›ν•˜λŠ” κ΅­κ°€(67개ꡭ)λ₯Ό μ„ νƒν•˜λ©΄, 검색어와 μΌμΉ˜ν•˜λŠ” 24μ‹œκ°„ 이내 λ‰΄μŠ€λ₯Ό μ΅œλŒ€ 100개 좜λ ₯ν•©λ‹ˆλ‹€.")
294
  gr.Markdown("κ΅­κ°€ 선택후 검색어에 'ν•œκΈ€'을 μž…λ ₯ν•˜λ©΄ ν˜„μ§€ μ–Έμ–΄λ‘œ λ²ˆμ—­λ˜μ–΄ κ²€μƒ‰ν•©λ‹ˆλ‹€. 예: 'Taiwan' κ΅­κ°€ 선택후 'μ‚Όμ„±' μž…λ ₯μ‹œ 'δΈ‰ζ˜Ÿ'으둜 μžλ™ 검색 ")
 
298
  query = gr.Textbox(label="검색어")
299
  country = gr.Dropdown(MAJOR_COUNTRIES, label="κ΅­κ°€", value="South Korea")
300
 
301
+ # 검색 μƒνƒœ λ©”μ‹œμ§€ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€
302
+ search_status = gr.Markdown(visible=False)
303
+
304
+ # λ²ˆμ—­ κ²°κ³Όλ₯Ό λ³΄μ—¬μ£ΌλŠ” μ»΄ν¬λ„ŒνŠΈ
305
  translated_query_display = gr.Markdown(visible=False)
306
 
307
  search_button = gr.Button("검색", variant="primary")
 
328
  })
329
 
330
  def search_and_display(query, country, articles_state, progress=gr.Progress()):
331
+ # 검색 μ‹œμž‘ λ©”μ‹œμ§€ ν‘œμ‹œ
332
+ search_status_output = gr.update(value="검색을 μ§„ν–‰μ€‘μž…λ‹ˆλ‹€. μž μ‹œλ§Œ κΈ°λ‹€λ¦¬μ„Έμš”...", visible=True)
333
+
334
  progress(0, desc="검색어 λ²ˆμ—­ 쀑...")
335
 
336
  # 검색어 λ²ˆμ—­
 
341
  error_message, articles = serphouse_search(query, country)
342
  progress(0.5, desc="κ²°κ³Ό 처리 쀑...")
343
 
344
+ outputs = [
345
+ search_status_output, # 검색 μƒνƒœ λ©”μ‹œμ§€
346
+ gr.update(value=translated_display, visible=True) # λ²ˆμ—­ κ²°κ³Ό ν‘œμ‹œ
347
+ ]
348
 
349
  if error_message:
350
  outputs.append(gr.update(value=error_message, visible=True))
 
381
  progress(1.0, desc="μ™„λ£Œ!")
382
  outputs.append(articles_state)
383
  outputs.append(gr.update(visible=False))
384
+
385
+ # 검색 μ™„λ£Œ ν›„ μƒνƒœ λ©”μ‹œμ§€ μˆ¨κΉ€
386
+ search_status_output = gr.update(visible=False)
387
+ outputs[0] = search_status_output
388
+
389
  return outputs
390
 
391
+ search_outputs = [
392
+ search_status, # 검색 μƒνƒœ λ©”μ‹œμ§€ 좜λ ₯ μΆ”κ°€
393
+ translated_query_display,
394
+ gr.Markdown(visible=False)
395
+ ]
396
  for comp in article_components:
397
  search_outputs.extend([comp['group'], comp['title'], comp['image'],
398
  comp['snippet'], comp['info']])