add point system
Browse files
app.py
CHANGED
@@ -8,6 +8,22 @@ 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):
|
@@ -43,7 +59,8 @@ def display_summary(col):
|
|
43 |
|
44 |
with cols[1]:
|
45 |
btn_score = st.button("์ฑ์ ํ๊ธฐ")
|
46 |
-
if btn_score:
|
|
|
47 |
#๋ฃจ๋ธ๋ฆญ์ ์ํ ์ฑ์
|
48 |
lubric = """์ฑ์ ๊ธฐ์ค ์: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ๊ณ , ์ฃผ์ ๋ด์ฉ์ ํ์
ํ ์ ์๋ค. ์ค: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค. ํ: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค."""
|
49 |
#๋ฃจ๋ธ๋ฆญ ๊ธฐ์ค์ ์ด์ฉํด์ ์
๋ ฅ์นธ์ ์
๋ ฅํ ๋ด์ฉ์ ์ฑ์ ํ๋ ์์ด๋ก ํ๋กฌํํธ
|
@@ -62,6 +79,12 @@ def display_summary(col):
|
|
62 |
|
63 |
explanation = response['choices'][0]['message']['content']
|
64 |
st.write(f"์ฑ์ ํ๊ธฐ: {explanation}")
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
def display_input_btns(col):
|
67 |
st.header("์ธ๊ณต์ง๋ฅ ์ฌ์ฉํ๊ธฐ")
|
@@ -72,7 +95,8 @@ def display_input_btns(col):
|
|
72 |
cols = st.columns(4)
|
73 |
with cols[0]:
|
74 |
btn_keyword = st.button("ํค์๋ ์ฐพ๊ธฐ")
|
75 |
-
if btn_keyword:
|
|
|
76 |
#๋ค๋ฅธ ์ง๋ฌธ ๋ฃ๊ธฐ
|
77 |
highlighted_text = """**๋ฏผ์ฃผ์ฃผ์ ์ฌํ**๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ **์ฐธ์ ๊ถ**์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก **๋์ ํฌํ์จ**์ ๋ฏผ์ฃผ์ฃผ์์ **์ ๋น์ฑ ํ๋ณด**์ ๊น์ ๊ด๋ จ์ด ์๋ค.
|
78 |
|
@@ -82,25 +106,39 @@ def display_input_btns(col):
|
|
82 |
|
83 |
๋ฐ๋ฉด **์๋ฌด ํฌํ์ ์ ๋ฐ๋ํ๋ ์ธก**์ ํ์ฌ ์ฐ๋ฆฌ๋๋ผ์ ํฌํ์จ์ด ์ ์น ์ง๋์๋ค์ ๋ํ์ฑ์ ํผ์ํ ๋งํผ ์ฌ๊ฐํ ์ํฉ์ ์๋๋ผ๊ณ ์ฃผ์ฅํ๋ค. ๋ ํฌํ์จ์ ๋์ด๋ ๊ฒ๋ณด๋ค **๊ตญ๋ฏผ์ ์ ๋ขฐ๋ฅผ ํ๋ณต**ํ๋ ๊ฒ์ด ๋ ์ค์ํ๊ณ , ์๋ฏผ ๊ต์ก์ด๋ ๋ชจ์ ํฌํ ๊ต์ก ํ๋ก๊ทธ๋จ์ผ๋ก๋ ํฌํ์จ ์์น์ ๊ธฐ๋ํ ์ ์๋ค๋ฉฐ ์๋ฌด ํฌํ์ ์ ๋์
๋ง์ด ํฌํ์จ์ด๋ ์ ์น์ ๊ด์ฌ์ ๋์ด๋ ํด๊ฒฐ ๋ฐฉ์์ ์๋๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ๋ฉด, ์ ์ถ๋ ์ ์น์ธ๋ค์ด ๋์ ํฌํ์จ์ ํ๊ณ๋ก **์ํ๋ฌด์ธ์ ํ๋**๋ฅผ ๊ฐ๋ ๋ถ์์ฉ์ด ์๊ธด๋ค๋ ๊ฐ ํ๋ณด์๋ฅผ ์ ๋ชจ๋ฅด๋ ์ํ์์ ํฌํํ๋ ์ผ์ด ๋ฐ์ํ์ฌ **๊ตญ๋ฏผ์ ๋ป์ด ์คํ๋ ค ์๊ณก**๋ ์ ์๋ค๋ฉฐ ์ฐ๋ ค์ ๋ชฉ์๋ฆฌ๋ฅผ ๋ด๊ณ ์๋ค.
|
84 |
"""
|
|
|
|
|
|
|
85 |
|
86 |
# ๊ธฐ์กด ์ง๋ฌธ ์ง์ฐ๊ธฐ
|
87 |
text_placeholder.empty()
|
88 |
-
#
|
89 |
with text_container:
|
90 |
-
st.markdown(highlighted_text)
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
with cols[1]:
|
93 |
global btn_explanation
|
94 |
btn_explanation= st.button("์ถ๊ฐ ์ค๋ช
")
|
95 |
-
|
|
|
|
|
96 |
with cols[2]:
|
97 |
global btn_simple
|
98 |
btn_simple = st.button("์ฌ์ด ํํ")
|
|
|
|
|
99 |
|
100 |
|
101 |
with cols[3]:
|
102 |
global btn_rewrite
|
103 |
btn_rewrite = st.button("๋ค์ ์ฐ๊ธฐ")
|
|
|
|
|
104 |
|
105 |
|
106 |
return btn_keyword, btn_explanation, btn_simple, btn_rewrite
|
@@ -109,7 +147,7 @@ def display_input_btns(col):
|
|
109 |
def display_output():
|
110 |
with st.container():
|
111 |
st.header("๊ฒฐ๊ณผ")
|
112 |
-
if btn_explanation:
|
113 |
explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
|
114 |
|
115 |
messages = [
|
@@ -129,8 +167,14 @@ def display_output():
|
|
129 |
# ์ถ๊ฐ ์ค๋ช
|
130 |
st.write(f"์ถ๊ฐ ์ค๋ช
: {explanation}")
|
131 |
pass
|
|
|
|
|
|
|
|
|
132 |
|
133 |
-
|
|
|
|
|
134 |
explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
|
135 |
|
136 |
messages = [
|
@@ -150,8 +194,12 @@ def display_output():
|
|
150 |
# ์ฌ์ด ํํ์ผ๋ก ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
151 |
st.write(f"์ฌ์ด ๊ธ: {explanation}")
|
152 |
pass
|
|
|
|
|
|
|
|
|
153 |
|
154 |
-
if btn_rewrite:
|
155 |
explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
|
156 |
|
157 |
messages = [
|
@@ -169,13 +217,19 @@ def display_output():
|
|
169 |
explanation = response['choices'][0]['message']['content']
|
170 |
|
171 |
st.write(f"๋ค์ ์ฐ๊ธฐ: {explanation}")
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
|
175 |
|
176 |
def main():
|
177 |
st.title("ํ๊ตญ์ด ํ์ต์๋ฅผ ์ํ HCI tools")
|
178 |
-
|
|
|
|
|
179 |
col1, col2 = st.columns(2)
|
180 |
|
181 |
with col1:
|
@@ -184,7 +238,8 @@ def main():
|
|
184 |
with col2:
|
185 |
btn_keyword, btn_explanation, btn_simple, btn_rewrite = display_input_btns(col2)
|
186 |
display_output()
|
187 |
-
|
|
|
188 |
|
189 |
|
190 |
if __name__ == "__main__":
|
|
|
8 |
st.set_page_config(layout="wide")
|
9 |
|
10 |
|
11 |
+
## ํฌ์ธํธ ๋ถ๋ถ ์ถ๊ฐ
|
12 |
+
if 'points' not in st.session_state:
|
13 |
+
st.session_state.points = 3
|
14 |
+
|
15 |
+
def update_points(value):
|
16 |
+
""" ํฌ์ธํธ ์
๋ฐ์ดํธ """
|
17 |
+
st.session_state.points += value
|
18 |
+
# display_points() # ํฌ์ธํธ๋ฅผ ์ค์๊ฐ์ผ๋ก ์
๋ฐ์ดํธ ํ๊ธฐ ์ํด
|
19 |
+
|
20 |
+
def display_points():
|
21 |
+
""" ํฌ์ธํธ ํ์ """
|
22 |
+
st.sidebar.header(f"Current Points: {st.session_state.points}")
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
##๊ธฐ๋ฅ์ ํจ์๋ก ๋๋์ด์ ๊ตฌํ
|
27 |
col, _ = st.columns(2)
|
28 |
|
29 |
def display_passage(col):
|
|
|
59 |
|
60 |
with cols[1]:
|
61 |
btn_score = st.button("์ฑ์ ํ๊ธฐ")
|
62 |
+
if btn_score and st.session_state.points > 0: # ํฌ์ธํธ ์ฒดํฌ
|
63 |
+
update_points(1) # ํฌ์ธํธ ์ฆ๊ฐ
|
64 |
#๋ฃจ๋ธ๋ฆญ์ ์ํ ์ฑ์
|
65 |
lubric = """์ฑ์ ๊ธฐ์ค ์: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ๊ณ , ์ฃผ์ ๋ด์ฉ์ ํ์
ํ ์ ์๋ค. ์ค: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค. ํ: ๋ฌธ์ฅ์ ์ฃผ์ ๋ฅผ ํ์
ํ ์ ์๋ค."""
|
66 |
#๋ฃจ๋ธ๋ฆญ ๊ธฐ์ค์ ์ด์ฉํด์ ์
๋ ฅ์นธ์ ์
๋ ฅํ ๋ด์ฉ์ ์ฑ์ ํ๋ ์์ด๋ก ํ๋กฌํํธ
|
|
|
79 |
|
80 |
explanation = response['choices'][0]['message']['content']
|
81 |
st.write(f"์ฑ์ ํ๊ธฐ: {explanation}")
|
82 |
+
pass
|
83 |
+
else:
|
84 |
+
if st.session_state.points == 0:
|
85 |
+
#ํฌ์ธํธ๊ฐ ์์ด์ ์ฌ์ฉํ ์ ์๋ค๋ ๋ฌธ๊ตฌ ์ถ๊ฐ
|
86 |
+
st.write("ํฌ์ธํธ๊ฐ ์์ด์ ์ฑ์ ํ๊ธฐ๋ฅผ ํ ์ ์์ต๋๋ค.")
|
87 |
+
pass
|
88 |
|
89 |
def display_input_btns(col):
|
90 |
st.header("์ธ๊ณต์ง๋ฅ ์ฌ์ฉํ๊ธฐ")
|
|
|
95 |
cols = st.columns(4)
|
96 |
with cols[0]:
|
97 |
btn_keyword = st.button("ํค์๋ ์ฐพ๊ธฐ")
|
98 |
+
if btn_keyword and st.session_state.points > 0: # ํฌ์ธํธ ์ฒดํฌ
|
99 |
+
update_points(-1) # ํฌ์ธํธ ๊ฐ์
|
100 |
#๋ค๋ฅธ ์ง๋ฌธ ๋ฃ๊ธฐ
|
101 |
highlighted_text = """**๋ฏผ์ฃผ์ฃผ์ ์ฌํ**๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ **์ฐธ์ ๊ถ**์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก **๋์ ํฌํ์จ**์ ๋ฏผ์ฃผ์ฃผ์์ **์ ๋น์ฑ ํ๋ณด**์ ๊น์ ๊ด๋ จ์ด ์๋ค.
|
102 |
|
|
|
106 |
|
107 |
๋ฐ๋ฉด **์๋ฌด ํฌํ์ ์ ๋ฐ๋ํ๋ ์ธก**์ ํ์ฌ ์ฐ๋ฆฌ๋๋ผ์ ํฌํ์จ์ด ์ ์น ์ง๋์๋ค์ ๋ํ์ฑ์ ํผ์ํ ๋งํผ ์ฌ๊ฐํ ์ํฉ์ ์๋๋ผ๊ณ ์ฃผ์ฅํ๋ค. ๋ ํฌํ์จ์ ๋์ด๋ ๊ฒ๋ณด๋ค **๊ตญ๋ฏผ์ ์ ๋ขฐ๋ฅผ ํ๋ณต**ํ๋ ๊ฒ์ด ๋ ์ค์ํ๊ณ , ์๋ฏผ ๊ต์ก์ด๋ ๋ชจ์ ํฌํ ๊ต์ก ํ๋ก๊ทธ๋จ์ผ๋ก๋ ํฌํ์จ ์์น์ ๊ธฐ๋ํ ์ ์๋ค๋ฉฐ ์๋ฌด ํฌํ์ ์ ๋์
๋ง์ด ํฌํ์จ์ด๋ ์ ์น์ ๊ด์ฌ์ ๋์ด๋ ํด๊ฒฐ ๋ฐฉ์์ ์๋๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ๋ฉด, ์ ์ถ๋ ์ ์น์ธ๋ค์ด ๋์ ํฌํ์จ์ ํ๊ณ๋ก **์ํ๋ฌด์ธ์ ํ๋**๋ฅผ ๊ฐ๋ ๋ถ์์ฉ์ด ์๊ธด๋ค๋ ๊ฐ ํ๋ณด์๋ฅผ ์ ๋ชจ๋ฅด๋ ์ํ์์ ํฌํํ๋ ์ผ์ด ๋ฐ์ํ์ฌ **๊ตญ๋ฏผ์ ๋ป์ด ์คํ๋ ค ์๊ณก**๋ ์ ์๋ค๋ฉฐ ์ฐ๋ ค์ ๋ชฉ์๋ฆฌ๋ฅผ ๋ด๊ณ ์๋ค.
|
108 |
"""
|
109 |
+
# highlighted_text = annotated_text(
|
110 |
+
# ("๋ฏผ์ฃผ์ฃผ์ ์ฌํ", ""), "๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ ", ("์ฐธ์ ๊ถ", ""), "์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก ", ("๋์ ํฌํ์จ", ""), "์ ๋ฏผ์ฃผ์ฃผ์์ ", ("์ ๋น์ฑ ํ๋ณด", ""), "์ ๊น์ ๊ด๋ จ์ด ์๋ค.\n\n", ("์ ๊ฑฐ ํฌํ ์ ๋", ""), "์๋ ํฌํ๊ถ ํ์ฌ๋ฅผ ํฌํ์์ ์์ ์์ฌ์ ๋งก๊ธฐ๋ โ", ("์์ ํฌํ์ ", ""), "โ์ ํฌํ๊ถ ํ์ฌ๋ฅผ ๊ตญ๋ฏผ์ ์๋ฌด๋ก ๊ฐ์ฃผํ๊ณ ์ ๋นํ ์ฌ์ ์์ด ๊ธฐ๊ถํ๋ฉด ๋ฒ์ ์ ์ฌ๋ฅผ ๊ฐํ๋ โ", ("์๋ฌด ํฌํ์ ", ""), "โ๊ฐ ์๋ค. ์ฐ๋ฆฌ๋๋ผ๋ ์์ ํฌํ์ ๋ฅผ ์ฑํํ๊ณ ์๋๋ฐ, ์ต๊ทผ ์น๋ฅธ ์ ๊ฑฐ์ ํ๊ท ํฌํ์จ์ด 50ํผ์ผํธ๋๋ก ๋ํ๋ฌ๋ค. ๊ฒฝ์ ๊ฐ๋ฐ ํ๋ ฅ ๊ธฐ๊ตฌ(", ("OECD", ""), ") ํ์๊ตญ ํ๊ท ์ด 70ํผ์ผํธ๋์ธ ๊ฒ์ ์๊ฐํ๋ฉด ๋งค์ฐ ๋ฎ์ ์์น๋ผ ํ ์ ์๋ค. ์ด๋ฌํ ์ํฉ์ด ์ง์๋์ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํด์ผ ํ๋ค๋ ์๊ฒฌ์ด ์ ์๋์๊ณ , ์์ ํฌํ์ ๊ฐ ๋ฏผ์ฃผ์ฃผ์์ ์์น์ ๋ง์ผ๋ฏ๋ก ์ด๋ฅผ ์ ์งํด์ผ ํ๋ค๋ ์๊ฒฌ๊ณผ ๋๋ฆฝํ๊ณ ์๋ค.\n\n", ("์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ์๋ ์ธก", ""), "์ ๋ฎ์ ํฌํ์จ๋ก ํฌํ ๊ฒฐ๊ณผ์ ", ("์ ๋น์ฑ์ ํ๋ณด", ""), "ํ์ง ๋ชปํ๋ ๋ฌธ์ ๊ฐ ๋งค์ฐ ์ฌ๊ฐํ๋ค๊ณ ์ฃผ์ฅํ๋ค. ๋ ์๋ฌด ํฌํ์ ์ ๊ฐ์ ์ฑ๊ณผ ๋ฒ์ ์ ์ฌ๊ฐ ํฌํ์จ์ ๋์ด๋ฏ๋ก ํฌํ์จ์ด ๋ฎ์์ ๋ฐ์ํ๋ ๋ฌธ์ ๏ฟฝ๏ฟฝ๏ฟฝ ํด๊ฒฐํ ์ ์๋ค๊ณ ๋ณธ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ตญ๋ฏผ ๋๋ถ๋ถ์ด ํฌํ์ ์ฐธ์ฌํ๊ฒ ๋๋ฉด ์ ์น์ธ๋ค์ด ๋ชจ๋ ๊ณ์ธต์ ์ง์ง๋ฅผ ๋ฐ๊ธฐ ์ํด ์ ์ฑ
๊ฒฝ์๋ ฅ์ ๋์ด๋ ค ํ ๊ฒ์ด๋ฏ๋ก ", ("์ ์น ์์ธ ๊ณ์ธต", ""), "์ ๋์ฑ ๊ด์ฌ์ ์๋ ํจ๊ณผ๊ฐ ์์ ๊ฒ์ด๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค.\n\n๋ฐ๋ฉด ", ("์๋ฌด ํฌํ์ ์ ๋ฐ๋ํ๋ ์ธก", ""), "์ ํ์ฌ ์ฐ๋ฆฌ๋๋ผ์ ํฌํ์จ์ด ์ ์น ์ง๋์๋ค์ ๋ํ์ฑ์ ํผ์ํ ๋งํผ ์ฌ๊ฐํ ์ํฉ์ ์๋๋ผ๊ณ ์ฃผ์ฅํ๋ค. ๋ ํฌํ์จ์ ๋์ด๋ ๊ฒ๋ณด๋ค ", ("๊ตญ๋ฏผ์ ์ ๋ขฐ๋ฅผ ํ๋ณต", ""), "ํ๋ ๊ฒ์ด ๋ ์ค์ํ๊ณ , ์๋ฏผ ๊ต์ก์ด๋ ๋ชจ์ ํฌํ ๊ต์ก ํ๋ก๊ทธ๋จ์ผ๋ก๋ ํฌํ์จ ์์น์ ๊ธฐ๋ํ ์ ์๋ค๋ฉฐ ์๋ฌด ํฌํ์ ์ ๋์
๋ง์ด ํฌํ์จ์ด๋ ์ ์น์ ๊ด์ฌ์ ๋์ด๋ ํด๊ฒฐ ๋ฐฉ์์ ์๋๋ผ๊ณ ์ด์ผ๊ธฐํ๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ฌด ํฌํ์ ๋ฅผ ๋์
ํ๋ฉด, ์ ์ถ๋ ์ ์น์ธ๋ค์ด ๋์ ํฌํ์จ์ ํ๊ณ๋ก ", ("์ํ๋ฌด์ธ์ ํ๋", ""), "๋ฅผ ๊ฐ๋ ๋ถ์์ฉ์ด ์๊ธด๋ค๋ ๊ฐ ํ๋ณด์๋ฅผ ์ ๋ชจ๋ฅด๋ ์ํ์์ ํฌํํ๋ ์ผ์ด ๋ฐ์ํ์ฌ ", ("๊ตญ๋ฏผ์ ๋ป์ด ์คํ๋ ค ์๊ณก", ""), "๋ ์ ์๋ค๋ฉฐ ์ฐ๋ ค์ ๋ชฉ์๋ฆฌ๋ฅผ ๋ด๊ณ ์๋ค."
|
111 |
+
# )
|
112 |
|
113 |
# ๊ธฐ์กด ์ง๋ฌธ ์ง์ฐ๊ธฐ
|
114 |
text_placeholder.empty()
|
115 |
+
#text_container์ highlight๋ ํ
์คํธ๋ฅผ ์ถ๋ ฅ
|
116 |
with text_container:
|
117 |
+
st.markdown(highlighted_text, unsafe_allow_html=True)
|
118 |
+
else:
|
119 |
+
if st.session_state.points == 0:
|
120 |
+
#ํฌ์ธํธ๊ฐ ์์ด์ ์ฌ์ฉํ ์ ์๋ค๋ ๋ฌธ๊ตฌ ์ถ๊ฐ
|
121 |
+
st.write("ํฌ์ธํธ๊ฐ ์์ด์ ํค์๋๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.")
|
122 |
+
pass
|
123 |
|
124 |
with cols[1]:
|
125 |
global btn_explanation
|
126 |
btn_explanation= st.button("์ถ๊ฐ ์ค๋ช
")
|
127 |
+
if btn_explanation and st.session_state.points > 0: # ํฌ์ธํธ ์ฒดํฌ
|
128 |
+
update_points(1) # ํฌ์ธํธ ์ฆ๊ฐ
|
129 |
+
|
130 |
with cols[2]:
|
131 |
global btn_simple
|
132 |
btn_simple = st.button("์ฌ์ด ํํ")
|
133 |
+
if btn_simple and st.session_state.points > 0: # ํฌ์ธํธ ์ฒดํฌ
|
134 |
+
update_points(-1) # ํฌ์ธํธ ๊ฐ์
|
135 |
|
136 |
|
137 |
with cols[3]:
|
138 |
global btn_rewrite
|
139 |
btn_rewrite = st.button("๋ค์ ์ฐ๊ธฐ")
|
140 |
+
if btn_rewrite and st.session_state.points > 0: # ํฌ์ธํธ ์ฒดํฌ
|
141 |
+
update_points(-1) # ํฌ์ธํธ ๊ฐ์
|
142 |
|
143 |
|
144 |
return btn_keyword, btn_explanation, btn_simple, btn_rewrite
|
|
|
147 |
def display_output():
|
148 |
with st.container():
|
149 |
st.header("๊ฒฐ๊ณผ")
|
150 |
+
if btn_explanation and st.session_state.points > 0:
|
151 |
explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
|
152 |
|
153 |
messages = [
|
|
|
167 |
# ์ถ๊ฐ ์ค๋ช
|
168 |
st.write(f"์ถ๊ฐ ์ค๋ช
: {explanation}")
|
169 |
pass
|
170 |
+
else:
|
171 |
+
if st.session_state.points == 0:
|
172 |
+
#ํฌ์ธํธ๊ฐ ์์ด์ ์ฌ์ฉํ ์ ์๋ค๋ ๋ฌธ๊ตฌ ์ถ๊ฐ
|
173 |
+
st.write("ํฌ์ธํธ๊ฐ ์์ด์ ์ถ๊ฐ ์ค๋ช
๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
174 |
|
175 |
+
pass
|
176 |
+
|
177 |
+
if btn_simple and st.session_state.points > 0:
|
178 |
explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
|
179 |
|
180 |
messages = [
|
|
|
194 |
# ์ฌ์ด ํํ์ผ๋ก ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
195 |
st.write(f"์ฌ์ด ๊ธ: {explanation}")
|
196 |
pass
|
197 |
+
else:
|
198 |
+
if st.session_state.points == 0:
|
199 |
+
st.write("ํฌ์ธํธ๊ฐ ์์ด์ ์ฌ์ด ํํ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
200 |
+
pass
|
201 |
|
202 |
+
if btn_rewrite and st.session_state.points > 0:
|
203 |
explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
|
204 |
|
205 |
messages = [
|
|
|
217 |
explanation = response['choices'][0]['message']['content']
|
218 |
|
219 |
st.write(f"๋ค์ ์ฐ๊ธฐ: {explanation}")
|
220 |
+
pass
|
221 |
+
else:
|
222 |
+
if st.session_state.points == 0:
|
223 |
+
st.write("ํฌ์ธํธ๊ฐ ์์ด์ ๋ค์ ์ฐ๊ธฐ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.")
|
224 |
|
225 |
+
pass
|
226 |
|
227 |
|
228 |
def main():
|
229 |
st.title("ํ๊ตญ์ด ํ์ต์๋ฅผ ์ํ HCI tools")
|
230 |
+
#ํฌ์ธํธ ์์คํ
์ค๋ช
์ถ๊ฐ
|
231 |
+
st.sidebar.markdown("ํฌ์ธํธ๋ 3์ ๋ถํฐ ์์ํด์, ํค์๋ ์ฐพ๊ธฐ, ์ฌ์ด ํํ, ๋ค์ ์ฐ๊ธฐ๋ฅผ ํ ๋ 1์ ์ฉ ๊ฐ์ํฉ๋๋ค. ์ถ๊ฐ ์ค๋ช
๊ณผ ์ฑ์ ํ๊ธฐ๋ฅผ ํ ๋ 1์ ์ฉ ์ฆ๊ฐํฉ๋๋ค. ํฌ์ธํธ๊ฐ 0์ ์ด ๋๋ฉด ๋ ์ด์ ์์
์ ํ ์ ์์ต๋๋ค. ")
|
232 |
+
|
233 |
col1, col2 = st.columns(2)
|
234 |
|
235 |
with col1:
|
|
|
238 |
with col2:
|
239 |
btn_keyword, btn_explanation, btn_simple, btn_rewrite = display_input_btns(col2)
|
240 |
display_output()
|
241 |
+
#ํฌ์ธํธ ํ์
|
242 |
+
display_points()
|
243 |
|
244 |
|
245 |
if __name__ == "__main__":
|