JUNGU commited on
Commit
cb1be96
โ€ข
1 Parent(s): 5fa6668

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -83
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
- with col1:
16
- st.header("์ง€๋ฌธ")
17
- text_container = st.container() # ์ถ”๊ฐ€๋œ ์ฝ”๋“œ
18
- # ๋ฏธ๋ฆฌ ๊ณต๊ฐ„ ํ™•๋ณด
19
- text_placeholder = text_container.empty()
20
 
21
- # with text_container: #์ถ”๊ฐ€๋œ ์ฝ”๋“œ
 
 
 
 
 
 
 
22
  user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
23
- ์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜์ž์œ  ํˆฌํ‘œ์ œโ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜์˜๋ฌด ํˆฌํ‘œ์ œโ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(OECD) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.
24
- ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ์ •๋‹น์„ฑ์„ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.
25
- ๋ฐ˜๋ฉด ์˜๋ฌด ํˆฌํ‘œ์ œ์— ๋ฐ˜๋Œ€ํ•˜๋Š” ์ธก์€ ํ˜„์žฌ ์šฐ๋ฆฌ๋‚˜๋ผ์˜ ํˆฌํ‘œ์œจ์ด ์ •์น˜ ์ง€๋„์ž๋“ค์˜ ๋Œ€ํ‘œ์„ฑ์„ ํ›ผ์†ํ•  ๋งŒํผ ์‹ฌ๊ฐํ•œ ์ƒํ™ฉ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋Š” ๊ฒƒ๋ณด๋‹ค ๊ตญ๋ฏผ์˜ ์‹ ๋ขฐ๋ฅผ ํšŒ๋ณตํ•˜๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๊ณ , ์‹œ๋ฏผ ๊ต์œก์ด๋‚˜ ๋ชจ์˜ ํˆฌํ‘œ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋„ ํˆฌํ‘œ์œจ ์ƒ์Šน์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๋„์ž…๋งŒ์ด ํˆฌํ‘œ์œจ์ด๋‚˜ ์ •์น˜์  ๊ด€์‹ฌ์„ ๋†’์ด๋Š” ํ•ด๊ฒฐ ๋ฐฉ์•ˆ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜๋ฉด, ์„ ์ถœ๋œ ์ •์น˜์ธ๋“ค์ด ๋†’์€ ํˆฌํ‘œ์œจ์„ ํ•‘๊ณ„๋กœ ์•ˆํ•˜๋ฌด์ธ์˜ ํƒœ๋„๋ฅผ ๊ฐ–๋Š” ๋ถ€์ž‘์šฉ์ด ์ƒ๊ธด๋‹ค๋“ ๊ฐ€ ํ›„๋ณด์ž๋ฅผ ์ž˜ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํˆฌํ‘œํ•˜๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜์—ฌ ๊ตญ๋ฏผ์˜ ๋œป์ด ์˜คํžˆ๋ ค ์™œ๊ณก๋  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์šฐ๋ ค์˜ ๋ชฉ์†Œ๋ฆฌ๋ฅผ ๋‚ด๊ณ  ์žˆ๋‹ค.
26
- """
27
  text_placeholder.write(user_text)
28
- st.write("""<style>.stTextInput input {height: 100px;}</style>""", unsafe_allow_html=True)
 
29
 
30
- # ์ƒ๋‹จ ์ปจํ…Œ์ด๋„ˆ
31
- with col2:
32
- st.header("์กฐ์ž‘ ํŒจ๋„")
33
- user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
34
- st.write(user_input)
35
-
36
- # ๋ฒ„ํŠผ row
37
- cols = st.columns(5)
38
- with cols[0]:
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
- with st.container():
68
- st.header("๊ฒฐ๊ณผ")
 
 
 
 
 
 
 
 
 
 
 
 
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
- # exec(highlighted_text)
117
- # pass
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
- if btn_score:
185
- #๋ฃจ๋ธŒ๋ฆญ ๊ธฐ์ค€ ์ถ”๊ฐ€
186
- lubric = """1. ๋ฌธ์žฅ์˜ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•˜๊ณ , ์ฃผ์š” ๋‚ด์šฉ์„ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•œ๋‹ค."""
187
 
188
- explanation_task = f"Score the following text based on the following rubric: {lubric}"
189
-
190
- messages = [
191
- {"role": "system", "content": "You are a helpful assistant. use only korean"},
192
- {"role": "user", "content": explanation_task}
193
- ]
194
-
195
- response = openai.ChatCompletion.create(
196
- model="gpt-3.5-turbo-16k",
197
- messages=messages,
198
- temperature=0.1,
199
- max_tokens=2500
200
- )
201
-
202
- explanation = response['choices'][0]['message']['content']
 
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()