File size: 2,711 Bytes
1d355ad
9a8f27f
5829c7a
22032f3
9a8f27f
 
 
1d355ad
9a8f27f
22032f3
 
5829c7a
fabb74d
5829c7a
 
452a07e
5829c7a
 
fabb74d
 
 
7ba8242
5829c7a
fabb74d
 
9a8f27f
5829c7a
579eda3
5829c7a
579eda3
 
9a8f27f
 
 
 
579eda3
5829c7a
 
9a8f27f
5829c7a
9a8f27f
 
 
 
 
 
 
 
5829c7a
9a8f27f
 
 
5829c7a
9a8f27f
 
 
 
579eda3
 
9a8f27f
39688bd
03d0703
9a8f27f
 
 
 
 
579eda3
9a8f27f
 
 
 
 
 
 
5829c7a
9a8f27f
 
 
 
 
 
 
579eda3
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
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 Key 설정
genai.configure(api_key=os.environ["GEMINI_API_KEY"])

# 모델 설정
generation_config = {
    "temperature": 1,
    "top_p": 0.95,
    "top_k": 40,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain",
}

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

def generate_evaluation_questions(learning_goal):
    """
    Generates 10 diverse evaluation questions for the given learning goal.
    """
    prompt = f"""교육평가 전문가로서 다음 학습 목표를 참고하여 초등학교 교육과정 수준에 맞는 다양한 유형의 평가 문항 10개를 작성해줘.
    각 문항은 학습 목표를 정확히 평가할 수 있는 질문으로 구성하고, 다양한 평가 방식(예: 서술형, 선택형, 참/거짓 등)을 활용해 작성해.
    
    ## 학습 목표
    * {learning_goal}
    
    ## 평가 문항
    """

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

    try:
        response = model.generate_content([prompt], stream=True)
        for chunk in response:
            full_text += chunk.text
            # Convert markdown to HTML for display
            html_text = markdown.markdown(full_text, extensions=['tables'])
            evaluation_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="blue-70",
)

add_vertical_space(1)

with st.sidebar.expander("입력 설정", expanded=True):
    learning_goal = st.text_input("학습 목표")

generate_evaluation_button = st.button("평가 문항 생성")

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

if generate_evaluation_button:
    evaluation_result = generate_evaluation_questions(learning_goal)
    st.session_state.generated_evaluation = evaluation_result

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