File size: 3,664 Bytes
1d355ad
dc6c650
c1c46eb
 
 
 
 
1d355ad
c1c46eb
22032f3
 
 
c1c46eb
 
 
 
22032f3
39688bd
22032f3
c1c46eb
 
 
 
22032f3
 
c1c46eb
b49cbf4
c1c46eb
 
 
f74a421
feb03cf
c1c46eb
 
 
 
217a78d
c1c46eb
feb03cf
c1c46eb
 
 
 
 
 
 
 
 
 
 
940b028
c1c46eb
 
 
 
 
 
 
39688bd
03d0703
c1c46eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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

# Configure the generative AI model
genai.configure(api_key=os.environ["GEMINI_API_KEY"])

generation_config = {
    "temperature": 1,
    "top_p": 0.95,
    "top_k": 40,
    "max_output_tokens": 8192,
}

safety_settings = [
    {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
    {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
    {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_NONE"},
    {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
]

model = genai.GenerativeModel(
    model_name="gemini-2.5-flash",
    generation_config=generation_config,
    safety_settings=safety_settings,
)

def generate_curriculum(prompt):
    prompt_parts = [
        f"수업설계 전문가. 학년: {prompt['grade']}, 주제: {prompt['subject']}, 수업 의도: {prompt['lesson_intent']}. 수업자의 의도를 파악하여, 수업 주제 및 목표에 관한 핵심 질문 및 수업 질문을 만들어 줘, 소크라테스 산파법(교사와 학생이 질문을 계속 주고 받는)을 기반으로한 수업 계획 및 시나리오 작성.",
        "질문 1. 핵심 질문(Big Question)\n\n2. 수업 질문(inquiry question)\n\n3. 수업 도입(전시학습 상기, 동기유발, 학습 목표 및 활동 안내) 부분 시나리오\n\n4. 수업 전개(학습활동 1, 2...) 부분 시나리오\n\n5. 수업 정리(간단한 정리 퀴즈, 수업 내용 정리, 차시 예고) 부분 시나리오\n\n6. 활용할 수 있는 자료\n\n7. 평가 계획 및 수행과제(GRASPS), 평가 루브릭(상, 중, 하)\n\n8. 학습을 위한 팁",
    ]

    full_text = ""  # 초기 빈 텍스트 출력

    try:
        response = model.generate_content(prompt_parts, stream=True)
        for chunk in response:
            full_text += chunk.text
            # Convert markdown to HTML for display
            html_text = markdown.markdown(full_text, extensions=['tables'])
            output_area.markdown(html_text, unsafe_allow_html=True)
            time.sleep(0.05)
    except Exception as e:
        st.error(f"Error: {str(e)}")
        return ""

    return full_text

# Streamlit Interface
colored_header(
    label="질문이 넘치는 수업 설계",
    description="수업 주제에 대한 질문이 넘치는 수업 설계를 생성하세요!",
    color_name="red-70",
)

add_vertical_space(1)

with st.sidebar.expander("입력 설정", expanded=True):
    grade = st.selectbox("학년", ["초등학교 1학년", "초등학교 2학년", "초등학교 3학년", "초등학교 4학년", "초등학교 5학년", "초등학교 6학년"])
    subject = st.text_input("수업 주제")
    lesson_intent = st.text_input("수업 의도")

generate_button = st.button("질문이 넘치는 수업 설계 생성")

# 출력 영역 정의
output_area = st.empty()

if generate_button:
    prompt_data = {
        "grade": grade,
        "subject": subject,
        "lesson_intent": lesson_intent,
    }
    result = generate_curriculum(prompt_data)
    st.session_state.generated_activity = result

    # 복사 버튼 추가
    if result:
        if st.button("출력 내용 복사"):
            try:
                st.experimental_set_query_params(copied_text=result)
                st.success("출력 내용이 복사되었습니다!")
            except Exception as e:
                st.error(f"복사 중 오류가 발생했습니다: {str(e)}")