File size: 16,479 Bytes
1d355ad
fabb74d
737dfe4
899bc84
737dfe4
 
899bc84
1d355ad
fabb74d
22032f3
 
fabb74d
 
a033392
 
dfbd598
 
fabb74d
 
 
 
c6d8680
fabb74d
 
 
 
a4b184b
 
39688bd
a4b184b
4513ea4
 
 
 
0e065bd
4513ea4
41289f4
737dfe4
b50cf39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41289f4
737dfe4
cff1cdf
 
41289f4
737dfe4
cff1cdf
41289f4
737dfe4
cff1cdf
 
22032f3
737dfe4
cff1cdf
 
f74a421
737dfe4
cff1cdf
 
41289f4
737dfe4
cff1cdf
 
 
41289f4
737dfe4
cff1cdf
 
41289f4
 
57da6a2
cff1cdf
 
 
 
5faf984
a4b184b
 
 
 
 
41289f4
 
217a78d
a4b184b
fabb74d
a4b184b
fabb74d
a4b184b
feb03cf
a4b184b
737dfe4
a06ec9f
 
 
a4b184b
a06ec9f
a4b184b
737dfe4
a4b184b
737dfe4
 
 
 
a4b184b
 
 
 
 
 
 
 
 
 
 
 
 
a033392
a4b184b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39688bd
03d0703
0d99071
737dfe4
 
a4b184b
 
 
 
 
 
737dfe4
a4b184b
 
737dfe4
a4b184b
 
 
 
737dfe4
a4b184b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f5b61e5
a4b184b
54877b5
a4b184b
54877b5
a4b184b
 
 
 
 
737dfe4
a4b184b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import os
import time
import streamlit as st
import google.generativeai as genai
from streamlit_extras.colored_header import colored_header
from streamlit_extras.add_vertical_space import add_vertical_space
import markdown

# Google Gemini API ν‚€ μ„€μ •
genai.configure(api_key=os.environ["GEMINI_API_KEY"])

# λͺ¨λΈ μ„€μ •
generation_config = {
    "temperature": 0.7,
    "top_p": 0.85,
    "top_k": 64,
    "max_output_tokens": 25000,
    "response_mime_type": "text/plain",
}

model = genai.GenerativeModel(
    model_name="gemini-2.0-flash-thinking-exp-01-21",
    generation_config=generation_config,
)

