add swmirae4
Browse files
app.py
CHANGED
|
@@ -2,11 +2,7 @@
|
|
| 2 |
# -----------------------------
|
| 3 |
# HF Router Inference API (OpenAI-compatible)
|
| 4 |
# Toss-like UI + "SW λ―Έλ μμ¬νμ" theme
|
| 5 |
-
# Tabs:
|
| 6 |
-
# 1) μμ½Β·μΆμ² (μ¬λ‘― μμ½ + λ§μΆ€ μΆμ²)
|
| 7 |
-
# 2) μ§λ¬ΈνκΈ° (μ±ν
)
|
| 8 |
-
# 3) νμ μκ°
|
| 9 |
-
# 4) μν μ κ²
|
| 10 |
# -----------------------------
|
| 11 |
|
| 12 |
import os, json, time, requests, gradio as gr
|
|
@@ -17,7 +13,7 @@ from datetime import datetime, timedelta
|
|
| 17 |
# Config
|
| 18 |
# =========================
|
| 19 |
API_BASE = os.getenv("HF_ENDPOINT_URL") or "https://router.huggingface.co/v1" # OpenAI-compatible Router
|
| 20 |
-
MODEL_QA = os.getenv("HF_MODEL_ID") or "Qwen/Qwen2.5-7B-Instruct"
|
| 21 |
HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 22 |
TIMEOUT_S = 60
|
| 23 |
|
|
@@ -33,7 +29,6 @@ KWDAYS = ["μ", "ν", "μ", "λͺ©", "κΈ", "ν ", "μΌ"]
|
|
| 33 |
# =========================
|
| 34 |
def hf_chat(model: str, messages: list, temperature: float = 0.2, max_tokens: int = 256,
|
| 35 |
timeout: int = TIMEOUT_S, retries: int = 3) -> str:
|
| 36 |
-
"""Call HF Router /v1/chat/completions with basic retry/backoff."""
|
| 37 |
if not HF_TOKEN:
|
| 38 |
return "β οΈ HF_TOKENμ΄ μμ΅λλ€. νκ²½λ³μμ HF_TOKENμ μ€μ νμΈμ."
|
| 39 |
headers = {"Authorization": f"Bearer {HF_TOKEN}", "Content-Type": "application/json"}
|
|
@@ -79,7 +74,6 @@ def save_reservations(resv: List[Dict[str, Any]]) -> None:
|
|
| 79 |
os.replace(tmp, RESV_FILE)
|
| 80 |
|
| 81 |
def make_slots(start: datetime | None = None, days: int = SLOT_DAYS_AHEAD) -> List[str]:
|
| 82 |
-
"""Return list like 'YYYY-MM-DD HH:MM (μμΌ)' for open slots (Mon-Sat only)."""
|
| 83 |
now = datetime.now()
|
| 84 |
base = start or now
|
| 85 |
out = []
|
|
@@ -95,12 +89,10 @@ def booked_slots() -> set:
|
|
| 95 |
return {item["slot"] for item in load_reservations()}
|
| 96 |
|
| 97 |
def available_slots() -> List[str]:
|
| 98 |
-
# remove already booked
|
| 99 |
bset = booked_slots()
|
| 100 |
return [s for s in make_slots() if s not in bset]
|
| 101 |
|
| 102 |
-
def
|
| 103 |
-
# For Dataframe display
|
| 104 |
rows = []
|
| 105 |
for r in sorted(resv, key=lambda x: x.get("slot", "")):
|
| 106 |
rows.append([
|
|
@@ -116,12 +108,11 @@ def resv_to_rows(resv: List[Dict[str, Any]]) -> List[List[str]]:
|
|
| 116 |
return rows
|
| 117 |
|
| 118 |
# =========================
|
| 119 |
-
# Recommendation
|
| 120 |
# =========================
|
| 121 |
def recommend_plan(grade: str, focuses: List[str], level: str, goals: str,
|
| 122 |
weeks: int, hours_per_week: int, constraints: str,
|
| 123 |
temperature: float, max_tokens: int) -> str:
|
| 124 |
-
"""Create a tailored plan via LLM. Falls back to rule-based if LLM fails."""
|
| 125 |
focus_str = ", ".join(focuses) if focuses else "μΌλ°"
|
| 126 |
user_profile = (
|
| 127 |
f"- νλ
: {grade}\n- κ΄μ¬ λΆμΌ: {focus_str}\n- μμ€: {level}\n"
|
|
@@ -139,7 +130,7 @@ def recommend_plan(grade: str, focuses: List[str], level: str, goals: str,
|
|
| 139 |
"\n\nνμ:\n"
|
| 140 |
"1) ν μ€ μμ½\n"
|
| 141 |
"2) μ£Όμ°¨λ³ κ³ν(μ£Όμ°¨/νμ΅λͺ©ν/νλ/κ³Όμ )\n"
|
| 142 |
-
"3) μΆμ² κ΅μ¬/ν΄(κ°λ¨ λ§ν¬λͺ
λ§, μ€μ URL
|
| 143 |
"4) μμ κ²°κ³Όλ¬Ό(ν¬νΈν΄λ¦¬μ€/λν/μ격μ¦)\n"
|
| 144 |
"5) λ€μ μμ½ μ μ(체ν μμ
1ν + μ κ· κ³Όμ )\n"
|
| 145 |
"λ¬Έμ₯ μ§§κ². λΆνμν μμμ΄ κΈμ§."
|
|
@@ -150,7 +141,6 @@ def recommend_plan(grade: str, focuses: List[str], level: str, goals: str,
|
|
| 150 |
]
|
| 151 |
out = hf_chat(MODEL_QA, msgs, temperature=temperature, max_tokens=max_tokens)
|
| 152 |
if out.startswith("β") or out.startswith("β οΈ"):
|
| 153 |
-
# Fallback (κ°λ¨ κ·μΉ)
|
| 154 |
rec = f"""[κ°λ¨ μΆμ²μ β Fallback]
|
| 155 |
ν μ€ μμ½: {grade} λμ {focus_str} {level} κ³Όμ , {weeks}μ£Ό, μ£Ό {hours_per_week}μκ°.
|
| 156 |
|
|
@@ -200,27 +190,26 @@ def reset_chat():
|
|
| 200 |
return [], []
|
| 201 |
|
| 202 |
# =========================
|
| 203 |
-
# Booking handlers
|
| 204 |
# =========================
|
| 205 |
-
def
|
| 206 |
-
return available_slots()
|
| 207 |
|
| 208 |
def submit_booking(name: str, grade: str, focuses: List[str], level: str,
|
| 209 |
-
contact: str, slot: str, notes: str)
|
| 210 |
name = (name or "").strip()
|
| 211 |
contact = (contact or "").strip()
|
| 212 |
slot = (slot or "").strip()
|
| 213 |
focus_str = ", ".join(focuses) if focuses else "μΌλ°"
|
| 214 |
|
| 215 |
if not name:
|
| 216 |
-
return "β οΈ μ΄λ¦μ μ
λ ₯νμΈμ."
|
| 217 |
if not contact:
|
| 218 |
-
return "β οΈ μ°λ½μ²(μ ν/μΉ΄μΉ΄μ€/μ΄λ©μΌ) μ
λ ₯νμΈμ."
|
| 219 |
if not slot:
|
| 220 |
-
return "β οΈ μμ½ μ¬λ‘―μ μ ννμΈμ."
|
| 221 |
-
# re-check conflict
|
| 222 |
if slot in booked_slots():
|
| 223 |
-
return "β μ΄λ―Έ μμ½λ μ¬λ‘―μ
λλ€. λ€λ₯Έ μκ°μ μ ννμΈμ."
|
| 224 |
|
| 225 |
resv = load_reservations()
|
| 226 |
item = {
|
|
@@ -235,13 +224,9 @@ def submit_booking(name: str, grade: str, focuses: List[str], level: str,
|
|
| 235 |
}
|
| 236 |
resv.append(item)
|
| 237 |
save_reservations(resv)
|
| 238 |
-
return f"β
μμ½ μλ£: {slot} Β· {name} ({grade}, {focus_str}/{level}) β λ΄λΉμκ° κ³§ μ°λ½λ립λλ€."
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
resv = load_reservations()
|
| 242 |
-
header = ["μ¬λ‘―", "μ΄λ¦", "νλ
", "κ΄μ¬ λΆμΌ", "λ 벨", "μ°λ½μ²", "λΉκ³ ", "μμ½μκ°"]
|
| 243 |
-
rows = resv_to_rows(resv)
|
| 244 |
-
return [header] + rows if rows else [header]
|
| 245 |
|
| 246 |
# =========================
|
| 247 |
# Health check
|
|
@@ -306,12 +291,10 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 306 |
""")
|
| 307 |
|
| 308 |
with gr.Tabs():
|
| 309 |
-
# =========================
|
| 310 |
# 1) μμ½Β·μΆμ²
|
| 311 |
-
# =========================
|
| 312 |
with gr.Tab("μμ½ Β· μΆμ²"):
|
| 313 |
with gr.Row():
|
| 314 |
-
#
|
| 315 |
with gr.Column(scale=5):
|
| 316 |
with gr.Group(elem_classes=["toss-card", "toss-input"]):
|
| 317 |
gr.Markdown("### λ§μΆ€ μΆμ²")
|
|
@@ -322,7 +305,7 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 322 |
label="κ΄μ¬ λΆμΌ", value=["νμ΄μ¬"]
|
| 323 |
)
|
| 324 |
level = gr.Radio(["μ
λ¬Έ", "κΈ°μ΄", "μ€κΈ", "μ¬ν"], value="κΈ°μ΄", label="μμ€")
|
| 325 |
-
goals = gr.Textbox(label="λͺ©ν(μ: λν μ
μ/μ격μ¦/ν¬νΈν΄λ¦¬μ€/
|
| 326 |
with gr.Row():
|
| 327 |
weeks = gr.Slider(2, 16, value=8, step=1, label="κΈ°κ°(μ£Ό)")
|
| 328 |
hpw = gr.Slider(1, 6, value=2, step=1, label="μ£ΌλΉ μκ°(μκ°)")
|
|
@@ -334,7 +317,7 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 334 |
with gr.Group(elem_classes=["toss-card"]):
|
| 335 |
rec_out = gr.Textbox(label="μΆμ² κ²°κ³Ό", lines=18)
|
| 336 |
|
| 337 |
-
#
|
| 338 |
with gr.Column(scale=4):
|
| 339 |
with gr.Group(elem_classes=["toss-card", "toss-input"]):
|
| 340 |
gr.Markdown("### μμ½")
|
|
@@ -354,34 +337,29 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 354 |
btn_book = gr.Button("μμ½ νμ ", elem_classes=["toss-primary"])
|
| 355 |
with gr.Group(elem_classes=["toss-card"]):
|
| 356 |
gr.Markdown("### νμ¬ μμ½ νν©")
|
| 357 |
-
table = gr.Dataframe(
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
| 359 |
res_msg = gr.Markdown("", elem_classes=["toss-note"])
|
| 360 |
|
| 361 |
-
#
|
| 362 |
btn_rec.click(
|
| 363 |
fn=recommend_plan,
|
| 364 |
inputs=[grade, focus, level, goals, weeks, hpw, constraints, r_temp, r_max],
|
| 365 |
outputs=[rec_out],
|
| 366 |
)
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
# Bind: booking
|
| 372 |
-
def _book_and_refresh(name_v, grade_v, focus_v, level_v, contact_v, slot_v, notes_v):
|
| 373 |
-
msg = submit_booking(name_v, grade_v, focus_v, level_v, contact_v, slot_v, notes_v)
|
| 374 |
-
# refresh dropdown + table
|
| 375 |
-
return msg, get_reservation_table(), available_slots()
|
| 376 |
btn_book.click(
|
| 377 |
-
fn=
|
| 378 |
inputs=[name, b_grade, b_focus, b_level, contact, slot, notes],
|
| 379 |
outputs=[res_msg, table, slot],
|
| 380 |
)
|
| 381 |
|
| 382 |
-
# =========================
|
| 383 |
# 2) μ§λ¬ΈνκΈ° (μ±ν
)
|
| 384 |
-
# =========================
|
| 385 |
with gr.Tab("μ§λ¬ΈνκΈ° (μ±ν
)"):
|
| 386 |
chat_history = gr.State([]) # list of (user, assistant)
|
| 387 |
with gr.Row():
|
|
@@ -420,9 +398,7 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 420 |
gr.Markdown('<div class="toss-note">β’ λν κΈ°λ‘μ μ μ±ν
μμμ μμλλ‘ λμ λ©λλ€.'
|
| 421 |
'<br>β’ κ³ΌκΈ μ£Όμ: Router μ¬μ©λ/ν ν°μ λ°λΌ λΉμ©μ΄ λ°μν μ μμ΅λλ€.</div>')
|
| 422 |
|
| 423 |
-
# =========================
|
| 424 |
# 3) νμ μκ°
|
| 425 |
-
# =========================
|
| 426 |
with gr.Tab("νμ μκ°"):
|
| 427 |
with gr.Group(elem_classes=["toss-card"]):
|
| 428 |
gr.Markdown("""
|
|
@@ -440,9 +416,7 @@ with gr.Blocks(title="μ¨ν SWλ―Έλμμ¬μ»΄ν¨ν°νμ β μμ½Β·μΆμ²Β·Q
|
|
| 440 |
> μλ΄/체ν μμ
λ¬Έμλ 'μμ½ Β· μΆμ²' νμμ μ§ννμΈμ.
|
| 441 |
""")
|
| 442 |
|
| 443 |
-
# =========================
|
| 444 |
# 4) μν μ κ²
|
| 445 |
-
# =========================
|
| 446 |
with gr.Tab("μν μ κ²"):
|
| 447 |
with gr.Group(elem_classes=["toss-card"]):
|
| 448 |
diag_btn = gr.Button("μλν¬μΈνΈ μ κ²", elem_classes=["toss-primary"])
|
|
|
|
| 2 |
# -----------------------------
|
| 3 |
# HF Router Inference API (OpenAI-compatible)
|
| 4 |
# Toss-like UI + "SW λ―Έλ μμ¬νμ" theme
|
| 5 |
+
# Tabs: μμ½Β·μΆμ² / μ§λ¬Έ(μ±ν
) / νμ μκ° / μν μ κ²
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# -----------------------------
|
| 7 |
|
| 8 |
import os, json, time, requests, gradio as gr
|
|
|
|
| 13 |
# Config
|
| 14 |
# =========================
|
| 15 |
API_BASE = os.getenv("HF_ENDPOINT_URL") or "https://router.huggingface.co/v1" # OpenAI-compatible Router
|
| 16 |
+
MODEL_QA = os.getenv("HF_MODEL_ID") or "Qwen/Qwen2.5-7B-Instruct" # Provider-attached model
|
| 17 |
HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 18 |
TIMEOUT_S = 60
|
| 19 |
|
|
|
|
| 29 |
# =========================
|
| 30 |
def hf_chat(model: str, messages: list, temperature: float = 0.2, max_tokens: int = 256,
|
| 31 |
timeout: int = TIMEOUT_S, retries: int = 3) -> str:
|
|
|
|
| 32 |
if not HF_TOKEN:
|
| 33 |
return "β οΈ HF_TOKENμ΄ μμ΅λλ€. νκ²½λ³μμ HF_TOKENμ μ€μ νμΈμ."
|
| 34 |
headers = {"Authorization": f"Bearer {HF_TOKEN}", "Content-Type": "application/json"}
|
|
|
|
| 74 |
os.replace(tmp, RESV_FILE)
|
| 75 |
|
| 76 |
def make_slots(start: datetime | None = None, days: int = SLOT_DAYS_AHEAD) -> List[str]:
|
|
|
|
| 77 |
now = datetime.now()
|
| 78 |
base = start or now
|
| 79 |
out = []
|
|
|
|
| 89 |
return {item["slot"] for item in load_reservations()}
|
| 90 |
|
| 91 |
def available_slots() -> List[str]:
|
|
|
|
| 92 |
bset = booked_slots()
|
| 93 |
return [s for s in make_slots() if s not in bset]
|
| 94 |
|
| 95 |
+
def reservation_rows(resv: List[Dict[str, Any]]) -> List[List[str]]:
|
|
|
|
| 96 |
rows = []
|
| 97 |
for r in sorted(resv, key=lambda x: x.get("slot", "")):
|
| 98 |
rows.append([
|
|
|
|
| 108 |
return rows
|
| 109 |
|
| 110 |
# =========================
|
| 111 |
+
# Recommendation
|
| 112 |
# =========================
|
| 113 |
def recommend_plan(grade: str, focuses: List[str], level: str, goals: str,
|
| 114 |
weeks: int, hours_per_week: int, constraints: str,
|
| 115 |
temperature: float, max_tokens: int) -> str:
|
|
|
|
| 116 |
focus_str = ", ".join(focuses) if focuses else "μΌλ°"
|
| 117 |
user_profile = (
|
| 118 |
f"- νλ
: {grade}\n- κ΄μ¬ λΆμΌ: {focus_str}\n- μμ€: {level}\n"
|
|
|
|
| 130 |
"\n\nνμ:\n"
|
| 131 |
"1) ν μ€ μμ½\n"
|
| 132 |
"2) μ£Όμ°¨λ³ κ³ν(μ£Όμ°¨/νμ΅λͺ©ν/νλ/κ³Όμ )\n"
|
| 133 |
+
"3) μΆμ² κ΅μ¬/ν΄(κ°λ¨ λ§ν¬λͺ
λ§, μ€μ URL μλ΅)\n"
|
| 134 |
"4) μμ κ²°κ³Όλ¬Ό(ν¬νΈν΄λ¦¬μ€/λν/μ격μ¦)\n"
|
| 135 |
"5) λ€μ μμ½ μ μ(체ν μμ
1ν + μ κ· κ³Όμ )\n"
|
| 136 |
"λ¬Έμ₯ μ§§κ². λΆνμν μμμ΄ κΈμ§."
|
|
|
|
| 141 |
]
|
| 142 |
out = hf_chat(MODEL_QA, msgs, temperature=temperature, max_tokens=max_tokens)
|
| 143 |
if out.startswith("β") or out.startswith("β οΈ"):
|
|
|
|
| 144 |
rec = f"""[κ°λ¨ μΆμ²μ β Fallback]
|
| 145 |
ν μ€ μμ½: {grade} λμ {focus_str} {level} κ³Όμ , {weeks}μ£Ό, μ£Ό {hours_per_week}μκ°.
|
| 146 |
|
|
|
|
| 190 |
return [], []
|
| 191 |
|
| 192 |
# =========================
|
| 193 |
+
# Booking handlers
|
| 194 |
# =========================
|
| 195 |
+
def refresh_slots_update():
|
| 196 |
+
return gr.update(choices=available_slots(), value=None)
|
| 197 |
|
| 198 |
def submit_booking(name: str, grade: str, focuses: List[str], level: str,
|
| 199 |
+
contact: str, slot: str, notes: str):
|
| 200 |
name = (name or "").strip()
|
| 201 |
contact = (contact or "").strip()
|
| 202 |
slot = (slot or "").strip()
|
| 203 |
focus_str = ", ".join(focuses) if focuses else "μΌλ°"
|
| 204 |
|
| 205 |
if not name:
|
| 206 |
+
return "β οΈ μ΄λ¦μ μ
λ ₯νμΈμ.", reservation_rows(load_reservations()), refresh_slots_update()
|
| 207 |
if not contact:
|
| 208 |
+
return "β οΈ μ°λ½μ²(μ ν/μΉ΄μΉ΄μ€/μ΄λ©μΌ) μ
λ ₯νμΈμ.", reservation_rows(load_reservations()), refresh_slots_update()
|
| 209 |
if not slot:
|
| 210 |
+
return "β οΈ μμ½ μ¬λ‘―μ μ ννμΈμ.", reservation_rows(load_reservations()), refresh_slots_update()
|
|
|
|
| 211 |
if slot in booked_slots():
|
| 212 |
+
return "β μ΄λ―Έ μμ½λ μ¬λ‘―μ
λλ€. λ€λ₯Έ μκ°μ μ ννμΈμ.", reservation_rows(load_reservations()), refresh_slots_update()
|
| 213 |
|
| 214 |
resv = load_reservations()
|
| 215 |
item = {
|
|
|
|
| 224 |
}
|
| 225 |
resv.append(item)
|
| 226 |
save_reservations(resv)
|
| 227 |
+
return (f"β
μμ½ μλ£: {slot} Β· {name} ({grade}, {focus_str}/{level}) β λ΄λΉμκ° κ³§ μ°λ½λ립λλ€.",
|
| 228 |
+
reservation_rows(resv),
|
| 229 |
+
refresh_slots_update())
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
# =========================
|
| 232 |
# Health check
|
|
|
|
| 291 |
""")
|
| 292 |
|
| 293 |
with gr.Tabs():
|
|
|
|
| 294 |
# 1) μμ½Β·μΆμ²
|
|
|
|
| 295 |
with gr.Tab("μμ½ Β· μΆμ²"):
|
| 296 |
with gr.Row():
|
| 297 |
+
# Left: Recommendation
|
| 298 |
with gr.Column(scale=5):
|
| 299 |
with gr.Group(elem_classes=["toss-card", "toss-input"]):
|
| 300 |
gr.Markdown("### λ§μΆ€ μΆμ²")
|
|
|
|
| 305 |
label="κ΄μ¬ λΆμΌ", value=["νμ΄μ¬"]
|
| 306 |
)
|
| 307 |
level = gr.Radio(["μ
λ¬Έ", "κΈ°μ΄", "μ€κΈ", "μ¬ν"], value="κΈ°μ΄", label="μμ€")
|
| 308 |
+
goals = gr.Textbox(label="λͺ©ν(μ: λν μ
μ/μ격μ¦/ν¬νΈν΄λ¦¬μ€/μννκ° λ±)", lines=2)
|
| 309 |
with gr.Row():
|
| 310 |
weeks = gr.Slider(2, 16, value=8, step=1, label="κΈ°κ°(μ£Ό)")
|
| 311 |
hpw = gr.Slider(1, 6, value=2, step=1, label="μ£ΌλΉ μκ°(μκ°)")
|
|
|
|
| 317 |
with gr.Group(elem_classes=["toss-card"]):
|
| 318 |
rec_out = gr.Textbox(label="μΆμ² κ²°κ³Ό", lines=18)
|
| 319 |
|
| 320 |
+
# Right: Booking
|
| 321 |
with gr.Column(scale=4):
|
| 322 |
with gr.Group(elem_classes=["toss-card", "toss-input"]):
|
| 323 |
gr.Markdown("### μμ½")
|
|
|
|
| 337 |
btn_book = gr.Button("μμ½ νμ ", elem_classes=["toss-primary"])
|
| 338 |
with gr.Group(elem_classes=["toss-card"]):
|
| 339 |
gr.Markdown("### νμ¬ μμ½ νν©")
|
| 340 |
+
table = gr.Dataframe(
|
| 341 |
+
headers=["μ¬λ‘―", "μ΄λ¦", "νλ
", "κ΄μ¬ λΆμΌ", "λ 벨", "μ°λ½μ²", "λΉκ³ ", "μμ½μκ°"],
|
| 342 |
+
value=reservation_rows(load_reservations()),
|
| 343 |
+
interactive=False,
|
| 344 |
+
)
|
| 345 |
res_msg = gr.Markdown("", elem_classes=["toss-note"])
|
| 346 |
|
| 347 |
+
# Recommend
|
| 348 |
btn_rec.click(
|
| 349 |
fn=recommend_plan,
|
| 350 |
inputs=[grade, focus, level, goals, weeks, hpw, constraints, r_temp, r_max],
|
| 351 |
outputs=[rec_out],
|
| 352 |
)
|
| 353 |
+
# Refresh slots
|
| 354 |
+
btn_refresh.click(fn=refresh_slots_update, outputs=[slot])
|
| 355 |
+
# Booking
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
btn_book.click(
|
| 357 |
+
fn=submit_booking,
|
| 358 |
inputs=[name, b_grade, b_focus, b_level, contact, slot, notes],
|
| 359 |
outputs=[res_msg, table, slot],
|
| 360 |
)
|
| 361 |
|
|
|
|
| 362 |
# 2) μ§λ¬ΈνκΈ° (μ±ν
)
|
|
|
|
| 363 |
with gr.Tab("μ§λ¬ΈνκΈ° (μ±ν
)"):
|
| 364 |
chat_history = gr.State([]) # list of (user, assistant)
|
| 365 |
with gr.Row():
|
|
|
|
| 398 |
gr.Markdown('<div class="toss-note">β’ λν κΈ°λ‘μ μ μ±ν
μμμ μμλλ‘ λμ λ©λλ€.'
|
| 399 |
'<br>β’ κ³ΌκΈ μ£Όμ: Router μ¬μ©λ/ν ν°μ λ°λΌ λΉμ©μ΄ λ°μν μ μμ΅λλ€.</div>')
|
| 400 |
|
|
|
|
| 401 |
# 3) νμ μκ°
|
|
|
|
| 402 |
with gr.Tab("νμ μκ°"):
|
| 403 |
with gr.Group(elem_classes=["toss-card"]):
|
| 404 |
gr.Markdown("""
|
|
|
|
| 416 |
> μλ΄/체ν μμ
λ¬Έμλ 'μμ½ Β· μΆμ²' νμμ μ§ννμΈμ.
|
| 417 |
""")
|
| 418 |
|
|
|
|
| 419 |
# 4) μν μ κ²
|
|
|
|
| 420 |
with gr.Tab("μν μ κ²"):
|
| 421 |
with gr.Group(elem_classes=["toss-card"]):
|
| 422 |
diag_btn = gr.Button("μλν¬μΈνΈ μ κ²", elem_classes=["toss-primary"])
|