NLong commited on
Commit
d085bec
·
verified ·
1 Parent(s): 9af0c15

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -542,7 +542,7 @@ def analyze_news(news_text):
542
  """Main analysis function combining all three tools"""
543
  try:
544
  if not news_text.strip():
545
- return "Vui lòng nhập tin tức cần phân tích.", "0%", "0%", "Chưa dữ liệu"
546
 
547
  print(f"Analyzing: {news_text[:50]}...")
548
 
@@ -627,12 +627,12 @@ def analyze_news(news_text):
627
  **Fake**: {fake_confidence:.3f}
628
  """
629
 
630
- return detailed_analysis, f"Độ chắc chắn là tin thật: {real_confidence:.1%}", f"Độ chắc chắn là tin giả: {fake_confidence:.1%}"
631
 
632
  except Exception as e:
633
  error_message = f"Lỗi phân tích tổng thể: {str(e)}"
634
  print(error_message)
635
- return error_message, "Độ chắc chắn là tin thật: 0%", "Độ chắc chắn là tin giả: 0%"
636
 
637
  # --- GRADIO INTERFACE ---
638
  def create_interface():
@@ -659,18 +659,18 @@ def create_interface():
659
 
660
  analyze_btn = gr.Button(" Phân tích với AI nâng cao", variant="primary", size="lg")
661
 
662
- with gr.Column(scale=1):
663
  gr.Markdown("### Kết quả phân tích")
664
  real_confidence = gr.Label("Độ chắc chắn là tin thật", value="Độ chắc chắn là tin thật: 0%")
665
  fake_confidence = gr.Label("Độ chắc chắn là tin giả", value="Độ chắc chắn là tin giả: 0%")
666
 
667
- detailed_analysis = gr.Markdown("### Phân tích chi tiết sẽ hiển thị ở đây...")
668
 
669
  # Event handlers
670
  analyze_btn.click(
671
  fn=analyze_news,
672
  inputs=[news_input],
673
- outputs=[detailed_analysis, real_confidence, fake_confidence]
674
  )
675
 
676
 
 
542
  """Main analysis function combining all three tools"""
543
  try:
544
  if not news_text.strip():
545
+ return gr.update(value="Vui lòng nhập tin tức cần phân tích.", visible=True), "Độ chắc chắn là tin thật: 0%", "Độ chắc chắn là tin giả: 0%", gr.update(visible=False)
546
 
547
  print(f"Analyzing: {news_text[:50]}...")
548
 
 
627
  **Fake**: {fake_confidence:.3f}
628
  """
629
 
630
+ return gr.update(value=detailed_analysis, visible=True), f"Độ chắc chắn là tin thật: {real_confidence:.1%}", f"Độ chắc chắn là tin giả: {fake_confidence:.1%}", gr.update(visible=True)
631
 
632
  except Exception as e:
633
  error_message = f"Lỗi phân tích tổng thể: {str(e)}"
634
  print(error_message)
635
+ return gr.update(value=error_message, visible=True), "Độ chắc chắn là tin thật: 0%", "Độ chắc chắn là tin giả: 0%", gr.update(visible=True)
636
 
637
  # --- GRADIO INTERFACE ---
638
  def create_interface():
 
659
 
660
  analyze_btn = gr.Button(" Phân tích với AI nâng cao", variant="primary", size="lg")
661
 
662
+ with gr.Column(scale=1, visible=False) as results_column:
663
  gr.Markdown("### Kết quả phân tích")
664
  real_confidence = gr.Label("Độ chắc chắn là tin thật", value="Độ chắc chắn là tin thật: 0%")
665
  fake_confidence = gr.Label("Độ chắc chắn là tin giả", value="Độ chắc chắn là tin giả: 0%")
666
 
667
+ detailed_analysis = gr.Markdown("### Phân tích chi tiết sẽ hiển thị ở đây...", visible=False)
668
 
669
  # Event handlers
670
  analyze_btn.click(
671
  fn=analyze_news,
672
  inputs=[news_input],
673
+ outputs=[detailed_analysis, real_confidence, fake_confidence, results_column]
674
  )
675
 
676