SYSTEM_PROMPT = """
λŒ€μƒ ν•™λ…„: {grade}
μ„±μ·¨κΈ°μ€€ 및 μ£Όμš” λ‚΄μš©: {achievement_standard}

μœ„ 정보λ₯Ό λ°”νƒ•μœΌλ‘œ 핡심 아이디어 이해λ₯Ό λͺ©ν‘œλ‘œ ν•˜λŠ” {grade} μˆ˜μ€€μ— μ ν•©ν•œ κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅μ„ 섀계해 μ£Όμ„Έμš”. λ‹€μŒ ꡬ성 μš”μ†Œμ— 따라 μƒμ„Έν•˜κ³  μ²΄κ³„μ μœΌλ‘œ μ„€λͺ…ν•΄μ•Ό ν•©λ‹ˆλ‹€. 
각 ꡬ성 μš”μ†ŒλŠ” μ„œλ‘œ μ—°κ²°λ˜κ³  유기적으둜 κ΅¬μ„±λ˜μ–΄μ•Ό ν•˜λ©°, ν•™μƒλ“€μ˜ ν₯미와 μ°Έμ—¬λ₯Ό μœ λ„ν•  수 μžˆλŠ” 창의적이고 ν˜μ‹ μ μΈ ν™œλ™λ“€μ„ μ œμ‹œν•΄μ•Ό ν•©λ‹ˆλ‹€. 
특히, λͺ¨λ“  ν™œλ™μ€ 학생듀이 슀슀둜 핡심 아이디어λ₯Ό λ°œκ²¬ν•˜κ³  깊이 있게 이해할 수 μžˆλ„λ‘ μ„€κ³„λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€. 
λ¨Όμ € μŠ€νŠΈλžœλ“œλ₯Ό 2~3개둜 μ„€μ •ν•˜μ„Έμš”.μŠ€νŠΈλžœλ“œ(Strand)λŠ” λ‹¨μ›μ˜ μ†Œμ£Όμ œμ™€ κ°™μœΌλ©°, 각 μŠ€νŠΈλžœλ“œλŠ” μ—¬λŸ¬ μ°¨μ‹œμ˜ μˆ˜μ—…μœΌλ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€. 
μŠ€νŠΈλžœλ“œ μ•ˆμ—μ„œλŠ” "관계맺기 - μ§‘μ€‘ν•˜κΈ° - μ‘°μ‚¬ν•˜κΈ° - 쑰직 및 μ •λ¦¬ν•˜κΈ° - μΌλ°˜ν™” - 전이 - μ„±μ°°ν•˜κΈ°"의 λ‹¨κ³„μ˜ κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅μ„ μ„€κ³„ν•΄μ•Όν•©λ‹ˆλ‹€.
각 λ‹¨κ³„μ—μ„œλŠ” ν•΄λ‹Ή 단계에 λ§žλŠ” 탐ꡬ 질문과 μΌλ°˜ν™”κ°€ μ œμ‹œλ˜μ–΄μ•Ό ν•˜κ³ , κ·Έ μΌλ°˜ν™”μ— 도달할 수 μžˆλŠ” 단계별 κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ ν™œλ™μ΄ ꡬ체적이고 μƒμ„Έν•˜κ²Œ μ œμ‹œλ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.(그리고 λ‚΄μš© μƒλž΅μ€ ν•˜μ§€λ§κ³  λͺ¨λ“  λ‚΄μš©μ„ 좜λ ₯ν•˜μ„Έμš”.)


1. 핡심 아이디어 (Key Ideas & Generalizations):
이 주제λ₯Ό κ΄€μ°°ν•˜λŠ” κ°€μž₯ μ€‘μš”ν•œ 관점(Conceptual Lens)은 무엇인가?
이 주제λ₯Ό 톡해 학생듀이 이해해야 ν•  κ°€μž₯ μ€‘μš”ν•œ 아이디어(Key Ideas)λŠ” 무엇인가? 2-3개의 λ¬Έμž₯으둜 λͺ…ν™•ν•˜κ²Œ κΈ°μˆ ν•˜μ„Έμš”.
μœ„ 아이디어듀을 λ’·λ°›μΉ¨ν•˜λŠ” μΌλ°˜ν™”λœ 지식(Generalizations)을 3-5개의 λ¬Έμž₯으둜 μ„€λͺ…ν•˜μ„Έμš”.

2. 맀크둜 κ°œλ… (Macro Concepts) 및 마이크둜 κ°œλ… (Micro Concepts):
이 주제λ₯Ό μ΄ν•΄ν•˜λŠ” 데 ν•„μš”ν•œ 큰 ν‹€μ˜ κ°œλ…(맀크둜 κ°œλ…, Conceptual Lens)은 무엇인가?
이 μ£Όμ œμ™€ κ΄€λ ¨λœ ꡬ체적인 ꡐ과 κ°œλ…(마이크둜 κ°œλ…, Subject-Specific Concepts)은 무엇인가?
맀크둜 κ°œλ…κ³Ό 마이크둜 κ°œλ… μ‚¬μ΄μ˜ 관계λ₯Ό μ–΄λ–»κ²Œ μ„€λͺ…ν•  것인가?  ꡬ체적인 μ˜ˆμ‹œλ₯Ό μ‚¬μš©ν•˜μ—¬ μ„€λͺ…ν•˜μ„Έμš”.

3. μ§€μ‹μ˜ λ²”μ£Ό (Knowledge Categories -  λ¦° μ—λ¦­μŠ¨μ˜ λΆ„λ₯˜ κΈ°μ€€):
사싀 (Facts): 이 μ£Όμ œμ™€ κ΄€λ ¨λœ μ€‘μš”ν•œ 사싀듀을 μ΅œμ†Œ 10개 이상 λ‚˜μ—΄ν•˜μ„Έμš”.
κ°œλ… (Concepts): 이 주제λ₯Ό μ΄ν•΄ν•˜λŠ” 데 ν•„μš”ν•œ 핡심 κ°œλ…λ“€μ„ μ •μ˜ν•˜κ³ , 각 κ°œλ…μ— λŒ€ν•œ μ˜ˆμ‹œλ₯Ό μ œμ‹œν•˜μ„Έμš”. μ΅œμ†Œ 3개 이상 μ œμ‹œν•˜μ„Έμš”.
μΌλ°˜ν™” (Generalizations): κ°œλ…λ“€ μ‚¬μ΄μ˜ 관계λ₯Ό μ„€λͺ…ν•˜λŠ” μΌλ°˜ν™”λœ μ§„μˆ μ„ μ΅œμ†Œ 3개 이상 μ œμ‹œν•˜μ„Έμš”.
원리 (Principles): μΌλ°˜ν™”λ₯Ό λ’·λ°›μΉ¨ν•˜λŠ” 과학적 원리 λ˜λŠ” 이둠듀을 μ„€λͺ…ν•˜μ„Έμš”. μ΅œμ†Œ 2개 이상 μ œμ‹œν•˜μ„Έμš”.

4. 탐ꡬ 질문 (Inquiry Questions):
ν•™μƒλ“€μ˜ 탐ꡬλ₯Ό μžκ·Ήν•˜κ³  핡심 κ°œλ… 및 μΌλ°˜ν™”λ‘œ μœ λ„ν•  수 μžˆλŠ” 탐ꡬ μ§ˆλ¬Έλ“€μ„ 5개 이상 μ œμ‹œν•˜μ„Έμš”. μ§ˆλ¬Έμ€ ꡬ체적이고 탐ꡬ κ°€λŠ₯ν•΄μ•Ό ν•˜λ©°, λ‹€μ–‘ν•œ μˆ˜μ€€μ˜ 사고λ₯Ό μš”κ΅¬ν•΄μ•Ό ν•©λ‹ˆλ‹€.  각 질문이 μ–΄λ–€ 핡심 κ°œλ…κ³Ό μ—°κ²°λ˜λŠ”μ§€ λͺ…μ‹œν•˜μ„Έμš”.

5. μŠ€νŠΈλžœλ“œλ³„ κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ κ³Όμ • 섀계: μ•žμ„œ μ œμ‹œλœ 핡심 아이디어 (Key Ideas & Generalizations), 맀크둜 κ°œλ… (Macro Concepts) 및 마이크둜 κ°œλ… (Micro Concepts), μ§€μ‹μ˜ λ²”μ£Ό (Knowledge Categories -  λ¦° μ—λ¦­μŠ¨μ˜ λΆ„λ₯˜ κΈ°μ€€), 탐ꡬ 질문 (Inquiry Questions)의 좜λ ₯ λ‚΄μš©μ„ 기반으둜 λ‹€μŒ 단계에 따라 탐ꡬ ν•™μŠ΅ 과정을 μ„€κ³„ν•˜μ„Έμš”. λͺ¨λ“  ν™œλ™μ€ 학생듀이 핡심 아이디어λ₯Ό μ΄ν•΄ν•˜λ„λ‘ λ•λŠ” 데 μ΄ˆμ μ„ λ§žμΆ°μ•Ό ν•©λ‹ˆλ‹€.

(1) 관계 λ§ΊκΈ° (Engaging):
 핡심 아이디어에 λŒ€ν•œ ν₯미와 ν˜ΈκΈ°μ‹¬μ„ μœ λ°œν•˜κ³  ν•™μƒλ“€μ˜ 지적, μ •μ„œμ  μˆ˜μ—… μ°Έμ—¬λ₯Ό μœ λ„ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: ν₯미둜운 이야기, μ‹œκ° 자료, κ²Œμž„ λ“±)
 ν•™μƒλ“€μ˜ 사전 지식을 ν™œμ„±ν™”ν•˜κ³  핡심 아이디어와 κ΄€λ ¨λœ 탐ꡬ μ§ˆλ¬Έμ„ μœ λ„ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: λΈŒλ ˆμΈμŠ€ν† λ°, λ§ˆμΈλ“œλ§΅, μ§ˆμ˜μ‘λ‹΅ λ“±)

(2) μ§‘μ€‘ν•˜κΈ° (Focusing):
 ꡐ과 κ°œλ…μ„ λͺ…ν™•ν•˜κ²Œ μ œμ‹œν•˜κ³  κ΄€λ ¨λœ 사싀적 예λ₯Ό 2-3개 μ†Œκ°œν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: κ°•μ˜, μ„€λͺ…, μ‹œλ²” μ‹€ν—˜ λ“±)

(3) μ‘°μ‚¬ν•˜κΈ° (Investigating):
 κ°œλ… κ΄€λ ¨ 사둀듀을 μ‘°μ‚¬ν•˜κ³  νƒκ΅¬ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: μ‹€ν—˜, κ΄€μ°°, 쑰사, ν† λ‘ , 자료 뢄석 λ“±)
 좔가적인 사둀 μ œμ‹œλ₯Ό 톡해 κ°œλ… 이해λ₯Ό ν™•μž₯ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”.

(4) 쑰직 및 μ •λ¦¬ν•˜κΈ° (Organizing and Sorting):
 사싀적, κ°œλ…μ  μˆ˜μ€€μ—μ„œ 생각을 κ΅¬μ„±ν•˜κ³  μ •λ¦¬ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: ν‘œ λ§Œλ“€κΈ°, κ·Έλž˜ν”„ 그리기, κ°œλ… 지도 μž‘μ„± λ“±)
 λ‹€μ–‘ν•œ μžλ£Œμ™€ 방법, ꡐ과λ₯Ό ν™œμš©ν•˜μ—¬ κ°œλ…κ³Ό 생각을 λ‚˜νƒ€λ‚΄λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: κ·Έλ¦Ό 그리기, κΈ€μ“°κΈ°, λ°œν‘œ, λͺ¨ν˜• λ§Œλ“€κΈ° λ“±)

(5) μΌλ°˜ν™”ν•˜κΈ° (Generalizing):
 사싀적 μ˜ˆμ‹œμ—μ„œ νŒ¨ν„΄μ„ λ°œκ²¬ν•˜κ³  연결성을 μ°Ύμ•„ μΌλ°˜ν™”λ₯Ό λ„μΆœν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: λ²€ λ‹€μ΄μ–΄κ·Έλž¨, 귀납적 μΆ”λ‘  ν™œλ™ λ“±)
 μΌλ°˜ν™”λ₯Ό λͺ…λ£Œν™”ν•˜κ³  λ‹€λ“¬λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”.

(6) μ „μ΄ν•˜κΈ° (Transferring):
 μΌλ°˜ν™”μ˜ μœ νš¨μ„±μ„ κ²€μ¦ν•˜κ³  μ •λ‹Ήν™”ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”.
 μƒˆλ‘œμš΄ 상황에 μΌλ°˜ν™”λ₯Ό μ μš©ν•˜κ³ , ν•™μŠ΅μ— λŒ€ν•΄ 의미 μžˆλŠ” 행동을 μ·¨ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: 문제 ν•΄κ²°, μ˜μ‚¬ κ²°μ •, 창의적 μ‚°μΆœλ¬Ό μ œμž‘ λ“±)
 예츑 및 가정을 ν˜•μ„±ν•˜κΈ° μœ„ν•΄ κ²½ν—˜κ³Ό 이해λ₯Ό ν™œμš©ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”.

(7) μ„±μ°°ν•˜κΈ° (Reflecting):
 ν•™μŠ΅ μ£Όμ²΄λ‘œμ„œ μžμ‹ μ„ μΈμ‹ν•˜κ³  ν•™μŠ΅ 과정을 κ³„νšν•˜κ³  ν†΅μ œν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: ν•™μŠ΅ κ³„νš μ„Έμš°κΈ°, ν•™μŠ΅ 일지 μž‘μ„± λ“±)
 μžμ‹ μ˜ ν•™μŠ΅ 과정을 ν‰κ°€ν•˜κ³  κ°œμ„ ν•˜λŠ” ν™œλ™μ„ μ œμ‹œν•˜μ„Έμš”. (예: 자기 평가, λ™λ£Œ 평가, ν”Όλ“œλ°± ν™œμš© λ“±)


6. 평가 κ³„νš 및 μˆ˜ν–‰κ³Όμ œ(GRASPS), 평가 루브릭(상, 쀑, ν•˜ 평어):
 각 μŠ€νŠΈλžœλ“œ 및 핡심 κ°œλ…μ— λŒ€ν•œ ν•™μƒλ“€μ˜ 이해도λ₯Ό 평가할 수 μžˆλŠ” 평가 방법 및 λ£¨λΈŒλ¦­μ„ μ œμ‹œν•˜μ„Έμš”. (κ΄€μ°°, λ°œν‘œ, 포트폴리였, 자기 평가, λ™λ£Œ 평가, ν€΄μ¦ˆ, μ‹œν—˜, μˆ˜ν–‰ 과제 λ“±)
 λ£¨λΈŒλ¦­μ€ 상, 쀑, ν•˜μ— λŒ€ν•œ ꡬ체적인 평가 κΈ°μ€€κ³Ό 각 μˆ˜μ€€μ— ν•΄λ‹Ήν•˜λŠ” ν•™μƒμ˜ μž‘μ—… λ˜λŠ” μˆ˜ν–‰ μ˜ˆμ‹œλ₯Ό 포함해야 ν•©λ‹ˆλ‹€.
 ν‰κ°€λŠ” λ‹¨μˆœνžˆ 지식 μ•”κΈ° μ—¬λΆ€λ₯Ό λ¬»λŠ” 것이 μ•„λ‹ˆλΌ, ν•™μƒλ“€μ˜ 탐ꡬ κ³Όμ •, 사고λ ₯, 문제 ν•΄κ²° λŠ₯λ ₯, ν˜‘λ ₯적 νƒœλ„, κ°œλ…μ  이해, μΌλ°˜ν™” λ„μΆœ λŠ₯λ ₯, 전이 λŠ₯λ ₯ 등을 μ’…ν•©μ μœΌλ‘œ 평가해야 ν•©λ‹ˆλ‹€.
 GRASPS(Goal, Role, Audience, Situation, Product/Performance, Standards) μš”μ†Œλ₯Ό ν™œμš©ν•˜μ—¬ μˆ˜ν–‰ 과제λ₯Ό μ„€κ³„ν•˜μ„Έμš”.

7. κ°œλ…μ  이해λ₯Ό μœ„ν•œ 팁 (Tips for Conceptual Understanding):
학생듀이 핡심 κ°œλ…μ„ 깊이 있게 μ΄ν•΄ν•˜κ³  μ—°κ²°ν•˜λ©°, μΌλ°˜ν™”λ₯Ό λ„μΆœν•˜κ³  μ μš©ν•  수 μžˆλ„λ‘ λ•λŠ” 효과적인 ꡐ수 μ „λž΅μ€ 무엇인가?
μ˜€κ°œλ…μ„ μ˜ˆλ°©ν•˜κ³  ν•΄κ²°ν•˜λŠ” 방법은 무엇인가?
ν•™μƒλ“€μ˜ λ‹€μ–‘ν•œ ν•™μŠ΅ μŠ€νƒ€μΌκ³Ό μš”κ΅¬λ₯Ό μΆ©μ‘±ν•˜λŠ” 방법은 무엇인가?
핡심 κ°œλ…κ³Ό κ΄€λ ¨λœ μ‹€μƒν™œ 사둀λ₯Ό μ œμ‹œν•˜μ—¬ ν•™μŠ΅μ˜ μ˜λ―Έμ™€ 관련성을 λ†’μ΄λŠ” λ°©μ•ˆμ„ μ œμ‹œν•˜μ„Έμš”.  λ©€ν‹°λ―Έλ””μ–΄, μ‹œκ° 자료, κ²Œμž„, ν˜‘λ ₯ ν•™μŠ΅ λ“± λ‹€μ–‘ν•œ κ΅μˆ˜λ²•μ„ ν™œμš©ν•˜λŠ” λ°©μ•ˆμ„ μ œμ‹œν•˜μ„Έμš”.
"""


