Spaces:
Sleeping
Sleeping
Update ui.py
Browse files
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 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 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 |
-
|
| 22 |
-
|
| 23 |
-
predict_btn = gr.Button("
|
| 24 |
with gr.Column(scale=3):
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 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=[
|
| 40 |
-
outputs=[
|
| 41 |
)
|
| 42 |
-
|
|
|
|
|
|
| 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
|