Update app.py
Browse files
app.py
CHANGED
@@ -7,66 +7,72 @@ import os
|
|
7 |
openai.api_key = os.getenv("OPENAI_API_KEY") # ์ค์ ์ฝ๋์์ ์ฃผ์ ํด์
|
8 |
st.set_page_config(layout="wide")
|
9 |
|
10 |
-
def main():
|
11 |
-
st.title("ํ๊ตญ์ด ํ์ต์๋ฅผ ์ํ HCI tools")
|
12 |
-
|
13 |
-
col1, col2 = st.columns(2)
|
14 |
|
15 |
-
|
16 |
-
st.header("์ง๋ฌธ")
|
17 |
-
text_container = st.container() # ์ถ๊ฐ๋ ์ฝ๋
|
18 |
-
# ๋ฏธ๋ฆฌ ๊ณต๊ฐ ํ๋ณด
|
19 |
-
text_placeholder = text_container.empty()
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
user_text = """๋ฏผ์ฃผ์ฃผ์ ์ฌํ๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ ์ฐธ์ ๊ถ์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก ๋์ ํฌํ์จ์ ๋ฏผ์ฃผ์ฃผ์์ ์ ๋น์ฑ ํ๋ณด์ ๊น์ ๊ด๋ จ์ด ์๋ค.
|
23 |
-
์ ๊ฑฐ ํฌํ ์ ๋์๋ ํฌํ๊ถ ํ์ฌ๋ฅผ ํฌํ์์ ์์ ์์ฌ์ ๋งก๊ธฐ๋ โ์์ ํฌํ์ โ์ ํฌํ๊ถ ํ์ฌ๋ฅผ ๊ตญ๋ฏผ์ ์๋ฌด๋ก ๊ฐ์ฃผํ๊ณ ์ ๋นํ ์ฌ์ ์์ด ๊ธฐ๊ถํ๋ฉด ๋ฒ์ ์ ์ฌ๋ฅผ ๊ฐํ๋ โ์๋ฌด ํฌํ์ โ๊ฐ ์๋ค. ์ฐ๋ฆฌ๋๋ผ๋ ์์ ํฌํ์ ๋ฅผ ์ฑํํ๊ณ ์๋๋ฐ, ์ต๊ทผ ์น๋ฅธ ์ ๊ฑฐ์ ํ๊ท ํฌํ์จ์ด 50ํผ์ผํธ๋๋ก ๋ํ๋ฌ๋ค. ๊ฒฝ์ ๊ฐ๋ฐ ํ๋ ฅ ๊ธฐ๊ตฌ(OECD) ํ์๊ตญ ํ๊ท ์ด 70ํผ์ผํธ๋์ธ ๊ฒ์ ์๊ฐํ๋ฉด ๋งค์ฐ ๋ฎ์ ์์น๋ผ ํ ์ ์๋ค. ์ด๋ฌํ ์ํฉ์ด ์ง์๋์ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํด์ผ ํ๋ค๋ ์๊ฒฌ์ด ์ ์๋์๊ณ , ์์ ํฌํ์ ๊ฐ ๋ฏผ์ฃผ์ฃผ์์ ์์น์ ๋ง์ผ๋ฏ๋ก ์ด๋ฅผ ์ ์งํด์ผ ํ๋ค๋ ์๊ฒฌ๊ณผ ๋๋ฆฝํ๊ณ ์๋ค.
|
24 |
-
์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ์๋ ์ธก์ ๋ฎ์ ํฌํ์จ๋ก ํฌํ ๊ฒฐ๊ณผ์ ์ ๋น์ฑ์ ํ๋ณดํ์ง ๋ชปํ๋ ๋ฌธ์ ๊ฐ ๋งค์ฐ ์ฌ๊ฐํ๋ค๊ณ ์ฃผ์ฅํ๋ค. ๋ ์๋ฌด ํฌํ์ ์ ๊ฐ์ ์ฑ๊ณผ ๋ฒ์ ์ ์ฌ๊ฐ ํฌํ์จ์ ๋์ด๋ฏ๋ก ํฌํ์จ์ด ๋ฎ์์ ๋ฐ์ํ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ค๊ณ ๋ณธ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ตญ๋ฏผ ๋๋ถ๋ถ์ด ํฌํ์ ์ฐธ์ฌํ๊ฒ ๋๋ฉด ์ ์น์ธ๋ค์ด ๋ชจ๋ ๊ณ์ธต์ ์ง์ง๋ฅผ ๋ฐ๊ธฐ ์ํด ์ ์ฑ
๊ฒฝ์๋ ฅ์ ๋์ด๋ ค ํ ๊ฒ์ด๋ฏ๋ก ์ ์น ์์ธ ๊ณ์ธต์ ๋์ฑ ๊ด์ฌ์ ์๋ ํจ๊ณผ๊ฐ ์์ ๊ฒ์ด๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค.
|
25 |
-
๋ฐ๋ฉด ์๋ฌด ํฌํ์ ์ ๋ฐ๋ํ๋ ์ธก์ ํ์ฌ ์ฐ๋ฆฌ๋๋ผ์ ํฌํ์จ์ด ์ ์น ์ง๋์๋ค์ ๋ํ์ฑ์ ํผ์ํ ๋งํผ ์ฌ๊ฐํ ์ํฉ์ ์๋๋ผ๊ณ ์ฃผ์ฅํ๋ค. ๋ ํฌํ์จ์ ๋์ด๋ ๊ฒ๋ณด๋ค ๊ตญ๋ฏผ์ ์ ๋ขฐ๋ฅผ ํ๋ณตํ๋ ๊ฒ์ด ๋ ์ค์ํ๊ณ , ์๋ฏผ ๊ต์ก์ด๋ ๋ชจ์ ํฌํ ๊ต์ก ํ๋ก๊ทธ๋จ์ผ๋ก๋ ํฌํ์จ ์์น์ ๊ธฐ๋ํ ์ ์๋ค๋ฉฐ ์๋ฌด ํฌํ์ ์
|
26 |
-
"""
|
27 |
text_placeholder.write(user_text)
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
btn_keyword = st.button("ํค์๋ ์ฐพ๊ธฐ")
|
40 |
-
with cols[1]:
|
41 |
-
btn_explanation = st.button("์ถ๊ฐ ์ค๋ช
")
|
42 |
-
with cols[2]:
|
43 |
-
btn_simple = st.button("์ฌ์ด ํํ")
|
44 |
-
with cols[3]:
|
45 |
-
btn_rewrite = st.button("๋ค์ ์ฐ๊ธฐ")
|
46 |
-
# with cols[4]: # ์ฑ์ ํ๊ธฐ
|
47 |
-
# btn_score = st.button("์ฑ์ ํ๊ธฐ")
|
48 |
-
|
49 |
-
|
50 |
-
#์์ฝ ๊ฒฐ๊ณผ
|
51 |
-
with st.container():
|
52 |
-
st.header("์์ฝ ๊ฒฐ๊ณผ")
|
53 |
-
st.text_input("์์ฝ๊ฒฐ๊ณผ๋ฅผ ์ ์ถํ์ธ์.")
|
54 |
-
# ๋ฒํผ row
|
55 |
-
cols = st.columns(2)
|
56 |
-
with cols[0]:
|
57 |
-
btn_score = st.button("์ฑ์ ํ๊ธฐ")
|
58 |
-
with cols[1]:
|
59 |
-
btn_submit = st.button("์ ์ถํ๊ธฐ") # ๊ตฌ๊ธ ๋๋ผ์ด๋ธ api ์ฐ๊ฒฐ ๋ก์ง ์ถํ ์ถ๊ฐ
|
60 |
-
|
61 |
-
#์ ์ถ ๋ฒํผ ๋๋ฅด๋ฉด google drive api๋ก ์์ฝ ๊ฒฐ๊ณผ๋ฅผ ๊ตฌ๊ธ ๋๋ผ์ด๋ธ์ ์ ์ฅ
|
62 |
if btn_submit:
|
|
|
|
|
63 |
pass
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
|
|
|
|
|
|
|
|
70 |
if btn_keyword:
|
71 |
# ํค์๋ ์ฐพ๊ธฐ ๋ก์ง
|
72 |
task_description ="""You are a useful helper that generates annotated text for Python's st-annotated-text library. Your task is to identify the topic of the passage and highlight the key words needed to convey the meaning. You should be able to identify the main points. Also, please mark keywords based on the different paragraphs and headings provided in the text. The output should be formatted in the following way:
|
@@ -106,17 +112,27 @@ def main():
|
|
106 |
# ์๋ก์ด ๋ด์ฉ ๋ฃ๊ธฐ
|
107 |
with text_container:
|
108 |
exec(highlighted_text)
|
109 |
-
|
110 |
-
else:
|
111 |
-
# ๋ค๋ฅธ ๋ฒํผ์ ๋๋ ์ ๋ ์๋ ์ง๋ฌธ ๋ค์ ๋ฃ๊ธฐ
|
112 |
-
text_placeholder.empty()
|
113 |
-
text_placeholder.write(user_text)
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
if btn_explanation:
|
121 |
explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
|
122 |
|
@@ -137,8 +153,7 @@ def main():
|
|
137 |
# ์ถ๊ฐ ์ค๋ช
|
138 |
st.write(f"์ถ๊ฐ ์ค๋ช
: {explanation}")
|
139 |
pass
|
140 |
-
|
141 |
-
#์ฌ์ด ํํ
|
142 |
if btn_simple:
|
143 |
explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
|
144 |
|
@@ -159,8 +174,7 @@ def main():
|
|
159 |
# ์ฌ์ด ํํ์ผ๋ก ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
160 |
st.write(f"์ฌ์ด ๊ธ: {explanation}")
|
161 |
pass
|
162 |
-
|
163 |
-
#๋ค์ ์ฐ๊ธฐ
|
164 |
if btn_rewrite:
|
165 |
explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
|
166 |
|
@@ -180,28 +194,26 @@ def main():
|
|
180 |
|
181 |
st.write(f"๋ค์ ์ฐ๊ธฐ: {explanation}")
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
#๋ฃจ๋ธ๋ฆญ ๊ธฐ์ค ์ถ๊ฐ
|
186 |
-
lubric = """1. ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ๊ณ , ์ฃผ์ ๋ด์ฉ์ ํ์
ํ ์ ์์ด์ผ ํ๋ค."""
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
203 |
|
204 |
-
st.write(f"์ฑ์ ํ๊ธฐ: {explanation}")
|
205 |
|
206 |
if __name__ == "__main__":
|
207 |
main()
|
|
|
7 |
openai.api_key = os.getenv("OPENAI_API_KEY") # ์ค์ ์ฝ๋์์ ์ฃผ์ ํด์
|
8 |
st.set_page_config(layout="wide")
|
9 |
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
col, _ = st.columns(2)
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
def display_passage(col):
|
14 |
+
st.header("์ง๋ฌธ")
|
15 |
+
global text_container
|
16 |
+
text_container = st.container() # ์ถ๊ฐ๋ ์ฝ๋
|
17 |
+
# ๋ฏธ๋ฆฌ ๊ณต๊ฐ ํ๋ณด
|
18 |
+
global text_placeholder
|
19 |
+
text_placeholder = text_container.empty()
|
20 |
+
global user_text
|
21 |
user_text = """๋ฏผ์ฃผ์ฃผ์ ์ฌํ๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ ์ฐธ์ ๊ถ์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก ๋์ ํฌํ์จ์ ๋ฏผ์ฃผ์ฃผ์์ ์ ๋น์ฑ ํ๋ณด์ ๊น์ ๊ด๋ จ์ด ์๋ค.
|
22 |
+
์ ๊ฑฐ ํฌํ ์ ๋์๋ ํฌํ๊ถ ํ์ฌ๋ฅผ ํฌํ์์ ์์ ์์ฌ์ ๋งก๊ธฐ๋ โ์์ ํฌํ์ โ์ ํฌํ๊ถ ํ์ฌ๋ฅผ ๊ตญ๋ฏผ์ ์๋ฌด๋ก ๊ฐ์ฃผํ๊ณ ์ ๋นํ ์ฌ์ ์์ด ๊ธฐ๊ถํ๋ฉด ๋ฒ์ ์ ์ฌ๋ฅผ ๊ฐํ๋ โ์๋ฌด ํฌํ์ โ๊ฐ ์๋ค. ์ฐ๋ฆฌ๋๋ผ๋ ์์ ํฌํ์ ๋ฅผ ์ฑํํ๊ณ ์๋๋ฐ, ์ต๊ทผ ์น๋ฅธ ์ ๊ฑฐ์ ํ๊ท ํฌํ์จ์ด 50ํผ์ผํธ๋๋ก ๋ํ๋ฌ๋ค. ๊ฒฝ์ ๊ฐ๋ฐ ํ๋ ฅ ๊ธฐ๊ตฌ(OECD) ํ์๊ตญ ํ๊ท ์ด 70ํผ์ผํธ๋์ธ ๊ฒ์ ์๊ฐํ๋ฉด ๋งค์ฐ ๋ฎ์ ์์น๋ผ ํ ์ ์๋ค. ์ด๋ฌํ ์ํฉ์ด ์ง์๋์ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํด์ผ ํ๋ค๋ ์๊ฒฌ์ด ์ ์๋์๊ณ , ์์ ํฌํ์ ๊ฐ ๋ฏผ์ฃผ์ฃผ์์ ์์น์ ๋ง์ผ๋ฏ๋ก ์ด๋ฅผ ์ ์งํด์ผ ํ๋ค๋ ์๊ฒฌ๊ณผ ๋๋ฆฝํ๊ณ ์๋ค.
|
23 |
+
์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ์๋ ์ธก์ ๋ฎ์ ํฌํ์จ๋ก ํฌํ ๊ฒฐ๊ณผ์ ์ ๋น์ฑ์ ํ๋ณดํ์ง ๋ชปํ๋ ๋ฌธ์ ๊ฐ ๋งค์ฐ ์ฌ๊ฐํ๋ค๊ณ ์ฃผ์ฅํ๋ค. ๋ ์๋ฌด ํฌํ์ ์ ๊ฐ์ ์ฑ๊ณผ ๋ฒ์ ์ ์ฌ๊ฐ ํฌํ์จ์ ๋์ด๋ฏ๋ก ํฌํ์จ์ด ๋ฎ์์ ๋ฐ์ํ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ค๊ณ ๋ณธ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ตญ๋ฏผ ๋๋ถ๋ถ์ด ํฌํ์ ์ฐธ์ฌํ๊ฒ ๋๋ฉด ์ ์น์ธ๋ค์ด ๋ชจ๋ ๊ณ์ธต์ ์ง์ง๋ฅผ ๋ฐ๊ธฐ ์ํด ์ ์ฑ
๊ฒฝ์๋ ฅ์ ๋์ด๋ ค ํ ๊ฒ์ด๋ฏ๋ก ์ ์น ์์ธ ๊ณ์ธต์ ๋์ฑ ๊ด์ฌ์ ์๋ ํจ๊ณผ๊ฐ ์์ ๊ฒ์ด๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค.
|
24 |
+
๋ฐ๋ฉด ์๋ฌด ํฌํ์ ์ ๋ฐ๋ํ๋ ์ธก์ ํ์ฌ ์ฐ๋ฆฌ๋๋ผ์ ํฌํ์จ์ด ์ ์น ์ง๋์๋ค์ ๋ํ์ฑ์ ํผ์ํ ๋งํผ ์ฌ๊ฐํ ์ํฉ์ ์๋๋ผ๊ณ ์ฃผ์ฅํ๋ค. ๋ ํฌํ์จ์ ๋์ด๋ ๊ฒ๋ณด๋ค ๊ตญ๋ฏผ์ ์ ๋ขฐ๋ฅผ ํ๋ณตํ๋ ๊ฒ์ด ๋ ์ค์ํ๊ณ , ์๋ฏผ ๊ต์ก์ด๋ ๋ชจ์ ํฌํ ๊ต์ก ํ๋ก๊ทธ๋จ์ผ๋ก๋ ํฌํ์จ ์์น์ ๊ธฐ๋ํ ์ ์๋ค๋ฉฐ ์๋ฌด ํฌํ์ ์ ๋์
๋ง๏ฟฝ๏ฟฝ ํฌํ์จ์ด๋ ์ ์น์ ๊ด์ฌ์ ๋์ด๋ ํด๊ฒฐ ๋ฐฉ์์ ์๋๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ๋ฉด, ์ ์ถ๋ ์ ์น์ธ๋ค์ด ๋์ ํฌํ์จ์ ํ๊ณ๋ก ์ํ๋ฌด์ธ์ ํ๋๋ฅผ ๊ฐ๋ ๋ถ์์ฉ์ด ์๊ธด๋ค๋ ๊ฐ ํ๋ณด์๋ฅผ ์ ๋ชจ๋ฅด๋ ์ํ์์ ํฌํํ๋ ์ผ์ด ๋ฐ์ํ์ฌ ๊ตญ๋ฏผ์ ๋ป์ด ์คํ๋ ค ์๊ณก๋ ์ ์๋ค๋ฉฐ ์ฐ๋ ค์ ๋ชฉ์๋ฆฌ๋ฅผ ๋ด๊ณ ์๋ค.
|
25 |
+
"""
|
26 |
text_placeholder.write(user_text)
|
27 |
+
#์ ์ธํ ๋ณ์ ๋ค๋ฅธ ํจ์์์ ์ฌ์ฉ๊ฐ๋ฅํ๊ฒ ํ๊ธฐ ์ํด return
|
28 |
+
return text_placeholder, text_container, user_text
|
29 |
|
30 |
+
|
31 |
+
def display_summary(col):
|
32 |
+
st.header("์์ฝ ๊ฒฐ๊ณผ")
|
33 |
+
global user_summary
|
34 |
+
user_summary = st.text_area("์์ฝ๊ฒฐ๊ณผ๋ฅผ ์ ์ถํ์ธ์.")
|
35 |
+
|
36 |
+
cols = st.columns(2)
|
37 |
+
with cols[0]:
|
38 |
+
btn_submit = st.button("์ ์ถ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
if btn_submit:
|
40 |
+
#๊ตฌ๊ธ ๋๋ผ์ด๋ธ api ์ฐ๊ฒฐ ๋ก์ง ์ถํ ์ถ๊ฐ
|
41 |
+
st.write("์ ์ถ ๋์์ต๋๋ค.")
|
42 |
pass
|
43 |
|
44 |
+
with cols[1]:
|
45 |
+
btn_score = st.button("์ฑ์ ํ๊ธฐ")
|
46 |
+
if btn_score:
|
47 |
+
#๋ฃจ๋ธ๋ฆญ์ ์ํ ์ฑ์
|
48 |
+
lubric = """์ฑ์ ๊ธฐ์ค ์: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ๊ณ , ์ฃผ์ ๋ด์ฉ์ ํ์
ํ ์ ์๋ค. ์ค: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค. ํ: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค."""
|
49 |
+
#๋ฃจ๋ธ๋ฆญ ๊ธฐ์ค์ ์ด์ฉํด์ ์
๋ ฅ์นธ์ ์
๋ ฅํ ๋ด์ฉ์ ์ฑ์ ํ๋ ์์ด๋ก ํ๋กฌํํธ
|
50 |
+
explanation_task = f"{lubric}์ ๊ธฐ์ค์ผ๋ก {user_summary}์ ๋ด์ฉ์ ์ฑ์ ํด์ฃผ์ธ์. ์ฑ์ ๊ธฐ์ค์ ๊ณต๊ฐํ์ง ๋ง๊ณ ์, ์ค,ํ๋ก ๋๋๊ณ ๊ฐ๋จํ ์ด์ ๋ฅผ ์๋ ค์ฃผ์ธ์."
|
51 |
+
messages = [
|
52 |
+
{"role": "system", "content": "You are a helpful assistant. use only korean"},
|
53 |
+
{"role": "user", "content": explanation_task}
|
54 |
+
]
|
55 |
|
56 |
+
response = openai.ChatCompletion.create(
|
57 |
+
model="gpt-3.5-turbo-16k",
|
58 |
+
messages=messages,
|
59 |
+
temperature=0.1,
|
60 |
+
max_tokens=2500
|
61 |
+
)
|
62 |
+
|
63 |
+
explanation = response['choices'][0]['message']['content']
|
64 |
+
st.write(f"์ฑ์ ํ๊ธฐ: {explanation}")
|
65 |
+
|
66 |
+
def display_input_btns(col):
|
67 |
+
st.header("์ธ๊ณต์ง๋ฅ ์ฌ์ฉํ๊ธฐ")
|
68 |
+
global user_input
|
69 |
+
user_input = st.text_area("๋ด์ฉ์ ๋ฃ๊ณ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์:", "")
|
70 |
+
st.write(user_input)
|
71 |
|
72 |
+
# ๋ฒํผ row
|
73 |
+
cols = st.columns(4)
|
74 |
+
with cols[0]:
|
75 |
+
btn_keyword = st.button("ํค์๋ ์ฐพ๊ธฐ")
|
76 |
if btn_keyword:
|
77 |
# ํค์๋ ์ฐพ๊ธฐ ๋ก์ง
|
78 |
task_description ="""You are a useful helper that generates annotated text for Python's st-annotated-text library. Your task is to identify the topic of the passage and highlight the key words needed to convey the meaning. You should be able to identify the main points. Also, please mark keywords based on the different paragraphs and headings provided in the text. The output should be formatted in the following way:
|
|
|
112 |
# ์๋ก์ด ๋ด์ฉ ๋ฃ๊ธฐ
|
113 |
with text_container:
|
114 |
exec(highlighted_text)
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
+
with cols[1]:
|
117 |
+
global btn_explanation
|
118 |
+
btn_explanation= st.button("์ถ๊ฐ ์ค๋ช
")
|
119 |
+
|
120 |
+
with cols[2]:
|
121 |
+
global btn_simple
|
122 |
+
btn_simple = st.button("์ฌ์ด ํํ")
|
123 |
+
|
124 |
|
125 |
+
with cols[3]:
|
126 |
+
global btn_rewrite
|
127 |
+
btn_rewrite = st.button("๋ค์ ์ฐ๊ธฐ")
|
128 |
+
|
129 |
+
|
130 |
+
return btn_keyword, btn_explanation, btn_simple, btn_rewrite
|
131 |
+
|
132 |
+
|
133 |
+
def display_output():
|
134 |
+
with st.container():
|
135 |
+
st.header("๊ฒฐ๊ณผ")
|
136 |
if btn_explanation:
|
137 |
explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
|
138 |
|
|
|
153 |
# ์ถ๊ฐ ์ค๋ช
|
154 |
st.write(f"์ถ๊ฐ ์ค๋ช
: {explanation}")
|
155 |
pass
|
156 |
+
|
|
|
157 |
if btn_simple:
|
158 |
explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
|
159 |
|
|
|
174 |
# ์ฌ์ด ํํ์ผ๋ก ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
175 |
st.write(f"์ฌ์ด ๊ธ: {explanation}")
|
176 |
pass
|
177 |
+
|
|
|
178 |
if btn_rewrite:
|
179 |
explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
|
180 |
|
|
|
194 |
|
195 |
st.write(f"๋ค์ ์ฐ๊ธฐ: {explanation}")
|
196 |
|
197 |
+
#๊ฒฐ๊ณผ ๋ถ๋ถ์ ๋ฒํผ ์ถ๋ ฅ ์ถ๊ฐ
|
198 |
+
|
|
|
|
|
199 |
|
200 |
+
def main():
|
201 |
+
st.title("ํ๊ตญ์ด ํ์ต์๋ฅผ ์ํ HCI tools")
|
202 |
+
|
203 |
+
col1, col2 = st.columns(2)
|
204 |
+
|
205 |
+
with col1:
|
206 |
+
display_passage(col1)
|
207 |
+
display_summary(col1)
|
208 |
+
with col2:
|
209 |
+
btn_keyword, btn_explanation, btn_simple, btn_rewrite = display_input_btns(col2)
|
210 |
+
display_output()
|
211 |
+
|
212 |
+
|
213 |
+
# # ํ๋จ ์ปจํ
์ด๋
|
214 |
+
# with st.container():
|
215 |
+
# st.header("๊ฒฐ๊ณผ")
|
216 |
|
|
|
217 |
|
218 |
if __name__ == "__main__":
|
219 |
main()
|