""" Ko-FreshQA Leaderboard 메인 애플리케이션 Gradio 기반의 웹 인터페이스를 제공합니다. """ import os import gradio as gr from config import Config from ui.leaderboard_tab import create_leaderboard_tab from ui.submission_tab import create_submission_tab from ui.dataset_tab import create_dataset_tab def load_css(): """CSS 파일 로드""" current_dir = os.path.dirname(os.path.abspath(__file__)) css_path = os.path.join(current_dir, 'ui', 'styles.css') try: with open(css_path, 'r', encoding='utf-8') as f: return f.read() except FileNotFoundError: print("⚠️ CSS 파일을 찾을 수 없습니다: {css_path}") raise FileNotFoundError(f"CSS 파일을 찾을 수 없습니다: {css_path}") def create_interface(): """메인 인터페이스 생성""" css_content = load_css() with gr.Blocks( title="Ko-FreshQA Leaderboard" ) as app: gr.HTML(f"") gr.Markdown("# Ko-FreshQA Leaderboard") with gr.Tabs(): # 리더보드 탭 with gr.Tab("🏆 리더보드"): # ✅ 리더보드 컴포넌트와 새로고침 함수 받아오기 relaxed_table, strict_table, refresh_leaderboard = create_leaderboard_tab() # 제출 및 평가 탭 with gr.Tab("📤 제출 및 평가"): create_submission_tab() # 데이터셋 다운로드 탭 with gr.Tab("💾 데이터셋"): create_dataset_tab() # ✅ 앱이 로드될 때마다(사용자가 페이지 처음 열 때마다) 한 번 자동으로 새로고침 app.load( fn=refresh_leaderboard, inputs=None, outputs=[relaxed_table, strict_table], ) return app def main(): """메인 실행 함수""" print("🇰🇷 한국어 FreshQA 리더보드 시작 중...") print("📋 리더보드 제출을 위해서는 '📤 제출 및 평가' 탭을 사용하세요.") # 필수 설정 검증 try: Config.validate_required_configs() print("✅ 필수 설정 검증 완료") except ValueError as e: print(f"❌ 설정 오류: {e}") import sys sys.exit(1) app = create_interface() # Hugging Face Spaces 환경 감지 is_huggingface_spaces = Config.IS_HUGGINGFACE_SPACES if is_huggingface_spaces: print("🚀 Hugging Face Spaces 환경에서 실행 중...") app.launch( server_name="0.0.0.0", server_port=7860, share=False, debug=False, show_error=True, theme=gr.themes.Soft() ) else: print("💻 로컬 환경에서 실행 중...") app.launch( server_name="127.0.0.1", server_port=7860, share=False, debug=True, show_error=True, theme=gr.themes.Soft() ) if __name__ == "__main__": main()