JUNGU commited on
Commit
08ab3f7
โ€ข
1 Parent(s): a0de072

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -11,6 +11,8 @@ st.set_page_config(layout="wide")
11
  ## ํฌ์ธํŠธ ๋ถ€๋ถ„ ์ถ”๊ฐ€
12
  if 'points' not in st.session_state:
13
  st.session_state.points = 3
 
 
14
 
15
  def update_points(value):
16
  """ ํฌ์ธํŠธ ์—…๋ฐ์ดํŠธ """
@@ -21,6 +23,15 @@ def display_points():
21
  """ ํฌ์ธํŠธ ํ‘œ์‹œ """
22
  st.sidebar.header(f"Current Points: {st.session_state.points}")
23
 
 
 
 
 
 
 
 
 
 
24
 
25
 
26
  ##๊ธฐ๋Šฅ์„ ํ•จ์ˆ˜๋กœ ๋‚˜๋ˆ„์–ด์„œ ๊ตฌํ˜„
@@ -53,7 +64,7 @@ def display_summary(col):
53
  with cols[0]:
54
  btn_submit = st.button("์ œ์ถœ")
55
  if btn_submit:
56
- #๊ตฌ๊ธ€ ๋“œ๋ผ์ด๋ธŒ api ์—ฐ๊ฒฐ ๋กœ์ง ์ถ”ํ›„ ์ถ”๊ฐ€
57
  st.write("์ œ์ถœ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
58
  pass
59
 
@@ -61,6 +72,7 @@ def display_summary(col):
61
  btn_score = st.button("์ฑ„์ ํ•˜๊ธฐ")
62
  if btn_score and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
63
  update_points(1) # ํฌ์ธํŠธ ์ฆ๊ฐ€
 
64
  #๋ฃจ๋ธŒ๋ฆญ์— ์˜ํ•œ ์ฑ„์ 
65
  lubric = """์ฑ„์  ๊ธฐ์ค€ ์ƒ: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•˜๊ณ , ์ฃผ์š” ๋‚ด์šฉ์„ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ค‘: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•  ์ˆ˜ ์—†๋‹ค."""
66
  #๋ฃจ๋ธŒ๋ฆญ ๊ธฐ์ค€์„ ์ด์šฉํ•ด์„œ ์ž…๋ ฅ์นธ์— ์ž…๋ ฅํ•œ ๋‚ด์šฉ์„ ์ฑ„์ ํ•˜๋Š” ์˜์–ด๋กœ ํ”„๋กฌํ”„ํŠธ
@@ -97,6 +109,7 @@ def display_input_btns(col):
97
  btn_keyword = st.button("ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ")
98
  if btn_keyword and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
99
  update_points(-1) # ํฌ์ธํŠธ ๊ฐ์†Œ
 
100
  #๋‹ค๋ฅธ ์ง€๋ฌธ ๋„ฃ๊ธฐ
101
  highlighted_text = """**๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ**๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ **์ฐธ์ •๊ถŒ**์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ **๋†’์€ ํˆฌํ‘œ์œจ**์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ **์ •๋‹น์„ฑ ํ™•๋ณด**์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
102
 
@@ -126,12 +139,14 @@ def display_input_btns(col):
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]:
@@ -139,6 +154,7 @@ def display_input_btns(col):
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
@@ -228,7 +244,7 @@ def display_output():
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
 
@@ -240,6 +256,9 @@ def main():
240
  display_output()
241
  #ํฌ์ธํŠธ ํ‘œ์‹œ
242
  display_points()
 
 
 
243
 
244
 
245
  if __name__ == "__main__":
 
11
  ## ํฌ์ธํŠธ ๋ถ€๋ถ„ ์ถ”๊ฐ€
12
  if 'points' not in st.session_state:
13
  st.session_state.points = 3
14
+ if 'history' not in st.session_state:
15
+ st.session_state.history = []
16
 
17
  def update_points(value):
18
  """ ํฌ์ธํŠธ ์—…๋ฐ์ดํŠธ """
 
23
  """ ํฌ์ธํŠธ ํ‘œ์‹œ """
24
  st.sidebar.header(f"Current Points: {st.session_state.points}")
25
 
26
+ def display_markdown_table():
27
+ """์ง€๊ธˆ๊นŒ์ง€ ์‚ฌ์šฉํ•œ ๊ธฐ๋Šฅ๊ณผ ํฌ์ธํŠธ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ํžˆ์Šคํ† ๋ฆฌ ํ•จ์ˆ˜, ๊ธฐ๋Šฅ์„ ๋ˆ„๋ฅธ ์ˆœ์„œ์™€ ํฌ์ธํŠธ ๋ณ€ํ™”์™€ ํ˜„์žฌ ํฌ์ธํŠธ๋ฅผ ํ‘œ๋กœ ์ •๋ฆฌ"""
28
+ markdown_table = """| ์ˆœ์„œ | ์„ ํƒํ•œ ๊ธฐ๋Šฅ | ํฌ์ธํŠธ ๋ณ€ํ™” | ํ˜„์žฌ ํฌ์ธํŠธ |
29
+ | --- | --- | --- | --- |
30
+ """
31
+ for i, step in enumerate(st.session_state.history):
32
+ markdown_table += f"| {i+1} | {step[0]} | {step[1]} | {step[2]} |\n"
33
+ st.sidebar.markdown(markdown_table)
34
+
35
 
36
 
37
  ##๊ธฐ๋Šฅ์„ ํ•จ์ˆ˜๋กœ ๋‚˜๋ˆ„์–ด์„œ ๊ตฌํ˜„
 
64
  with cols[0]:
65
  btn_submit = st.button("์ œ์ถœ")
66
  if btn_submit:
67
+ #๊ตฌ๊ธ€ ๋“œ๋ผ์ด๋ธŒ api ์ด์šฉํ•˜์—ฌ ์—…๋กœ๋“œ
68
  st.write("์ œ์ถœ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
69
  pass
70
 
 
72
  btn_score = st.button("์ฑ„์ ํ•˜๊ธฐ")
73
  if btn_score and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
74
  update_points(1) # ํฌ์ธํŠธ ์ฆ๊ฐ€
75
+ st.session_state.history.append(["์ฑ„์ ํ•˜๊ธฐ", -1, st.session_state.points])
76
  #๋ฃจ๋ธŒ๋ฆญ์— ์˜ํ•œ ์ฑ„์ 
77
  lubric = """์ฑ„์  ๊ธฐ์ค€ ์ƒ: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•˜๊ณ , ์ฃผ์š” ๋‚ด์šฉ์„ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ค‘: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜: ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•  ์ˆ˜ ์—†๋‹ค."""
78
  #๋ฃจ๋ธŒ๋ฆญ ๊ธฐ์ค€์„ ์ด์šฉํ•ด์„œ ์ž…๋ ฅ์นธ์— ์ž…๋ ฅํ•œ ๋‚ด์šฉ์„ ์ฑ„์ ํ•˜๋Š” ์˜์–ด๋กœ ํ”„๋กฌํ”„ํŠธ
 
109
  btn_keyword = st.button("ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ")
110
  if btn_keyword and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
111
  update_points(-1) # ํฌ์ธํŠธ ๊ฐ์†Œ
112
+ st.session_state.history.append(["ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ", -1, st.session_state.points])
113
  #๋‹ค๋ฅธ ์ง€๋ฌธ ๋„ฃ๊ธฐ
114
  highlighted_text = """**๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ**๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ **์ฐธ์ •๊ถŒ**์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ **๋†’์€ ํˆฌํ‘œ์œจ**์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ **์ •๋‹น์„ฑ ํ™•๋ณด**์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
115
 
 
139
  btn_explanation= st.button("์ถ”๊ฐ€ ์„ค๋ช…")
140
  if btn_explanation and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
141
  update_points(1) # ํฌ์ธํŠธ ์ฆ๊ฐ€
142
+ st.session_state.history.append(["์ถ”๊ฐ€ ์„ค๋ช…", 1, st.session_state.points])
143
 
144
  with cols[2]:
145
  global btn_simple
146
  btn_simple = st.button("์‰ฌ์šด ํ‘œํ˜„")
147
  if btn_simple and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
148
  update_points(-1) # ํฌ์ธํŠธ ๊ฐ์†Œ
149
+ st.session_state.history.append(["์‰ฌ์šด ํ‘œํ˜„", -1, st.session_state.points])
150
 
151
 
152
  with cols[3]:
 
154
  btn_rewrite = st.button("๋‹ค์‹œ ์“ฐ๊ธฐ")
155
  if btn_rewrite and st.session_state.points > 0: # ํฌ์ธํŠธ ์ฒดํฌ
156
  update_points(-1) # ํฌ์ธํŠธ ๊ฐ์†Œ
157
+ st.session_state.history.append(["๋‹ค์‹œ ์“ฐ๊ธฐ", -1, st.session_state.points])
158
 
159
 
160
  return btn_keyword, btn_explanation, btn_simple, btn_rewrite
 
244
  def main():
245
  st.title("ํ•œ๊ตญ์–ด ํ•™์Šต์ž๋ฅผ ์œ„ํ•œ HCI tools")
246
  #ํฌ์ธํŠธ ์‹œ์Šคํ…œ ์„ค๋ช… ์ถ”๊ฐ€
247
+ st.sidebar.markdown("ํฌ์ธํŠธ๋Š” 3์ ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์„œ, **ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ**, **์‰ฌ์šด ํ‘œํ˜„**, **๋‹ค์‹œ ์“ฐ๊ธฐ**๋ฅผ ํ•  ๋•Œ 1์ ์”ฉ ๊ฐ์†Œํ•ฉ๋‹ˆ๋‹ค. **์ถ”๊ฐ€ ์„ค๋ช…**๊ณผ **์ฑ„์ ํ•˜๊ธฐ**๋ฅผ ํ•  ๋•Œ 1์ ์”ฉ ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ํฌ์ธํŠธ๊ฐ€ 0์ ์ด ๋˜๋ฉด ๋” ์ด์ƒ ์ž‘์—…์„ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ")
248
 
249
  col1, col2 = st.columns(2)
250
 
 
256
  display_output()
257
  #ํฌ์ธํŠธ ํ‘œ์‹œ
258
  display_points()
259
+ #ํฌ์ธํŠธ ๋ณ€ํ™” ํ‘œ์‹œ
260
+ display_markdown_table()
261
+
262
 
263
 
264
  if __name__ == "__main__":