ll7098ll commited on
Commit
e39486f
ยท
verified ยท
1 Parent(s): d89b606

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -34
app.py CHANGED
@@ -24,44 +24,43 @@ model = genai.GenerativeModel(
24
  # ํ”„๋กฌํ”„ํŠธ ์„ค์ •
25
  SYSTEM_PROMPT = """
26
  ๋‹น์‹ ์€ ๊ต์ˆ˜ํ•™์Šต ํ™œ๋™ ์„ค๊ณ„ ์ „๋ฌธ๊ฐ€, ๊ต๊ณผ๊ต์œก ๋‚ด์šฉ ์ „๋ฌธ๊ฐ€, ๊ต์œก๊ณตํ•™์ž์ž…๋‹ˆ๋‹ค.
27
- ์„ ์ƒ๋‹˜๋“ค์ด ํ™œ๋™ ์ปจ์…‰ ๋ฐ ์†Œ๊ฐœ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ™œ๋™์„ ์ž์„ธํ•˜๊ฒŒ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”..
28
- ๋‹ค์Œ์€ ํ™œ๋™ ์„ค๊ณ„์— ํ•„์š”ํ•œ ์ •๋ณด์ž…๋‹ˆ๋‹ค.
29
 
30
- **ํ™œ๋™ ๊ตฌ์„ฑ ์š”์†Œ:**
31
- 1. ํ™œ๋™ ์ปจ์…‰ ๋ฐ ์†Œ๊ฐœ
32
- 2. ํ™œ๋™ ๋ชฉํ‘œ
33
- 3. ํ™œ๋™ ๋‹จ๊ณ„๋ณ„ ์•ˆ๋‚ด
34
- - 1๋‹จ๊ณ„: 1๋‹จ๊ณ„ ํ™œ๋™ ์•ˆ๋‚ด
35
- - 2๋‹จ๊ณ„: 2๋‹จ๊ณ„ ํ™œ๋™ ์•ˆ๋‚ด
36
- - 3๋‹จ๊ณ„: 3๋‹จ๊ณ„ ํ™œ๋™ ์•ˆ๋‚ด
37
- - 4๋‹จ๊ณ„: 4๋‹จ๊ณ„ ํ™œ๋™ ์•ˆ๋‚ด...
38
- 4. ํ™œ๋™ ์ค€๋น„๋ฌผ ๋ฐ ๊ธฐ๊ตฌ
39
- 5. ํ™œ๋™์„ ์œ„ํ•œ ์ž๋ฃŒ
40
- - ํ™œ๋™์— ํ•„์š”ํ•œ ์ž๋ฃŒ
41
- - ์ถ”๊ฐ€ ์ถ”์ฒœ ์ž๋ฃŒ
42
- 6. ํ™œ๋™์˜ ์œ ์˜์ 
43
- - ํ•™์ƒ ์ž…์žฅ ์œ ์˜์ 
44
- - ๊ต์‚ฌ ์ž…์žฅ ์œ ์˜์ 
45
- 7. ํ•™์ƒ์—๊ฒŒ ์ œ๊ณตํ•  ํ™œ๋™ ์•ˆ๋‚ด ์ž๋ฃŒ
46
  * ํ™œ๋™ ์•ˆ๋‚ด ์ž๋ฃŒ๋Š” ์ดˆ๋“ฑํ•™์ƒ์ด ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก ์ตœ๋Œ€ํ•œ ๊ตฌ์ฒด์ ์ด๊ณ , ๋‹จ๊ณ„์ , ๋ช…์‹œ์ ์œผ๋กœ ์•ˆ๋‚ดํ•ด์ฃผ์„ธ์š”.
47
  """
48
 
49
- def generate_curriculum(achievement_standard):
50
  """
51
- ํ™œ๋™ ์ปจ์…‰์„ ์ž…๋ ฅ๋ฐ›์•„ ํ™œ๋™์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
52
- ์•„์›ƒํ’‹์„ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
53
 
54
  Args:
55
- achievement_standard (str): ํ™œ๋™ ์ปจ์…‰
 
56
 
57
  Returns:
58
- str: ์ƒ์„ฑ๋œ ํ™œ๋™
59
  """
60
 
61
  prompt = [
62
  SYSTEM_PROMPT,
63
- f"**ํ™œ๋™ ์ปจ์…‰:** {achievement_standard}",
64
- "**ํ™œ๋™:**",
 
65
  ]
66
 
67
  response = model.generate_content(prompt, stream=True)
@@ -69,18 +68,47 @@ def generate_curriculum(achievement_standard):
69
  for token in response:
70
  chunk = token.text
71
  collected_text += chunk
72
- yield collected_text # ์‹ค์‹œ๊ฐ„ ์ถœ๋ ฅ์„ ์œ„ํ•ด yield ์‚ฌ์šฉ
73
- time.sleep(0.03) # ์ถœ๋ ฅ ์†๋„ ์กฐ์ ˆ
74
 
75
- # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
76
  iface = gr.Interface(
77
- fn=generate_curriculum,
78
- inputs=gr.Textbox(lines=3, label="ํ™œ๋™ ์ปจ์…‰ ๋ฐ ์†Œ๊ฐœ ์ž…๋ ฅ"),
79
- outputs=gr.Textbox(lines=10, label="ํ•™์Šต ํ™œ๋™"),
80
- title="ํ•™์Šต ํ™œ๋™ ์„ค๊ณ„ ๋„์šฐ๋ฏธ",
81
- description="์„ ์ƒ๋‹˜์ด ํ™œ๋™์˜ ์ปจ์…‰์„ ์ž…๋ ฅํ•˜์‹œ๋ฉด ํ™œ๋™์„ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๊ณ„ํ•ด์ค๋‹ˆ๋‹ค.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  examples=[
83
- ["๊ตญ๊ฒฝ, ์ง€ํ˜•, ์ž์›, ์ธ๊ตฌ์ •๋ณด, ๊ตญ๊ฐ€ ๊ฐ„ ๊ด€๊ณ„๊ฐ€ ํ‘œ์‹œ๋œ ์ง€๋„์™€ ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ์ฃผ๊ณ , ๋‚˜๋ผ ๊ฐ„ ๊ตญ๊ฒฝ์„ ์„ ์ •ํ•˜๋Š” ํ™œ๋™์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๊ฒŒ์ž„ ๋ชจํ˜•์„ ํ™œ์šฉํ•ด ํ•˜๊ณ  ์‹ถ์–ด."],
 
84
  ]
85
  )
