File size: 3,267 Bytes
1d355ad 9a8f27f 5829c7a 22032f3 9a8f27f 1d355ad 9a8f27f 22032f3 5829c7a fabb74d 5829c7a 452a07e 5829c7a fabb74d dc2e4a1 5829c7a fabb74d 9a8f27f 5829c7a 9a8f27f 5829c7a be971e9 7468eee 9a8f27f 5829c7a 9a8f27f 5829c7a 9a8f27f 5829c7a 9a8f27f 5829c7a 9a8f27f 39688bd 03d0703 9a8f27f 5829c7a 9a8f27f | 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
# 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 2-3 descriptive evaluation questions and grading criteria for the given learning goal.
"""
prompt = f"""교육평가 전문가로서 다음 학습 목표를 참고하여 초등학교 교육과정 수준에 맞는 서술형 평가 문항을 2~3개 작성하고, 각 평가 문항에 대한 평가기준을 상, 중, 하로 제시해줘.
각 문항은 학습 목표를 정확히 평가할 수 있는 질문으로 구성하고, 평가 기준은 다음과 같이 구체적으로 작성해:
- 상: 학생이 학습 목표를 완전히 이해하고, 깊이 있는 사고와 구체적인 예시를 통해 명확하게 설명할 수 있는 경우
- 중: 학생이 학습 목표를 대부분 이해하고, 기본적인 개념을 설명할 수 있으나 예시나 설명이 다소 부족한 경우
- 하: 학생이 학습 목표를 부분적으로만 이해하고, 기본적인 설명에도 어려움을 겪는 경우
## 학습 목표
* {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)}")
|