Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -76,14 +76,6 @@ selected_standard = st.selectbox("성취기준을 선택하세요:", selected_st
|
|
| 76 |
# 선택된 성취기준을 텍스트 입력창의 기본값으로 사용
|
| 77 |
achievement_standard = st.text_input("성취기준 입력:", value=selected_standard)
|
| 78 |
|
| 79 |
-
# 세션 상태 초기화
|
| 80 |
-
if 'selected_sentence' not in st.session_state:
|
| 81 |
-
st.session_state.selected_sentence = None
|
| 82 |
-
if 'similar_sentences' not in st.session_state:
|
| 83 |
-
st.session_state.similar_sentences = []
|
| 84 |
-
if 'selected_index' not in st.session_state:
|
| 85 |
-
st.session_state.selected_index = 0
|
| 86 |
-
|
| 87 |
# # "평가 생성" 버튼 클릭 시의 동작
|
| 88 |
# if st.button("평가 생성"):
|
| 89 |
# with st.spinner('답변 생성중...'):
|
|
@@ -115,14 +107,21 @@ if 'selected_index' not in st.session_state:
|
|
| 115 |
# for sentence in st.session_state.similar_sentences:
|
| 116 |
# st.write(sentence)
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
# "평가 생성" 버튼 클릭 시의 동작
|
| 119 |
if st.button("평가 생성"):
|
| 120 |
with st.spinner('답변 생성중...'):
|
| 121 |
result = generate_annotated_text(achievement_standard)
|
| 122 |
st.session_state.generated_result = result
|
|
|
|
| 123 |
exec(result.replace('```', ''))
|
| 124 |
|
| 125 |
-
# annotated_text 결과에서 문장만 추출
|
| 126 |
result_lines = result.split('\n')
|
| 127 |
sentences = []
|
| 128 |
for line in result_lines:
|
|
@@ -133,15 +132,15 @@ if st.button("평가 생성"):
|
|
| 133 |
sentences.append(sentence)
|
| 134 |
|
| 135 |
if sentences:
|
| 136 |
-
st.session_state.selected_sentence = st.selectbox("문장을 선택하세요:", sentences)
|
| 137 |
|
| 138 |
# 유사한 문장 생성 버튼 추가
|
| 139 |
if st.button("유사한 문구 생성") and st.session_state.get('selected_sentence'):
|
| 140 |
with st.spinner('문장 생성중...'):
|
| 141 |
-
similar_sentences = generate_similar_sentences(st.session_state.selected_sentence)
|
| 142 |
-
for generated_sentence in similar_sentences:
|
| 143 |
-
st.write(generated_sentence)
|
| 144 |
|
| 145 |
# 생성된 결과 및 유사한 문장들 출력
|
| 146 |
if st.session_state.get('generated_result'):
|
| 147 |
exec(st.session_state.generated_result.replace('```', ''))
|
|
|
|
|
|
|
|
|
| 76 |
# 선택된 성취기준을 텍스트 입력창의 기본값으로 사용
|
| 77 |
achievement_standard = st.text_input("성취기준 입력:", value=selected_standard)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# # "평가 생성" 버튼 클릭 시의 동작
|
| 80 |
# if st.button("평가 생성"):
|
| 81 |
# with st.spinner('답변 생성중...'):
|
|
|
|
| 107 |
# for sentence in st.session_state.similar_sentences:
|
| 108 |
# st.write(sentence)
|
| 109 |
|
| 110 |
+
# 세션 상태 초기화
|
| 111 |
+
if 'selected_sentence' not in st.session_state:
|
| 112 |
+
st.session_state.selected_sentence = None
|
| 113 |
+
if 'similar_sentences' not in st.session_state:
|
| 114 |
+
st.session_state.similar_sentences = []
|
| 115 |
+
|
| 116 |
# "평가 생성" 버튼 클릭 시의 동작
|
| 117 |
if st.button("평가 생성"):
|
| 118 |
with st.spinner('답변 생성중...'):
|
| 119 |
result = generate_annotated_text(achievement_standard)
|
| 120 |
st.session_state.generated_result = result
|
| 121 |
+
st.session_state.selected_sentence = None # 새로운 평가 생성시 선택된 문장 초기화
|
| 122 |
exec(result.replace('```', ''))
|
| 123 |
|
| 124 |
+
# annotated_text 결과에서 문장만 추출
|
| 125 |
result_lines = result.split('\n')
|
| 126 |
sentences = []
|
| 127 |
for line in result_lines:
|
|
|
|
| 132 |
sentences.append(sentence)
|
| 133 |
|
| 134 |
if sentences:
|
| 135 |
+
st.session_state.selected_sentence = st.selectbox("문장을 선택하세요:", sentences, key="sentence_select")
|
| 136 |
|
| 137 |
# 유사한 문장 생성 버튼 추가
|
| 138 |
if st.button("유사한 문구 생성") and st.session_state.get('selected_sentence'):
|
| 139 |
with st.spinner('문장 생성중...'):
|
| 140 |
+
st.session_state.similar_sentences = generate_similar_sentences(st.session_state.selected_sentence)
|
|
|
|
|
|
|
| 141 |
|
| 142 |
# 생성된 결과 및 유사한 문장들 출력
|
| 143 |
if st.session_state.get('generated_result'):
|
| 144 |
exec(st.session_state.generated_result.replace('```', ''))
|
| 145 |
+
for sentence in st.session_state.get('similar_sentences', []):
|
| 146 |
+
st.write(sentence)
|