86
 
 
24
  # ํ”„๋กฌํ”„ํŠธ ์„ค์ •
25
  SYSTEM_PROMPT = """
26
  ๋‹น์‹ ์€ ๊ต์ˆ˜ํ•™์Šต ํ™œ๋™ ์„ค๊ณ„ ์ „๋ฌธ๊ฐ€, ๊ต๊ณผ๊ต์œก ๋‚ด์šฉ ์ „๋ฌธ๊ฐ€, ๊ต์œก๊ณตํ•™์ž์ž…๋‹ˆ๋‹ค.
27
+ ์„ ์ƒ๋‹˜๋“ค์ด ํ•™์Šต ์ฃผ์ œ์™€ ์‚ฌ๊ณ  ๋ฃจํ‹ด์„ ์ž…๋ ฅํ•˜๋ฉด, ํ•ด๋‹น ์ฃผ์ œ์— ์ ์šฉ ๊ฐ€๋Šฅํ•œ ์‚ฌ๊ณ  ๋ฃจํ‹ด ํ™œ๋™ ์˜ˆ์‹œ๋ฅผ ์ƒ์„ธํ•˜๊ฒŒ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”.
 
28
 
29
+ **ํ™œ๋™ ์˜ˆ์‹œ ๊ตฌ์„ฑ ์š”์†Œ:**
30
+ 1. ํ•™์Šต ์ฃผ์ œ
31
+ 2. ์ ์šฉํ•  ์‚ฌ๊ณ  ๋ฃจํ‹ด
32
+ 3. ํ™œ๋™ ๋ชฉํ‘œ
33
+ 4. ํ™œ๋™ ๋‹จ๊ณ„๋ณ„ ์•ˆ๋‚ด
34
+ - ๊ฐ ๋‹จ๊ณ„๋ณ„๋กœ ์‚ฌ๊ณ  ๋ฃจํ‹ด์„ ์–ด๋–ป๊ฒŒ ํ™œ์šฉํ•˜๋Š”์ง€ ์ž์„ธํ•˜๊ฒŒ ์„ค๋ช…
35
+ - ์˜ˆ์‹œ ์งˆ๋ฌธ ํฌํ•จ
36
+ 5. ํ™œ๋™ ์ค€๋น„๋ฌผ ๋ฐ ๊ธฐ๊ตฌ
37
+ 6. ํ™œ๋™์„ ์œ„ํ•œ ์ž๋ฃŒ
38
+ - ํ™œ๋™์— ํ•„์š”ํ•œ ์ž๋ฃŒ
39
+ - ์ถ”๊ฐ€ ์ถ”์ฒœ ์ž๋ฃŒ
40
+ 7. ํ™œ๋™์˜ ์œ ์˜์ 
41
+ - ํ•™์ƒ ์ž…์žฅ ์œ ์˜์ 
42
+ - ๊ต์‚ฌ ์ž…์žฅ ์œ ์˜์ 
43
+ 8. ํ•™์ƒ์—๊ฒŒ ์ œ๊ณตํ•  ํ™œ๋™ ์•ˆ๋‚ด ์ž๋ฃŒ
 
44
  * ํ™œ๋™ ์•ˆ๋‚ด ์ž๋ฃŒ๋Š” ์ดˆ๋“ฑํ•™์ƒ์ด ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก ์ตœ๋Œ€ํ•œ ๊ตฌ์ฒด์ ์ด๊ณ , ๋‹จ๊ณ„์ , ๋ช…์‹œ์ ์œผ๋กœ ์•ˆ๋‚ดํ•ด์ฃผ์„ธ์š”.
45
  """
