alwaysgood commited on
Commit
7646174
·
verified ·
1 Parent(s): c96958c

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +21 -22
ui.py CHANGED
@@ -4,39 +4,38 @@ from config import STATIONS
4
  from supabase_utils import get_supabase_client
5
 
6
  def create_ui(prediction_handler, chatbot_handler):
7
- """Gradio UI 생성하고 반환합니다."""
8
- with gr.Blocks(title="통합 조위 예측 시스템", theme=gr.themes.Soft()) as demo:
9
- gr.Markdown("# 🌊 통합 조위 예측 시스템 with Gemini")
 
10
 
11
- # 연결 상태 표시
12
- client = get_supabase_client()
13
- supabase_status = "🟢 연결됨" if client else "🔴 연결 안됨 (환경변수 확인 필요)"
14
- gemini_status = "🟢 연결됨" if os.getenv("GEMINI_API_KEY") else "🔴 연결 안됨 (환경변수 확인 필요)"
15
- gr.Markdown(f"**Supabase 상태**: {supabase_status} | **Gemini 상태**: {gemini_status}")
16
 
17
  with gr.Tabs():
18
- with gr.TabItem("통합 조위 예측"):
19
  with gr.Row():
20
  with gr.Column(scale=1):
21
- station_id_input = gr.Dropdown(STATIONS, label="관측소 선택", value="DT_0001")
22
- input_csv = gr.File(label="과거 데이터 업로드 (.csv)")
23
- predict_btn = gr.Button("예측 실행", variant="primary")
24
  with gr.Column(scale=3):
25
- output_plot = gr.Plot(label="예측 결과 시각화")
26
- output_df = gr.DataFrame(label="예측 결과 데이터")
27
- output_log = gr.Textbox(label="실행 로그", lines=5, interactive=False)
28
 
29
- with gr.TabItem("AI 조위 챗봇"):
30
  gr.ChatInterface(
31
  fn=chatbot_handler,
32
- title="AI 조위 챗봇",
33
- description="조위에 대해 궁금한 점을 물어보세요. (예: '인천 오늘 현재 조위 알려줘')",
34
- #examples=[]
35
  )
36
 
37
  predict_btn.click(
38
  fn=prediction_handler,
39
- inputs=[station_id_input, input_csv],
40
- outputs=[output_plot, output_df, output_log]
41
  )
42
- return demo
 
 
4
  from supabase_utils import get_supabase_client
5
 
6
  def create_ui(prediction_handler, chatbot_handler):
7
+ """Gradio UI for Tide Prediction System."""
8
+ client = get_supabase_client()
9
+ supabase_status = "🟢 Connected" if client else "🔴 Disconnected (Check env variables)"
10
+ gemini_status = "🟢 Connected" if os.getenv("GEMINI_API_KEY") else "🔴 Disconnected (Check env variables)"
11
 
12
+ with gr.Blocks(title="Tide Prediction System", theme=gr.themes.Default()) as demo:
13
+ gr.Markdown("# 🌊 Tide Prediction System")
14
+ gr.Markdown(f"**Supabase**: {supabase_status} | **Gemini**: {gemini_status}")
 
 
15
 
16
  with gr.Tabs():
17
+ with gr.TabItem("Tide Prediction"):
18
  with gr.Row():
19
  with gr.Column(scale=1):
20
+ station = gr.Dropdown(choices=STATIONS, label="Station", value="DT_0001")
21
+ csv_file = gr.File(label="Historical Data (.csv)")
22
+ predict_btn = gr.Button("Run Prediction", variant="primary")
23
  with gr.Column(scale=3):
24
+ plot_output = gr.Plot(label="Prediction Visualization")
25
+ df_output = gr.DataFrame(label="Prediction Data")
26
+ log_output = gr.Textbox(label="Execution Log", interactive=False)
27
 
28
+ with gr.TabItem("AI Tide Chatbot"):
29
  gr.ChatInterface(
30
  fn=chatbot_handler,
31
+ title="AI Tide Chatbot",
32
+ description="Ask about tide information (e.g., 'What's the current tide in Incheon?')"
 
33
  )
34
 
35
  predict_btn.click(
36
  fn=prediction_handler,
37
+ inputs=[station, csv_file],
38
+ outputs=[plot_output, df_output, log_output]
39
  )
40
+
41
+ return demo