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

Duplicate from JUNGU/keyword

Browse files

Co-authored-by: HAN JUNGU <[email protected]>

Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +219 -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,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 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:
79
+ annotated_text(
80
+ "This ",
81
+ ("is", ""),
82
+ " some ",
83
+ ("annotated", ""),
84
+ ("text", ""),
85
+ " for those of ",
86
+ ("you", ""),
87
+ " who ",
88
+ ("like", ""),
89
+ " this sort of ",
90
+ ("thing", ""),
91
+ ". "
92
+ )"""
93
+
94
+ user_prompt = f"First, extract key words for the topic st-annotated-text format.: {user_text}"
95
+
96
+ messages = [{"role": "system", "content": task_description}, {"role": "user", "content": user_prompt}]
97
+
98
+ response = openai.ChatCompletion.create(
99
+ model="gpt-3.5-turbo-16k",
100
+ messages=messages,
101
+ temperature=0.1,
102
+ max_tokens=2500,
103
+ top_p=0.2,
104
+ frequency_penalty=0,
105
+ presence_penalty=0
106
+ )
107
+
108
+ highlighted_text = response['choices'][0]['message']['content']
109
+
110
+ # ๊ธฐ์กด ์ง€๋ฌธ ์ง€์šฐ๊ธฐ
111
+ text_placeholder.empty()
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
+
139
+ messages = [
140
+ {"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"},
141
+ {"role": "user", "content": explanation_task}
142
+ ]
143
+
144
+ response = openai.ChatCompletion.create(
145
+ model="gpt-3.5-turbo-16k",
146
+ messages=messages,
147
+ temperature=0.1,
148
+ max_tokens=200
149
+ )
150
+
151
+ explanation = response['choices'][0]['message']['content']
152
+
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
+
160
+ messages = [
161
+ {"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"},
162
+ {"role": "user", "content": explanation_task}
163
+ ]
164
+
165
+ response = openai.ChatCompletion.create(
166
+ model="gpt-3.5-turbo-16k",
167
+ messages=messages,
168
+ temperature=0.1,
169
+ max_tokens=2500
170
+ )
171
+
172
+ explanation = response['choices'][0]['message']['content']
173
+
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
+
181
+ messages = [
182
+ {"role": "system", "content": "You are a helpful assistant. use only korean"},
183
+ {"role": "user", "content": explanation_task}
184
+ ]
185
+
186
+ response = openai.ChatCompletion.create(
187
+ model="gpt-3.5-turbo-16k",
188
+ messages=messages,
189
+ temperature=0.1,
190
+ max_tokens=2500
191
+ )
192
+
193
+ explanation = response['choices'][0]['message']['content']
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()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openai
2
+ google-api-python-client
3
+ oauth2client
4
+ st-annotated-text