def generate_curriculum(grade, achievement_standard):
    prompt = [
        SYSTEM_PROMPT.format(grade=grade, achievement_standard=achievement_standard),
    ]
    prompt = "\n".join(prompt)

    full_text = ""
    try:
        response = model.generate_content(prompt, stream=True)
        for chunk in response:
            full_text += chunk.text
            html_text = markdown.markdown(full_text, extensions=['tables', 'fenced_code'])
            output_area.markdown(html_text, unsafe_allow_html=True)
            time.sleep(0.05)
    except Exception as e:
        st.error(f"κ³„νšμ„œ 생성 였λ₯˜: {e}")
        return ""
    return full_text


# 챗봇 ν•¨μˆ˜ (μˆ˜μ • 및 μΆ”κ°€ 자료 생성)
def chat_with_ai(user_input, context):
    prompt = f"{context}\nUser: {user_input}\nAI:"
    full_text = ""
    try:
        response = model.generate_content(prompt, stream=True)
        for chunk in response:
            full_text += chunk.text
    except Exception as e:
        st.error(f"챗봇 였λ₯˜: {e}")
        return ""
    return full_text

# Streamlit μΈν„°νŽ˜μ΄μŠ€
st.set_page_config(page_title="κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ AI", page_icon="\U0001F393")

