yunzi7 commited on
Commit
c90fe2b
β€’
1 Parent(s): 4dd778b
ice_breaking_challenge/background_task.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ def background_task():
2
+ "continue"
ice_breaking_challenge/introduction.py CHANGED
@@ -7,18 +7,18 @@ from flask import request
7
  from flask import url_for
8
  from werkzeug.exceptions import abort
9
  from flask import session
 
10
 
11
  from .auth import login_required
12
  from .db import get_db
13
 
14
-
15
- bp = Blueprint("introduction", __name__)
16
 
17
 
18
  @bp.route("/", methods=["GET", "POST"])
19
- def qr() -> None:
20
  match request.method:
21
  case "GET":
22
  return render_template("introduction.html")
23
- case "POST":
24
- return render_template("introduction.html")
 
7
  from flask import url_for
8
  from werkzeug.exceptions import abort
9
  from flask import session
10
+ from threading import Thread
11
 
12
  from .auth import login_required
13
  from .db import get_db
14
 
15
+ bp = Blueprint("introduction", __name__, url_prefix="introduction")
 
16
 
17
 
18
  @bp.route("/", methods=["GET", "POST"])
19
+ def introduction() -> None:
20
  match request.method:
21
  case "GET":
22
  return render_template("introduction.html")
23
+ case "POST":
24
+ return redirect(url_for("topic.topic"))
ice_breaking_challenge/models/model_loader.py CHANGED
@@ -16,47 +16,6 @@ def load_model_with_lora(model_name:str = MODEL_NAME, lora_weight_path: str = LO
16
  """
17
  model = keras_nlp.models.GemmaCausalLM.from_preset(model_name)
18
 
19
-
20
  model.backbone.load_lora_weights(lora_weight_path)
21
- # question_crawling="λ‚˜μ˜ 이런 점은 일할 λ•Œ 도움이 돼!?"
22
- question_crawling="μ¦κ²¨λ³΄λŠ” μœ νŠœλ²„?"
23
- # answer_crawling="λ‚˜λˆ„κ³  μ‹Άμ–΄ν•˜λŠ” 마음? μ£Όλ³€ μ‚¬λžŒλ“€μ€ 그만 퍼주라고 ν•˜κΈ°λ„ ν•˜μ§€λ§Œ, λ‚΄κ°€ ν΄λΌμ΄μ–ΈνŠΈλ‘œλΆ€ν„° λˆμ„ 벌고자 ν•˜λŠ” 것이 μ•„λ‹ˆλΌ μ‘°κΈˆμ΄λΌλ„ 더 μ±™κ²¨μ£Όκ³ μž ν•˜λŠ” λ§ˆμŒμ„ κ°€μ‘Œμ„ λ•Œ κ²°κ΅­ λ‚˜μ˜ λΈŒλžœλ“œκ°€ 훨씬 더 컀질 수 μžˆλ‹€λŠ” 믿음이 μžˆλ‹€."
24
- answer_crawling="μ„ λ°”, λ“œλ¦½μΉ˜λŠ” 게 제 μ·¨ν–₯μž…λ‹ˆλ‹€."
25
-
26
- input_text = f"""
27
- <instruction>
28
- Using the text: {question_crawling} {answer_crawling}, create a new multiple-choice question with 4 answer options.
29
- """
30
-
31
- print(model.generate(input_text, max_length=512))
32
 
33
  return model
34
-
35
-
36
- # def template_setting(df:pd.DataFrame, is_test:bool) -> np.ndarray:
37
- # template_input="""
38
- # <instruction>
39
- # Using the text: {question_crawling} {answer_crawling}, create a new multiple-choice question with 4 answer options.
40
- # """
41
-
42
- # template_output="""
43
- # <Response>
44
- # {question_generated}
45
- # {multiple_choice_generated}
46
- # {answer_generated}
47
- # """
48
- # template=template_input+'\n'+template_output
49
-
50
- # inputs = np.array(df.apply(lambda row: template.format(
51
- # question_crawling=row['question_crawling'],
52
- # answer_crawling=row['answer_crawling'],
53
- # question_generated=row['question_generated'] if not is_test else "",
54
- # multiple_choice_generated=row['multiple_choice_generated'] if not is_test else "",
55
- # answer_generated=row['answer_generated'] if not is_test else "").strip(), axis=1))
56
-
57
- # outputs = np.array(df.apply(lambda row: template_output.format(
58
- # question_generated=row['question_generated'],
59
- # multiple_choice_generated=row['multiple_choice_generated'],
60
- # answer_generated=row['answer_generated']).strip(), axis=1))
61
- # combined_array = np.column_stack((inputs, outputs))
62
- # return combined_array
 
16
  """
17
  model = keras_nlp.models.GemmaCausalLM.from_preset(model_name)
18
 
 
19
  model.backbone.load_lora_weights(lora_weight_path)
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  return model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ice_breaking_challenge/qr.py CHANGED
@@ -10,10 +10,14 @@ from flask import url_for
10
  from werkzeug.exceptions import abort
11
  from flask import session
12
 
 
 
13
  from .auth import login_required
14
  from .db import get_db
15
  from ice_breaking_challenge.google_sheets import get_team_numbers
16
 
 
 
17
 
18
  bp = Blueprint("qr", __name__, url_prefix="/qr")
19
 
@@ -23,12 +27,14 @@ def qr() -> None:
23
  match request.method:
24
  case "GET":
25
  return render_template("qr.html")
 
26
  case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
27
  counter = Counter(get_team_numbers())
28
  if session.get("team_number") not in counter:
29
  flash("ν•΄λ‹Ή νŒ€ λ²ˆν˜Έκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.")
30
  return render_template("index.html")
31
  if counter[session.get("team_number")] == session["team_size"]:
 
32
  return render_template("introduction.html")
33
  else:
34
  flash("섀문을 μ™„λ£Œν•˜μ§€ μ•Šμ€ νŒ€μ›μ΄ μžˆμŠ΅λ‹ˆλ‹€.")
 
10
  from werkzeug.exceptions import abort
11
  from flask import session
12
 
13
+ from threading import Thread
14
+
15
  from .auth import login_required
16
  from .db import get_db
17
  from ice_breaking_challenge.google_sheets import get_team_numbers
18
 
19
+ from background_task import background_task
20
+
21
 
22
  bp = Blueprint("qr", __name__, url_prefix="/qr")
23
 
 
27
  match request.method:
28
  case "GET":
29
  return render_template("qr.html")
30
+
31
  case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
32
  counter = Counter(get_team_numbers())
33
  if session.get("team_number") not in counter:
34
  flash("ν•΄λ‹Ή νŒ€ λ²ˆν˜Έκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.")
35
  return render_template("index.html")
36
  if counter[session.get("team_number")] == session["team_size"]:
37
+ Thread(target=background_task).start()
38
  return render_template("introduction.html")
39
  else:
40
  flash("섀문을 μ™„λ£Œν•˜μ§€ μ•Šμ€ νŒ€μ›μ΄ μžˆμŠ΅λ‹ˆλ‹€.")
ice_breaking_challenge/templates/topic.html ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Random Topic Recommendation</title>
8
+ <style>
9
+ body {
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ height: 100vh;
14
+ font-family: Arial, sans-serif;
15
+ }
16
+ h1 {
17
+ font-size: 2em;
18
+ color: #333;
19
+ }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <h1 id="topic">μ£Όμ œκ°€ 여기에 ν‘œμ‹œλ©λ‹ˆλ‹€</h1>
24
+
25
+ <script>
26
+ // 주제 μ—…λ°μ΄νŠΈ ν•¨μˆ˜
27
+ function updateTopic() {
28
+ fetch('/get_topic')
29
+ .then(response => response.json())
30
+ .then(data => {
31
+ document.getElementById('topic').textContent = data.topic;
32
+ })
33
+ .catch(error => console.error('Error fetching topic:', error));
34
+ }
35
+
36
+ // νŽ˜μ΄μ§€κ°€ λ‘œλ“œλ  λ•Œ 주제 μ—…λ°μ΄νŠΈ
37
+ updateTopic();
38
+
39
+ // 20μ΄ˆλ§ˆλ‹€ 주제 μ—…λ°μ΄νŠΈ
40
+ setInterval(updateTopic, 20000);
41
+ </script>
42
+ </body>
43
+ </html>
ice_breaking_challenge/topic.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Blueprint, render_template, redirect, url_for
2
+ import random
3
+
4
+ import time
5
+
6
+ bp = Blueprint("topic", __name__, url_prefix="topic")
7
+ topics = ["MBTI", ""]
8
+
9
+ @bp.route("/", methods=["GET"])
10
+ def topic() -> None:
11
+ if session.get("quiz_generated"):
12
+ return redirect(url_for("quiz.show_quiz"))
13
+ else:
14
+ selected_topic = random.choice(topics)
15
+ time.sleep(20) # 20초 λŒ€κΈ° ν›„ λ‹€μŒ 주제둜
16
+ return render_template("topic.html", topic=selected_topic)
17
+