File size: 1,505 Bytes
bbbed95
0d5adf0
 
 
 
 
 
 
 
 
 
 
 
 
 
950069a
0d5adf0
 
 
 
 
 
 
 
 
 
 
 
950069a
0d5adf0
 
 
 
 
 
 
 
 
bbbed95
950069a
 
0d5adf0
 
 
 
 
 
 
 
bbbed95
950069a
bbbed95
 
0d5adf0
950069a
 
 
 
bbbed95
950069a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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
    )