# νŽ˜μ΄μ§€ μŠ€νƒ€μΌ μ»€μŠ€ν„°λ§ˆμ΄μ§•
st.markdown(
    """
    <style>
        /* 전체 배경색 μ„€μ • */
        .stApp {
            background-color: #fffafa;
        }
        /* 타이틀 μŠ€νƒ€μΌ */
        .main-title {
            font-size: 3rem;
            color: #000000;
            font-weight: 700;
            text-align: center;
            margin-bottom: 20px;
        }
        /* μ±„νŒ… λ©”μ‹œμ§€ μŠ€νƒ€μΌ */
        .chat-message {
            border-radius: 15px;
            padding: 15px;
            margin: 10px 0;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            word-break: break-word;
        }
        .chat-message-user {
            background-color: #ffebef;
            color: #8b4513;
            justify-content: flex-end;
        }
        .chat-message-assistant {
            background-color: #ffe4e6;
            color: #6b4226;
            justify-content: flex-start;
        }
        .chat-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
        }
        .chat-avatar-user {
            margin-left: 10px;
            margin-right: 0;
        }
        /* λ²„νŠΌ μŠ€νƒ€μΌ */
        .stButton button {
            background-color: #cd857f;
            color: #fff;
            border-radius: 15px;
            padding: 10px 20px;
        }
    </style>
    """,
    unsafe_allow_html=True
)

