lanna_lalala;- commited on
Commit
e378f37
·
1 Parent(s): a9fb560

trying to fix prefix

Browse files
Files changed (1) hide show
  1. utils/api.py +47 -0
utils/api.py CHANGED
@@ -351,6 +351,53 @@ def chat_ai(query: str, lesson_id: int, level_slug: str, history=None) -> str:
351
  return r.json().get("answer", "")
352
  except Exception as e:
353
  return f"(chat failed: {e})"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
  # ---------- LangGraph-backed ----------
356
  def fetch_lesson_content(lesson: str, module: str, topic: str):
 
351
  return r.json().get("answer", "")
352
  except Exception as e:
353
  return f"(chat failed: {e})"
354
+
355
+ # ---------- Direct requests (no prefix) ----------
356
+
357
+ def signup_student(name: str, email: str, password: str, level_label: str, country_label: str):
358
+ payload = {
359
+ "name": name,
360
+ "email": email,
361
+ "password": password,
362
+ "level": level_label, # match your backend param names
363
+ "country": country_label,
364
+ }
365
+ try:
366
+ url = f"{BACKEND}/auth/signup/student"
367
+ r = _session.post(url, json=payload, timeout=DEFAULT_TIMEOUT)
368
+ r.raise_for_status()
369
+ return r.json()
370
+ except Exception as e:
371
+ raise RuntimeError(f"Signup failed: {e}")
372
+
373
+ def signup_teacher(title: str, name: str, email: str, password: str):
374
+ payload = {
375
+ "title": title,
376
+ "name": name,
377
+ "email": email,
378
+ "password": password,
379
+ }
380
+ try:
381
+ url = f"{BACKEND}/auth/signup/teacher"
382
+ r = _session.post(url, json=payload, timeout=DEFAULT_TIMEOUT)
383
+ r.raise_for_status()
384
+ return r.json()
385
+ except Exception as e:
386
+ raise RuntimeError(f"Signup failed: {e}")
387
+
388
+ def login(email: str, password: str):
389
+ payload = {
390
+ "email": email,
391
+ "password": password,
392
+ }
393
+ try:
394
+ url = f"{BACKEND}/auth/login"
395
+ r = _session.post(url, json=payload, timeout=DEFAULT_TIMEOUT)
396
+ r.raise_for_status()
397
+ return r.json()
398
+ except Exception as e:
399
+ raise RuntimeError(f"Login failed: {e}")
400
+
401
 
402
  # ---------- LangGraph-backed ----------
403
  def fetch_lesson_content(lesson: str, module: str, topic: str):