Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,14 @@ import openai
|
|
| 3 |
import json
|
| 4 |
from annotated_text import annotated_text
|
| 5 |
import os
|
|
|
|
| 6 |
import achivenment_standards as data
|
| 7 |
|
| 8 |
|
| 9 |
# OpenAI API 설정 (환경 변수에서 읽어옴)
|
| 10 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 11 |
|
| 12 |
-
#gpt이용해서 추론함수 만들기
|
| 13 |
def generate_annotated_text(text):
|
| 14 |
response = openai.ChatCompletion.create(
|
| 15 |
model="gpt-3.5-turbo-16k",
|
|
@@ -53,8 +54,7 @@ def generate_similar_sentences(base_sentence):
|
|
| 53 |
)
|
| 54 |
generated_sentences = response.choices[0].message['content'].split('\n')
|
| 55 |
return [sentence.strip() for sentence in generated_sentences if sentence.strip()]
|
| 56 |
-
|
| 57 |
-
|
| 58 |
# Streamlit 앱의 제목 및 설명
|
| 59 |
st.title("성취기준 기반 학생의 특성 및 활동 평가 생성")
|
| 60 |
st.write("성취기준을 입력하시면, 해당 성취기준에 기반한 학생의 특성 및 활동에 대한 평가를 \n\n [학생 활동, 성취 수준, 교사의 총평, 학생 역량] 4가지 요소를 조합하여 제공합니다.")
|
|
@@ -111,3 +111,19 @@ if st.session_state.generated_result:
|
|
| 111 |
# 유사한 문장들 출력
|
| 112 |
for sentence in st.session_state.similar_sentences:
|
| 113 |
st.write(sentence)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import json
|
| 4 |
from annotated_text import annotated_text
|
| 5 |
import os
|
| 6 |
+
import pandas as pd
|
| 7 |
import achivenment_standards as data
|
| 8 |
|
| 9 |
|
| 10 |
# OpenAI API 설정 (환경 변수에서 읽어옴)
|
| 11 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 12 |
|
| 13 |
+
# gpt이용해서 추론함수 만들기
|
| 14 |
def generate_annotated_text(text):
|
| 15 |
response = openai.ChatCompletion.create(
|
| 16 |
model="gpt-3.5-turbo-16k",
|
|
|
|
| 54 |
)
|
| 55 |
generated_sentences = response.choices[0].message['content'].split('\n')
|
| 56 |
return [sentence.strip() for sentence in generated_sentences if sentence.strip()]
|
| 57 |
+
|
|
|
|
| 58 |
# Streamlit 앱의 제목 및 설명
|
| 59 |
st.title("성취기준 기반 학생의 특성 및 활동 평가 생성")
|
| 60 |
st.write("성취기준을 입력하시면, 해당 성취기준에 기반한 학생의 특성 및 활동에 대한 평가를 \n\n [학생 활동, 성취 수준, 교사의 총평, 학생 역량] 4가지 요소를 조합하여 제공합니다.")
|
|
|
|
| 111 |
# 유사한 문장들 출력
|
| 112 |
for sentence in st.session_state.similar_sentences:
|
| 113 |
st.write(sentence)
|
| 114 |
+
|
| 115 |
+
# CSV 파일로 저장하는 버튼 추가
|
| 116 |
+
if st.session_state.similar_sentences:
|
| 117 |
+
# 데이터프레임 생성
|
| 118 |
+
df = pd.DataFrame(st.session_state.similar_sentences, columns=["Similar Sentences"])
|
| 119 |
+
|
| 120 |
+
# CSV 파일로 변환
|
| 121 |
+
csv = df.to_csv(index=False).encode('utf-8')
|
| 122 |
+
|
| 123 |
+
# 다운로드 버튼 생성
|
| 124 |
+
st.download_button(
|
| 125 |
+
label="CSV로 저장",
|
| 126 |
+
data=csv,
|
| 127 |
+
file_name='similar_sentences.csv',
|
| 128 |
+
mime='text/csv'
|
| 129 |
+
)
|