46
 
47
+ def generate_thinking_routine_example(topic, thinking_routine):
48
  """
49
+ ํ•™์Šต ์ฃผ์ œ์™€ ์‚ฌ๊ณ  ๋ฃจํ‹ด์„ ์ž…๋ ฅ๋ฐ›์•„ ํ™œ๋™ ์˜ˆ์‹œ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
 
50
 
51
  Args:
52
+ topic (str): ํ•™์Šต ์ฃผ์ œ
53
+ thinking_routine (str): ์ ์šฉํ•  ์‚ฌ๊ณ  ๋ฃจํ‹ด
54
 
55
  Returns:
56
+ str: ์ƒ์„ฑ๋œ ํ™œ๋™ ์˜ˆ์‹œ
57
  """
58
 
59
  prompt = [
60
  SYSTEM_PROMPT,
61
+ f"**ํ•™์Šต ์ฃผ์ œ:** {topic}",
62
+ f"**์ ์šฉํ•  ์‚ฌ๊ณ  ๋ฃจํ‹ด:** {thinking_routine}",
63
+ "**ํ™œ๋™ ์˜ˆ์‹œ:**",
64
  ]
65
 
66
  response = model.generate_content(prompt, stream=True)
 
68
  for token in response:
69
  chunk = token.text
70
  collected_text += chunk
71
+ yield collected_text
72
+ time.sleep(0.03)
73
 
74
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • - ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด ์ถ”๊ฐ€
75
  iface = gr.Interface(
76
+ fn=generate_thinking_routine_example,
77
+ inputs=[
78
+ gr.Textbox(lines=2, label="ํ•™์Šต ์ฃผ์ œ ์ž…๋ ฅ"),
79
+ gr.Dropdown(
80
+ choices=[
81
+ "See-Think-Wonder",
82
+ "Zoom In",
83
+ "Think-Puzzle-Explore",
84
+ "Chalk Talk",
85
+ "321 Bridge",
86
+ "Compass Points",
87
+ "Explanation Game",
88
+ "Headlines",
89
+ "CSI: Color, Symbol, Image",
90
+ "Generate-Sort-Connect-Elaborate-Concept Maps",
91
+ "Connect-Extend-Challenge",
92
+ "The 4 C's",
93
+ "Micro Lab",
94
+ "I used to thinkโ€ฆNow I thinkโ€ฆ",
95
+ "What makes you say that?",
96
+ "Circle Viewpoints",
97
+ "Step Inside",
98
+ "Red Light, Yellow Light",
99
+ "Claim Support Question",
100
+ "Tug of War",
101
+ "Word-Phrase-Sentence"
102
+ ],
103
+ label="์‚ฌ๊ณ  ๋ฃจํ‹ด ์„ ํƒ"
104
+ ),
105
+ ],
106
+ outputs=gr.Textbox(lines=15, label="์‚ฌ๊ณ  ๋ฃจํ‹ด ํ™œ์šฉ ์˜ˆ์‹œ"),
107
+ title="ํ•™์Šต ํ™œ๋™ ์„ค๊ณ„ ๋„์šฐ๋ฏธ: ์‚ฌ๊ณ  ๋ฃจํ‹ด ํ™œ์šฉ ํŽธ",
108
+ description="์„ ์ƒ๋‹˜์ด ํ•™์Šต ์ฃผ์ œ์™€ ์‚ฌ๊ณ  ๋ฃจํ‹ด์„ ์„ ํƒํ•˜์‹œ๋ฉด, ํ•ด๋‹น ์ฃผ์ œ์— ์ ์šฉ ๊ฐ€๋Šฅํ•œ ์‚ฌ๊ณ  ๋ฃจํ‹ด ํ™œ๋™ ์˜ˆ์‹œ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.",
109
  examples=[
110
+ ["๊ด‘ํ•ฉ์„ฑ", "See-Think-Wonder"],
111
+ ["์กฐ์„  ์‹œ๋Œ€์˜ ๊ณผํ•™ ๊ธฐ์ˆ ", "Think-Puzzle-Explore"],
112
  ]
113
  )
114