mlo0ollm JUNGU commited on
Commit
3b3393b
โ€ข
0 Parent(s):

Duplicate from JUNGU/keyword

Browse files

Co-authored-by: HAN JUNGU <JUNGU@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +265 -0
  4. requirements.txt +4 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Keyword
3
+ emoji: ๐Ÿ”ฅ
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: streamlit
7
+ sdk_version: 1.26.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: openrail
11
+ duplicated_from: JUNGU/keyword
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from annotated_text import annotated_text
2
+ import streamlit as st
3
+ import openai
4
+ import os
5
+
6
+ # OpenAI API ์„ค์ • (ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ์ฝ์–ด์˜ด)
7
+ openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด์ œ
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
+ if 'history' not in st.session_state:
15
+ st.session_state.history = []
16
+
17
+ def update_points(value):
18
+ """ ํฌ์ธํŠธ ์—…๋ฐ์ดํŠธ """
19
+ st.session_state.points += value
20
+ # display_points() # ํฌ์ธํŠธ๋ฅผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์—…๋ฐ์ดํŠธ ํ•˜๊ธฐ ์œ„ํ•ด
21
+
22
+ def display_points():
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
+ ##๊ธฐ๋Šฅ์„ ํ•จ์ˆ˜๋กœ ๋‚˜๋ˆ„์–ด์„œ ๊ตฌํ˜„
38
+ col, _ = st.columns(2)
39
+
40
+ def display_passage(col):
41
+ st.header("์ง€๋ฌธ")
42
+ global text_container
43
+ text_container = st.container() # ์ถ”๊ฐ€๋œ ์ฝ”๋“œ
44
+ # ๋ฏธ๋ฆฌ ๊ณต๊ฐ„ ํ™•๋ณด
45
+ global text_placeholder
46
+ text_placeholder = text_container.empty()
47
+ global user_text
48
+ user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.<br><br>
49
+ ์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜์ž์œ  ํˆฌํ‘œ์ œโ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜์˜๋ฌด ํˆฌํ‘œ์ œโ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(OECD) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.<br><br>
50
+ ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ์ •๋‹น์„ฑ์„ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.<br><br>
51
+ ๋ฐ˜๋ฉด ์˜๋ฌด ํˆฌํ‘œ์ œ์— ๋ฐ˜๋Œ€ํ•˜๋Š” ์ธก์€ ํ˜„์žฌ ์šฐ๋ฆฌ๋‚˜๋ผ์˜ ํˆฌํ‘œ์œจ์ด ์ •์น˜ ์ง€๋„์ž๋“ค์˜ ๋Œ€ํ‘œ์„ฑ์„ ํ›ผ์†ํ•  ๋งŒํผ ์‹ฌ๊ฐํ•œ ์ƒํ™ฉ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋Š” ๊ฒƒ๋ณด๋‹ค ๊ตญ๋ฏผ์˜ ์‹ ๋ขฐ๋ฅผ ํšŒ๋ณตํ•˜๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๊ณ , ์‹œ๋ฏผ ๊ต์œก์ด๋‚˜ ๋ชจ์˜ ํˆฌํ‘œ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋„ ํˆฌํ‘œ์œจ ์ƒ์Šน์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๋„์ž…๋งŒ์ด ํˆฌํ‘œ์œจ์ด๋‚˜ ์ •์น˜์  ๊ด€์‹ฌ์„ ๋†’์ด๋Š” ํ•ด๊ฒฐ ๋ฐฉ์•ˆ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜๋ฉด, ์„ ์ถœ๋œ ์ •์น˜์ธ๋“ค์ด ๋†’์€ ํˆฌํ‘œ์œจ์„ ํ•‘๊ณ„๋กœ ์•ˆํ•˜๋ฌด์ธ์˜ ํƒœ๋„๋ฅผ ๊ฐ–๋Š” ๋ถ€์ž‘์šฉ์ด ์ƒ๊ธด๋‹ค๋“ ๊ฐ€ ํ›„๋ณด์ž๋ฅผ ์ž˜ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํˆฌํ‘œํ•˜๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜์—ฌ ๊ตญ๋ฏผ์˜ ๋œป์ด ์˜คํžˆ๋ ค ์™œ๊ณก๋  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์šฐ๋ ค์˜ ๋ชฉ์†Œ๋ฆฌ๋ฅผ ๋‚ด๊ณ  ์žˆ๋‹ค.<br><br>
52
+ """
53
+ text_placeholder.write(user_text, unsafe_allow_html=True)
54
+ #์„ ์–ธํ•œ ๋ณ€์ˆ˜ ๋‹ค๋ฅธ ํ•จ์ˆ˜์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด return
55
+ return text_placeholder, text_container, user_text
56
+
57
+
58
+ def display_summary(col):
59
+ st.header("์š”์•ฝ ๊ฒฐ๊ณผ")
60
+ global user_summary
61
+ user_summary = st.text_area("์š”์•ฝ๊ฒฐ๊ณผ๋ฅผ ์ œ์ถœํ•˜์„ธ์š”.")
62
+
63
+ cols = st.columns(2)
64
+ with cols[0]:
65
+ btn_submit = st.button("์ œ์ถœ")
66
+ if btn_submit:
67
+ #๊ตฌ๊ธ€ ๋“œ๋ผ์ด๋ธŒ api ์ด์šฉํ•˜์—ฌ ์—…๋กœ๋“œ
68
+ st.write("์ œ์ถœ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
69
+ pass
70
+
71
+ with cols[1]:
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
+ #๋ฃจ๋ธŒ๋ฆญ ๊ธฐ์ค€์„ ์ด์šฉํ•ด์„œ ์ž…๋ ฅ์นธ์— ์ž…๋ ฅํ•œ ๋‚ด์šฉ์„ ์ฑ„์ ํ•˜๋Š” ์˜์–ด๋กœ ํ”„๋กฌํ”„ํŠธ
79
+ explanation_task = f"{lubric}์„ ๊ธฐ์ค€์œผ๋กœ {user_summary}์˜ ๋‚ด์šฉ์„ ์ฑ„์ ํ•ด์ฃผ์„ธ์š”. ์ฑ„์  ๊ธฐ์ค€์€ ๊ณต๊ฐœํ•˜์ง€ ๋ง๊ณ  ์ƒ, ์ค‘,ํ•˜๋กœ ๋‚˜๋ˆ„๊ณ  ๊ฐ„๋‹จํ•œ ์ด์œ ๋ฅผ ์•Œ๋ ค์ฃผ์„ธ์š”."
80
+ messages = [
81
+ {"role": "system", "content": "You are a helpful assistant. use only korean"},
82
+ {"role": "user", "content": explanation_task}
83
+ ]
84
+
85
+ response = openai.ChatCompletion.create(
86
+ model="gpt-3.5-turbo-16k",
87
+ messages=messages,
88
+ temperature=0.1,
89
+ max_tokens=2500
90
+ )
91
+
92
+ explanation = response['choices'][0]['message']['content']
93
+ st.write(f"์ฑ„์  ํ•˜๊ธฐ: {explanation}")
94
+ pass
95
+ else:
96
+ if st.session_state.points == 0:
97
+ #ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์‚ฌ์šฉํ• ์ˆ˜ ์—†๋‹ค๋Š” ๋ฌธ๊ตฌ ์ถ”๊ฐ€
98
+ st.write("ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์ฑ„์ ํ•˜๊ธฐ๋ฅผ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
99
+ pass
100
+
101
+ def display_input_btns(col):
102
+ st.header("์ธ๊ณต์ง€๋Šฅ ์‚ฌ์šฉํ•˜๊ธฐ")
103
+ global user_input
104
+ user_input = st.text_area("๋‚ด์šฉ์„ ๋„ฃ๊ณ  ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”:", "์ถ”๊ฐ€ ์„ค๋ช…์ด ํ•„์š”ํ•˜๊ฑฐ๋‚˜ ๋‹ค์‹œ ์“ฐ๊ณ  ์‹ถ์€ ๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”.")
105
+
106
+ # ๋ฒ„ํŠผ row
107
+ cols = st.columns(4)
108
+ with cols[0]:
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
+
116
+ **์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„**์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜**์ž์œ  ํˆฌํ‘œ์ œ**โ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜**์˜๋ฌด ํˆฌํ‘œ์ œ**โ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(**OECD**) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.
117
+
118
+ **์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก**์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ **์ •๋‹น์„ฑ์„ ํ™•๋ณด**ํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ **์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต**์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.
119
+
120
+ ๋ฐ˜๋ฉด **์˜๋ฌด ํˆฌํ‘œ์ œ์— ๋ฐ˜๋Œ€ํ•˜๋Š” ์ธก**์€ ํ˜„์žฌ ์šฐ๋ฆฌ๋‚˜๋ผ์˜ ํˆฌํ‘œ์œจ์ด ์ •์น˜ ์ง€๋„์ž๋“ค์˜ ๋Œ€ํ‘œ์„ฑ์„ ํ›ผ์†ํ•  ๋งŒํผ ์‹ฌ๊ฐํ•œ ์ƒํ™ฉ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋Š” ๊ฒƒ๋ณด๋‹ค **๊ตญ๋ฏผ์˜ ์‹ ๋ขฐ๋ฅผ ํšŒ๋ณต**ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๊ณ , ์‹œ๋ฏผ ๊ต์œก์ด๋‚˜ ๋ชจ์˜ ํˆฌํ‘œ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋„ ํˆฌํ‘œ์œจ ์ƒ์Šน์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๋„์ž…๋งŒ์ด ํˆฌํ‘œ์œจ์ด๋‚˜ ์ •์น˜์  ๊ด€์‹ฌ์„ ๋†’์ด๋Š” ํ•ด๊ฒฐ ๋ฐฉ์•ˆ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜๋ฉด, ์„ ์ถœ๋œ ์ •์น˜์ธ๋“ค์ด ๋†’์€ ํˆฌํ‘œ์œจ์„ ํ•‘๊ณ„๋กœ **์•ˆํ•˜๋ฌด์ธ์˜ ํƒœ๋„**๋ฅผ ๊ฐ–๋Š” ๋ถ€์ž‘์šฉ์ด ์ƒ๊ธด๋‹ค๋“ ๊ฐ€ ํ›„๋ณด์ž๋ฅผ ์ž˜ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํˆฌํ‘œํ•˜๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜์—ฌ **๊ตญ๋ฏผ์˜ ๋œป์ด ์˜คํžˆ๋ ค ์™œ๊ณก**๋  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์šฐ๋ ค์˜ ๋ชฉ์†Œ๋ฆฌ๋ฅผ ๋‚ด๊ณ  ์žˆ๋‹ค.
121
+ """
122
+ # highlighted_text = annotated_text(
123
+ # ("๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ", ""), "๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ", ("์ฐธ์ •๊ถŒ", ""), "์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ", ("๋†’๏ฟฝ๏ฟฝ ํˆฌํ‘œ์œจ", ""), "์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ", ("์ •๋‹น์„ฑ ํ™•๋ณด", ""), "์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.\n\n", ("์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„", ""), "์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜", ("์ž์œ  ํˆฌํ‘œ์ œ", ""), "โ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜", ("์˜๋ฌด ํˆฌํ‘œ์ œ", ""), "โ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(", ("OECD", ""), ") ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.\n\n", ("์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก", ""), "์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ", ("์ •๋‹น์„ฑ์„ ํ™•๋ณด", ""), "ํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ", ("์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต", ""), "์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.\n\n๋ฐ˜๋ฉด ", ("์˜๋ฌด ํˆฌํ‘œ์ œ์— ๋ฐ˜๋Œ€ํ•˜๋Š” ์ธก", ""), "์€ ํ˜„์žฌ ์šฐ๋ฆฌ๋‚˜๋ผ์˜ ํˆฌํ‘œ์œจ์ด ์ •์น˜ ์ง€๋„์ž๋“ค์˜ ๋Œ€ํ‘œ์„ฑ์„ ํ›ผ์†ํ•  ๋งŒํผ ์‹ฌ๊ฐํ•œ ์ƒํ™ฉ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋Š” ๊ฒƒ๋ณด๋‹ค ", ("๊ตญ๋ฏผ์˜ ์‹ ๋ขฐ๋ฅผ ํšŒ๋ณต", ""), "ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๊ณ , ์‹œ๋ฏผ ๊ต์œก์ด๋‚˜ ๋ชจ์˜ ํˆฌํ‘œ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋„ ํˆฌํ‘œ์œจ ์ƒ์Šน์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๋„์ž…๋งŒ์ด ํˆฌํ‘œ์œจ์ด๋‚˜ ์ •์น˜์  ๊ด€์‹ฌ์„ ๋†’์ด๋Š” ํ•ด๊ฒฐ ๋ฐฉ์•ˆ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜๋ฉด, ์„ ์ถœ๋œ ์ •์น˜์ธ๋“ค์ด ๋†’์€ ํˆฌํ‘œ์œจ์„ ํ•‘๊ณ„๋กœ ", ("์•ˆํ•˜๋ฌด์ธ์˜ ํƒœ๋„", ""), "๋ฅผ ๊ฐ–๋Š” ๋ถ€์ž‘์šฉ์ด ์ƒ๊ธด๋‹ค๋“ ๊ฐ€ ํ›„๋ณด์ž๋ฅผ ์ž˜ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํˆฌํ‘œํ•˜๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜์—ฌ ", ("๊ตญ๋ฏผ์˜ ๋œป์ด ์˜คํžˆ๋ ค ์™œ๊ณก", ""), "๋  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์šฐ๋ ค์˜ ๋ชฉ์†Œ๋ฆฌ๋ฅผ ๋‚ด๊ณ  ์žˆ๋‹ค."
124
+ # )
125
+
126
+ # ๊ธฐ์กด ์ง€๋ฌธ ์ง€์šฐ๊ธฐ
127
+ text_placeholder.empty()
128
+ #text_container์— highlight๋œ ํ…์ŠคํŠธ๋ฅผ ์ถœ๋ ฅ
129
+ with text_container:
130
+ st.markdown(highlighted_text, unsafe_allow_html=True)
131
+ else:
132
+ if st.session_state.points == 0:
133
+ #ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์‚ฌ์šฉํ• ์ˆ˜ ์—†๋‹ค๋Š” ๋ฌธ๊ตฌ ์ถ”๊ฐ€
134
+ st.write("ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ํ‚ค์›Œ๋“œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
135
+ pass
136
+
137
+ with cols[1]:
138
+ global btn_explanation
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]:
153
+ global btn_rewrite
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
161
+
162
+
163
+ def display_output():
164
+ with st.container():
165
+ st.header("๊ฒฐ๊ณผ")
166
+ if btn_explanation and st.session_state.points > 0:
167
+ explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
168
+
169
+ messages = [
170
+ {"role": "system", "content": "You are a helpful assistant that explains complex topics in a way that an elementary school student can understand. use only korean"},
171
+ {"role": "user", "content": explanation_task}
172
+ ]
173
+
174
+ response = openai.ChatCompletion.create(
175
+ model="gpt-3.5-turbo-16k",
176
+ messages=messages,
177
+ temperature=0.1,
178
+ max_tokens=200
179
+ )
180
+
181
+ explanation = response['choices'][0]['message']['content']
182
+
183
+ # ์ถ”๊ฐ€ ์„ค๋ช…
184
+ st.write(f"์ถ”๊ฐ€ ์„ค๋ช…: {explanation}")
185
+ pass
186
+ else:
187
+ if st.session_state.points == 0:
188
+ #ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์‚ฌ์šฉํ• ๏ฟฝ๏ฟฝ๏ฟฝ ์—†๋‹ค๋Š” ๋ฌธ๊ตฌ ์ถ”๊ฐ€
189
+ st.write("ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์ถ”๊ฐ€ ์„ค๋ช… ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
190
+
191
+ pass
192
+
193
+ if btn_simple and st.session_state.points > 0:
194
+ explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
195
+
196
+ messages = [
197
+ {"role": "system", "content": "You are a helpful assistant that explains complex topics in a way that an elementary school student can understand. use only korean"},
198
+ {"role": "user", "content": explanation_task}
199
+ ]
200
+
201
+ response = openai.ChatCompletion.create(
202
+ model="gpt-3.5-turbo-16k",
203
+ messages=messages,
204
+ temperature=0.1,
205
+ max_tokens=2500
206
+ )
207
+
208
+ explanation = response['choices'][0]['message']['content']
209
+
210
+ # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
211
+ st.write(f"์‰ฌ์šด ๊ธ€: {explanation}")
212
+ pass
213
+ else:
214
+ if st.session_state.points == 0:
215
+ st.write("ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ์‰ฌ์šด ํ‘œํ˜„ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
216
+ pass
217
+
218
+ if btn_rewrite and st.session_state.points > 0:
219
+ explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
220
+
221
+ messages = [
222
+ {"role": "system", "content": "You are a helpful assistant. use only korean"},
223
+ {"role": "user", "content": explanation_task}
224
+ ]
225
+
226
+ response = openai.ChatCompletion.create(
227
+ model="gpt-3.5-turbo-16k",
228
+ messages=messages,
229
+ temperature=0.1,
230
+ max_tokens=2500
231
+ )
232
+
233
+ explanation = response['choices'][0]['message']['content']
234
+
235
+ st.write(f"๋‹ค์‹œ ์“ฐ๊ธฐ: {explanation}")
236
+ pass
237
+ else:
238
+ if st.session_state.points == 0:
239
+ st.write("ํฌ์ธํŠธ๊ฐ€ ์—†์–ด์„œ ๋‹ค์‹œ ์“ฐ๊ธฐ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
240
+
241
+ pass
242
+
243
+
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
+
251
+ with col1:
252
+ display_passage(col1)
253
+ display_summary(col1)
254
+ with col2:
255
+ btn_keyword, btn_explanation, btn_simple, btn_rewrite = display_input_btns(col2)
256
+ display_output()
257
+ #ํฌ์ธํŠธ ํ‘œ์‹œ
258
+ display_points()
259
+ #ํฌ์ธํŠธ ๋ณ€ํ™” ํ‘œ์‹œ
260
+ display_markdown_table()
261
+
262
+
263
+
264
+ if __name__ == "__main__":
265
+ main()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openai
2
+ google-api-python-client
3
+ oauth2client
4
+ st-annotated-text