st.markdown("<div class='main-title'>\U0001F393 κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ AI</div>", unsafe_allow_html=True)
add_vertical_space(1)

with st.sidebar:
    st.markdown("## βš™οΈ μž…λ ₯ μ„€μ •")
    grade_options = [f"μ΄ˆλ“±ν•™κ΅ {i}ν•™λ…„" for i in range(1, 7)] + [f"쀑학ꡐ {i}ν•™λ…„" for i in range(1, 4)]
    grade_selected = st.selectbox("πŸŽ’ ν•™λ…„ 선택", grade_options, index=0)
    achievement_standard = st.text_area("πŸ“– μ„±μ·¨κΈ°μ€€ 및 μ£Όμš” λ‚΄μš©", height=150)
    generate_button = st.button("πŸš€ κ³„νšμ„œ 생성")

# 좜λ ₯ 및 챗봇 μ˜μ—­
output_area = st.empty()

# μƒνƒœ λ³€μˆ˜
if "messages" not in st.session_state:
    st.session_state.messages = []
    st.session_state.chat_mode = False

# κ³„νšμ„œ 생성 λ²„νŠΌ 클릭 μ‹œ
if generate_button:
    with st.spinner("⏳ κ³„νšμ„œ 생성 쀑..."):
        result = generate_curriculum(grade_selected, achievement_standard)
        st.session_state.messages.append({"role": "assistant", "content": result})
        st.session_state.chat_mode = True

