Update app.py
Browse files
app.py
CHANGED
|
@@ -25,6 +25,7 @@ model = genai.GenerativeModel(
|
|
| 25 |
)
|
| 26 |
|
| 27 |
def generate_text(grade, num_paragraphs, sentences_per_paragraph, structure, topic):
|
|
|
|
| 28 |
prompt = f"""
|
| 29 |
초등학교 {grade}학년 학생이 이해할 수 있는 수준의 설명문을 작성.
|
| 30 |
설명문의 주제는 {topic}이며, 주제를 중심으로 {structure} 구조에 따른 설명문을 작성할 것.
|
|
@@ -42,6 +43,9 @@ def generate_text(grade, num_paragraphs, sentences_per_paragraph, structure, top
|
|
| 42 |
text_area.text_area("읽기 자료", value=full_text, height=300)
|
| 43 |
time.sleep(0.05)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
| 45 |
except Exception as e:
|
| 46 |
st.error(f"에러 발생: {str(e)}")
|
| 47 |
|
|
@@ -56,7 +60,7 @@ add_vertical_space(1)
|
|
| 56 |
|
| 57 |
with st.sidebar:
|
| 58 |
st.header("옵션 설정")
|
| 59 |
-
grade = st.selectbox("학년", [
|
| 60 |
num_paragraphs = st.number_input("문단 수", min_value=1, value=3)
|
| 61 |
sentences_per_paragraph = st.selectbox("문단 당 문장 수", ["3-4", "5-6", "6-7", "7-8", "9-10"], index=0)
|
| 62 |
structure = st.selectbox("설명문 구조", ["정의와 예시", "비교와 대조", "분류", "분석", "인과", "순서"], index=0)
|
|
@@ -68,10 +72,9 @@ if st.button("읽기 자료 생성"):
|
|
| 68 |
# Streamlit UI에 대한 장소의 text_area 출력 설정
|
| 69 |
text_area = st.empty()
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
if "
|
| 73 |
-
|
| 74 |
-
st.markdown(html_text, unsafe_allow_html=True)
|
| 75 |
|
| 76 |
if st.button("출력 내용 복사", key="copy_button"):
|
| 77 |
pyperclip.copy(st.session_state.generated_curriculum)
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
def generate_text(grade, num_paragraphs, sentences_per_paragraph, structure, topic):
|
| 28 |
+
global text_area
|
| 29 |
prompt = f"""
|
| 30 |
초등학교 {grade}학년 학생이 이해할 수 있는 수준의 설명문을 작성.
|
| 31 |
설명문의 주제는 {topic}이며, 주제를 중심으로 {structure} 구조에 따른 설명문을 작성할 것.
|
|
|
|
| 43 |
text_area.text_area("읽기 자료", value=full_text, height=300)
|
| 44 |
time.sleep(0.05)
|
| 45 |
|
| 46 |
+
# 생성된 텍스트를 세션 상태에 저장
|
| 47 |
+
st.session_state.generated_curriculum = full_text
|
| 48 |
+
|
| 49 |
except Exception as e:
|
| 50 |
st.error(f"에러 발생: {str(e)}")
|
| 51 |
|
|
|
|
| 60 |
|
| 61 |
with st.sidebar:
|
| 62 |
st.header("옵션 설정")
|
| 63 |
+
grade = st.selectbox("학년", [f"초등학교 {i}학년" for i in range(1, 7)])
|
| 64 |
num_paragraphs = st.number_input("문단 수", min_value=1, value=3)
|
| 65 |
sentences_per_paragraph = st.selectbox("문단 당 문장 수", ["3-4", "5-6", "6-7", "7-8", "9-10"], index=0)
|
| 66 |
structure = st.selectbox("설명문 구조", ["정의와 예시", "비교와 대조", "분류", "분석", "인과", "순서"], index=0)
|
|
|
|
| 72 |
# Streamlit UI에 대한 장소의 text_area 출력 설정
|
| 73 |
text_area = st.empty()
|
| 74 |
|
| 75 |
+
# 출력 내용 복사 버튼 추가 (이미 생성된 경우)
|
| 76 |
+
if "generated_text" in st.session_state and st.session_state.generated_curriculum:
|
| 77 |
+
st.text_area("생성된 읽기 자료", value=st.session_state.generated_curriculum, height=300, key="generated_text_area", disabled=True)
|
|
|
|
| 78 |
|
| 79 |
if st.button("출력 내용 복사", key="copy_button"):
|
| 80 |
pyperclip.copy(st.session_state.generated_curriculum)
|