my-tide-env / app_hf.py
alwaysgood's picture
Update app_hf.py
bbbed95 verified
# app_hf.py - HF Spaces 1단계: Gradio Only
import warnings
import os
from dotenv import load_dotenv
import gradio as gr
# .env 파일에서 환경 변수 로드
load_dotenv()
# --- 기본 모듈 import ---
from prediction import single_prediction
from chatbot import process_chatbot_query_with_llm
from ui import create_ui
# --- API 유틸리티 함수 가져오기 (UI 내부에서만 사용) ---
from api_utils import (
api_get_tide_level,
api_get_tide_series,
api_get_extremes_info,
api_check_tide_alert,
api_compare_stations,
api_health_check
)
# --- 경고 무시 ---
warnings.filterwarnings('ignore')
# --- API 핸들러 준비 (UI 내부에서만 사용) ---
api_handlers = {
"health": api_health_check,
"tide_level": api_get_tide_level,
"tide_series": api_get_tide_series,
"extremes": api_get_extremes_info,
"alert": api_check_tide_alert,
"compare": api_compare_stations
}
print("🌊 조위 예측 시스템 초기화 중 (Gradio Only)")
# --- Gradio UI 생성 ---
demo = create_ui(
prediction_handler=single_prediction,
chatbot_handler=process_chatbot_query_with_llm,
api_handlers=api_handlers
)
print("✅ Gradio UI 생성 완료")
# --- 실행 ---
if __name__ == "__main__":
print("🤗 HF Spaces 1단계 - Gradio 전용")
print("🔗 UI 작동 확인 후 app.py로 교체하세요")
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
show_error=True
)