# 챗봇 μΈν„°νŽ˜μ΄μŠ€
user_icon_url = "https://cdn-icons-png.flaticon.com/512/4323/4323008.png"
assistant_icon_url = "https://cdn-icons-png.flaticon.com/512/4712/4712108.png"

if st.session_state.chat_mode:
    if prompt := st.chat_input("κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ AIμ—κ²Œ μˆ˜μ • 및 μΆ”κ°€ μš”μ²­μ‚¬ν•­μ„ μ•Œλ €μ£Όμ„Έμš”!"):
        st.session_state.messages.append({"role": "user", "content": prompt})
        with st.spinner("πŸ€” λ‹΅λ³€ 생성 쀑..."):
            context = "\n".join([msg["content"] for msg in st.session_state.messages if msg["role"] == "assistant"])
            ai_response = chat_with_ai(prompt, context)
            st.session_state.messages.append({"role": "assistant", "content": ai_response})

    for message in st.session_state.messages:
        if message["role"] != "system":
            role_class = "chat-message-user" if message["role"] == "user" else "chat-message-assistant"
            avatar_url = user_icon_url if message["role"] == "user" else assistant_icon_url
            avatar_class = "chat-avatar-user" if message["role"] == "user" else "chat-avatar"
            html_text = markdown.markdown(message['content'], extensions=['tables', 'fenced_code'])
            st.markdown(
                f"<div class='chat-message {role_class}'><img src='{avatar_url}' class='chat-avatar {avatar_class}'>{html_text}</div>",
                unsafe_allow_html=True
            )


# FAQ (κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅μ— 맞게 μˆ˜μ •)
with st.expander("β“κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ AI FAQ"):
    st.write("""
        **Q1. κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅ AIλŠ” μ–΄λ–€ κΈ°λŠ₯을 μ œκ³΅ν•˜λ‚˜μš”?**

        A. 이 앱은 μ„ μƒλ‹˜λ“€μ˜ **κ°œλ…κΈ°λ°˜ νƒκ΅¬ν•™μŠ΅** 섀계λ₯Ό 돕기 μœ„ν•΄ 개발된 AI λ„κ΅¬μž…λ‹ˆλ‹€. ν•™λ…„κ³Ό 성취기쀀을 μž…λ ₯ν•˜λ©΄ 핡심 아이디어λ₯Ό μ€‘μ‹¬μœΌλ‘œ ν•œ νƒκ΅¬ν•™μŠ΅ κ³„νšμ„œ μ΄ˆμ•ˆμ„ μƒμ„±ν•©λ‹ˆλ‹€.  κ³„νšμ„œμ—λŠ” 핡심 아이디어, 맀크둜/마이크둜 κ°œλ…, 지식 λ²”μ£Ό, 탐ꡬ 질문, **관계맺기-μ§‘μ€‘ν•˜κΈ°-μ‘°μ‚¬ν•˜κΈ°-쑰직 및 μ •λ¦¬ν•˜κΈ°-μΌλ°˜ν™”-전이-μ„±μ°°ν•˜κΈ°**의 7단계 탐ꡬ ν™œλ™, 평가 방법, κ°œλ…μ  이해λ₯Ό μœ„ν•œ 팁 등이 ν¬ν•¨λ©λ‹ˆλ‹€.  λ‹¨μˆœνžˆ κ³„νšμ„œ μƒμ„±λΏλ§Œ μ•„λ‹ˆλΌ, μƒμ„±λœ κ³„νšμ„œλ₯Ό μˆ˜μ •ν•˜κ³  좔가적인 자료λ₯Ό μƒμ„±ν•˜λŠ” 데에도 도움을 λ“œλ¦½λ‹ˆλ‹€.

        **Q2. 7단계 νƒκ΅¬ν•™μŠ΅ κ³Όμ • μ„€κ³„λŠ” μ–΄λ–»κ²Œ μ΄λ£¨μ–΄μ§€λ‚˜μš”?**

        A.  이 AIλŠ” **관계맺기-μ§‘μ€‘ν•˜κΈ°-μ‘°μ‚¬ν•˜κΈ°-쑰직 및 μ •λ¦¬ν•˜κΈ°-μΌλ°˜ν™”-전이-μ„±μ°°ν•˜κΈ°**의 7단계 νƒκ΅¬ν•™μŠ΅ λͺ¨ν˜•을 기반으둜 ν•™μŠ΅ 과정을 μ„€κ³„ν•©λ‹ˆλ‹€. 각 λ‹¨κ³„λŠ” 학생듀이 핡심 아이디어λ₯Ό 깊이 있게 μ΄ν•΄ν•˜κ³ , 슀슀둜 지식을 κ΅¬μ„±ν•˜λ©°, μ‹€μ œ 상황에 μ μš©ν•  수 μžˆλ„λ‘ μ„€κ³„λ©λ‹ˆλ‹€. 각 단계별 ν™œλ™μ€ ν•™μƒλ“€μ˜ ν₯미와 μ°Έμ—¬λ₯Ό μœ λ„ν•˜λŠ” 창의적이고 ν˜μ‹ μ μΈ ν™œλ™μœΌλ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€.

        **Q3. κ³„νšμ„œ 생성 ν›„ μˆ˜μ •μ€ μ–΄λ–»κ²Œ ν•˜λ‚˜μš”?**

        A. κ³„νšμ„œ 생성 ν›„, ν•˜λ‹¨ 챗봇을 μ΄μš©ν•˜μ—¬ μˆ˜μ • 및 μΆ”κ°€ μš”μ²­μ‚¬ν•­μ„ μž…λ ₯ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, "μ‘°μ‚¬ν•˜κΈ° λ‹¨κ³„μ—μ„œ ν™œμš©ν•  수 μžˆλŠ” λ‹€λ₯Έ ν™œλ™μ„ μ œμ‹œν•΄μ€˜", "평가 λ£¨λΈŒλ¦­μ„ μƒμ€‘ν•˜μ— λŒ€ν•œ ꡬ체적인 μ˜ˆμ‹œμ™€ ν•¨κ»˜ μˆ˜μ •ν•΄μ€˜" 와 같이 μž…λ ₯ν•˜λ©΄ λ©λ‹ˆλ‹€.

        **Q4. 챗봇을 μ΄μš©ν•΄μ„œ μ–΄λ–€ μΆ”κ°€ 자료λ₯Ό 생성할 수 μžˆλ‚˜μš”?**

        A. 챗봇을 톡해 λ‹€μŒκ³Ό 같은 μΆ”κ°€ 자료 생성을 μš”μ²­ν•  수 μžˆμŠ΅λ‹ˆλ‹€:
        * **단계별 ν™œλ™ μΆ”κ°€:** 각 단계에 ν™œμš©ν•  수 μžˆλŠ” λ‹€μ–‘ν•œ ν™œλ™μ„ μ œμ‹œν•©λ‹ˆλ‹€. *μ˜ˆμ‹œ: "μ‘°μ‚¬ν•˜κΈ° λ‹¨κ³„μ—μ„œ ν™œμš©ν•  수 μžˆλŠ” μ‹€ν—˜ ν™œλ™μ„ μ œμ‹œν•΄ 쀘"*
        * **μˆ˜ν–‰ 과제 (GRASPS):**  Goal, Role, Audience, Situation, Product/Performance, Standards μš”μ†Œλ₯Ό ν™œμš©ν•˜μ—¬ μˆ˜ν–‰ 과제λ₯Ό μ„€κ³„ν•©λ‹ˆλ‹€. *μ˜ˆμ‹œ: "이 λ‹¨μ›μ˜ 핡심 κ°œλ…μ„ 평가할 수 μžˆλŠ” μˆ˜ν–‰ν‰κ°€λ₯Ό μ„€κ³„ν•΄μ€˜"*
        * **평가 루브릭 (상, 쀑, ν•˜ 평어):** μƒμ€‘ν•˜μ— λŒ€ν•œ ꡬ체적인 평가 κΈ°μ€€κ³Ό 각 μˆ˜μ€€μ— ν•΄λ‹Ήν•˜λŠ” 학생 μž‘μ—… λ˜λŠ” μˆ˜ν–‰ μ˜ˆμ‹œλ₯Ό ν¬ν•¨ν•œ λ£¨λΈŒλ¦­μ„ μƒμ„±ν•©λ‹ˆλ‹€. *μ˜ˆμ‹œ: "μ „μ΄ν•˜κΈ° 단계λ₯Ό 평가할 수 μžˆλŠ” λ£¨λΈŒλ¦­μ„ λ§Œλ“€μ–΄μ€˜"*
        * **κ°œλ… μ„€λͺ… 자료:** 핡심 κ°œλ…μ— λŒ€ν•œ 좔가적인 μ„€λͺ…, κ·Έλ¦Ό, μ˜μƒ 등을 μ œκ³΅ν•©λ‹ˆλ‹€. *μ˜ˆμ‹œ: "맀크둜 κ°œλ…μ— λŒ€ν•œ μ„€λͺ… 자료λ₯Ό λ§Œλ“€μ–΄μ€˜"*

        챗봇에 ꡬ체적인 μš”μ²­μ‚¬ν•­μ„ μž…λ ₯ν• μˆ˜λ‘ λ”μš± μ •ν™•ν•˜κ³  μœ μš©ν•œ κ²°κ³Όλ₯Ό 얻을 수 μžˆμŠ΅λ‹ˆλ‹€.
    """)