JUNGU commited on
Commit
91674d2
โ€ข
1 Parent(s): 471b2f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -120
app.py CHANGED
@@ -3,143 +3,98 @@ import streamlit as st
3
  import openai
4
  import os
5
 
6
-
7
- #์ง€๋ฌธ์„ ์ž…๋ ฅ ๋ฐ›์•„์„œ ํ‚ค์›Œ๋“œ๋งŒ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
8
- #๋ฌธ๋‹จ์—์„œ ๋ชจ๋ฅด๋Š” ๋‚ด์šฉ์„ ์ถ”๊ฐ€์ ์œผ๋กœ ์„ค๋ช…ํ•ด์คŒ
9
- #์ž…๋ ฅ์ฐฝ์— ์ž…๋ ฅํ•œ ์ง€๋ฌธ์—์„œ ํ‘œํ˜„์„ ๋‹ค๋“ฌ์€ ๊ธ€์„ ์ƒ์„ฑํ•ด์คŒ gpt3-5-turbo-16k ์‚ฌ์šฉ
10
- #์ถ”๊ฐ€ ์„ค๋ช… ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์ถ”๊ฐ€์ ์ธ ์„ค๋ช…์„ ํ•ด์คŒ
11
-
12
  # OpenAI API ์„ค์ • (ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ์ฝ์–ด์˜ด)
13
  openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด์ œ
14
 
15
  def main():
16
  st.title("ํ•œ๊ตญ์–ด ํ•™์Šต์ž๋ฅผ ์œ„ํ•œ HCI tools")
17
 
18
- col1, col2= st.columns(2)
19
 
20
  with col1:
21
  st.header("์ง€๋ฌธ")
22
 
23
- user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
24
- ์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜์ž์œ  ํˆฌํ‘œ์ œโ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜์˜๋ฌด ํˆฌํ‘œ์ œโ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(OECD) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.
25
- ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ์ •๋‹น์„ฑ์„ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.
26
- ๋ฐ˜๋ฉด ์˜๋ฌด ํˆฌํ‘œ์ œ์— ๋ฐ˜๋Œ€ํ•˜๋Š” ์ธก์€ ํ˜„์žฌ ์šฐ๋ฆฌ๋‚˜๋ผ์˜ ํˆฌํ‘œ์œจ์ด ์ •์น˜ ์ง€๋„์ž๋“ค์˜ ๋Œ€ํ‘œ์„ฑ์„ ํ›ผ์†ํ•  ๋งŒํผ ์‹ฌ๊ฐํ•œ ์ƒํ™ฉ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋Š” ๊ฒƒ๋ณด๋‹ค ๊ตญ๋ฏผ์˜ ์‹ ๋ขฐ๋ฅผ ํšŒ๋ณตํ•˜๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•˜๊ณ , ์‹œ๋ฏผ ๊ต์œก์ด๋‚˜ ๋ชจ์˜ ํˆฌํ‘œ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋„ ํˆฌํ‘œ์œจ ์ƒ์Šน์„ ๊ธฐ๋Œ€ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๋„์ž…๋งŒ์ด ํˆฌํ‘œ์œจ์ด๋‚˜ ์ •์น˜์  ๊ด€์‹ฌ์„ ๋†’์ด๋Š” ํ•ด๊ฒฐ ๋ฐฉ์•ˆ์€ ์•„๋‹ˆ๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜๋ฉด, ์„ ์ถœ๋œ ์ •์น˜์ธ๋“ค์ด ๋†’์€ ํˆฌํ‘œ์œจ์„ ํ•‘๊ณ„๋กœ ์•ˆํ•˜๋ฌด์ธ์˜ ํƒœ๋„๋ฅผ ๊ฐ–๋Š” ๋ถ€์ž‘์šฉ์ด ์ƒ๊ธด๋‹ค๋“ ๊ฐ€ ํ›„๋ณด์ž๋ฅผ ์ž˜ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํˆฌํ‘œํ•˜๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜์—ฌ ๊ตญ๋ฏผ์˜ ๋œป์ด ์˜คํžˆ๋ ค ์™œ๊ณก๋  ์ˆ˜ ์žˆ๋‹ค๋ฉฐ ์šฐ๋ ค์˜ ๋ชฉ์†Œ๋ฆฌ๋ฅผ ๋‚ด๊ณ  ์žˆ๋‹ค.
27
- """
28
  st.write(user_text)
29
 
 
30
  with col2:
 
31
  user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
32
-
 
33
  cols = st.columns(4)
34
- with cols[0]:
35
- if st.button("ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ"):
36
- 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:
37
- annotated_text(
38
- "This ",
39
- ("is", ""),
40
- " some ",
41
- ("annotated", ""),
42
- ("text", ""),
43
- " for those of ",
44
- ("you", ""),
45
- " who ",
46
- ("like", ""),
47
- " this sort of ",
48
- ("thing", ""),
49
- ". "
50
- )"""
51
-
52
- user_prompt = f"First, extract key words for the topic st-annotated-text format.: {user_text}"
53
-
54
- messages = [{"role": "system", "content": task_description}, {"role": "user", "content": user_prompt}]
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
- top_p=0.2,
62
- frequency_penalty=0,
63
- presence_penalty=0
64
- )
65
-
66
- highlighted_text = response['choices'][0]['message']['content']
67
-
68
- exec(highlighted_text)
69
- pass
70
-
71
  with cols[1]:
72
- if st.button("์ถ”๊ฐ€ ์„ค๋ช…"):
73
- # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ ์„ค๋ช…
74
- explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
75
-
76
- messages = [
77
- {"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"},
78
- {"role": "user", "content": explanation_task}
79
- ]
80
-
81
- response = openai.ChatCompletion.create(
82
- model="gpt-3.5-turbo-16k",
83
- messages=messages,
84
- temperature=0.1,
85
- max_tokens=200
86
- )
87
-
88
- explanation = response['choices'][0]['message']['content']
89
-
90
- # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
91
- st.text("์„ค๋ช…:")
92
- st.write(explanation)
93
- pass
94
-
95
- #๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด user_text์˜ ๋‚ด์šฉ์„ ์‰ฝ๊ฒŒ ๋‹ค์‹œ ์„ค๋ช…ํ•ด์คŒ
96
  with cols[2]:
97
- if st.button("์‰ฌ์šด ํ‘œํ˜„"):
98
- # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ ์„ค๋ช…
99
- #user_text๋ฅผ ์‰ฝ๊ฒŒ ์„ค๋ช…ํ•ด์คŒ
100
- explanation_task = f"Describe the fingerprint of '{user_text}' in a way that an elementary school student could understand."
101
-
102
- messages = [
103
- {"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"},
104
- {"role": "user", "content": explanation_task}
105
- ]
106
-
107
- response = openai.ChatCompletion.create(
108
- model="gpt-3.5-turbo-16k",
109
- messages=messages,
110
- temperature=0.1,
111
- max_tokens=500
112
- )
113
-
114
- explanation = response['choices'][0]['message']['content']
115
-
116
- # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
117
- st.text("์„ค๋ช…:")
118
- st.write(explanation)
119
- pass
120
- #๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์ž…๋ ฅ์ค‘์ธ ๊ธ€์„ ๋‹ค๋“ฌ์–ด์„œ ๋‹ค์‹œ ์จ์คŒ
121
  with cols[3]:
122
- if st.button("๋‹ค์‹œ ์“ฐ๊ธฐ"):
123
- explanation_task = f"Rewrite the contents of '{user_input}' so that it will pass the writing test."
124
-
125
- messages = [
126
- {"role": "system", "content": "You are a helpful assistant. use only korean"},
127
- {"role": "user", "content": explanation_task}
128
- ]
129
-
130
- response = openai.ChatCompletion.create(
131
- model="gpt-3.5-turbo-16k",
132
- messages=messages,
133
- temperature=0.1,
134
- max_tokens=1000
135
- )
136
-
137
- explanation = response['choices'][0]['message']['content']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
- # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
140
- st.text("์„ค๋ช…:")
141
- st.write(explanation)
142
- pass
143
-
144
  if __name__ == "__main__":
145
- main()
 
3
  import openai
4
  import os
5
 
 
 
 
 
 
 
6
  # OpenAI API ์„ค์ • (ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ์ฝ์–ด์˜ด)
7
  openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด์ œ
8
 
9
  def main():
10
  st.title("ํ•œ๊ตญ์–ด ํ•™์Šต์ž๋ฅผ ์œ„ํ•œ HCI tools")
11
 
12
+ col1, col2 = st.columns(2)
13
 
14
  with col1:
15
  st.header("์ง€๋ฌธ")
16
 
17
+ user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค."""
 
 
 
 
18
  st.write(user_text)
19
 
20
+ # ์ƒ๋‹จ ์ปจํ…Œ์ด๋„ˆ
21
  with col2:
22
+ st.header("์กฐ์ž‘ ํŒจ๋„")
23
  user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
24
+
25
+ # ๋ฒ„ํŠผ row
26
  cols = st.columns(4)
27
+ with cols[0]:
28
+ btn_keyword = st.button("ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  with cols[1]:
30
+ btn_explanation = st.button("์ถ”๊ฐ€ ์„ค๋ช…")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  with cols[2]:
32
+ btn_simple = st.button("์‰ฌ์šด ํ‘œํ˜„")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  with cols[3]:
34
+ btn_rewrite = st.button("๋‹ค์‹œ ์“ฐ๊ธฐ")
35
+
36
+ # ํ•˜๋‹จ ์ปจํ…Œ์ด๋„ˆ
37
+ with st.container():
38
+ st.header("๊ฒฐ๊ณผ")
39
+
40
+ if btn_keyword:
41
+ # ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ ๋กœ์ง
42
+ # OpenAI API ํ˜ธ์ถœ์€ ์‹ค์ œ๋กœ ์‹คํ–‰ํ•˜์‹ค ๋•Œ ์ฃผ์„์„ ํ•ด์ œํ•ด์ฃผ์„ธ์š”.
43
+
44
+ response = openai.ChatCompletion.create(
45
+ model="gpt-3.5-turbo-16k",
46
+ prompt=f"Extract key words from the text: {user_text}",
47
+ temperature=0.1,
48
+ max_tokens=200
49
+ )
50
+ keywords = response['choices'][0]['text']
51
+
52
+ keywords = "๋ฏผ์ฃผ์ฃผ์˜, ๊ตญ๋ฏผ, ์ •์น˜, ์ฐธ์—ฌ, ๊ถŒ๋ฆฌ, ์ฐธ์ •๊ถŒ, ์„ ๊ฑฐ, ์‚ฌํšŒ ์ง‘๋‹จ, ๋Œ€ํ‘œ์ž, ๊ณต์ง์ž, ๋Œ€ํ‘œ์„ฑ, ํˆฌํ‘œ์œจ, ์ •๋‹น์„ฑ" # ์˜ˆ์‹œ
53
+ st.write(f"ํ‚ค์›Œ๋“œ: {keywords}")
54
+
55
+ if btn_explanation:
56
+ # ์ถ”๊ฐ€ ์„ค๋ช… ๋กœ์ง
57
+ # OpenAI API ํ˜ธ์ถœ์€ ์‹ค์ œ๋กœ ์‹คํ–‰ํ•˜์‹ค ๋•Œ ์ฃผ์„์„ ํ•ด์ œํ•ด์ฃผ์„ธ์š”.
58
+
59
+ response = openai.ChatCompletion.create(
60
+ model="gpt-3.5-turbo-16k",
61
+ prompt=f"Explain the term '{user_input}' in the context of the text: {user_text}",
62
+ temperature=0.1,
63
+ max_tokens=200
64
+ )
65
+ explanation = response['choices'][0]['text']
66
+
67
+ explanation = "์—ฌ๊ธฐ์— ์ถ”๊ฐ€ ์„ค๋ช…์ด ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค." # ์˜ˆ์‹œ
68
+ st.write(f"์„ค๋ช…: {explanation}")
69
+
70
+ if btn_simple:
71
+ # ์‰ฌ์šด ํ‘œํ˜„ ๋กœ์ง
72
+ # OpenAI API ํ˜ธ์ถœ์€ ์‹ค์ œ๋กœ ์‹คํ–‰ํ•˜์‹ค ๋•Œ ์ฃผ์„์„ ํ•ด์ œํ•ด์ฃผ์„ธ์š”.
73
+
74
+ response = openai.ChatCompletion.create(
75
+ model="gpt-3.5-turbo-16k",
76
+ prompt=f"Rewrite the text in simpler terms: {user_text}",
77
+ temperature=0.1,
78
+ max_tokens=200
79
+ )
80
+ simple_text = response['choices'][0]['text']
81
+ simple_text = "์—ฌ๊ธฐ์— ์‰ฌ์šด ํ‘œํ˜„์ด ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค." # ์˜ˆ์‹œ
82
+ st.write(f"์‰ฌ์šด ํ‘œํ˜„: {simple_text}")
83
+
84
+ if btn_rewrite:
85
+ # ๋‹ค์‹œ ์“ฐ๊ธฐ ๋กœ์ง
86
+ # OpenAI API ํ˜ธ์ถœ์€ ์‹ค์ œ๋กœ ์‹คํ–‰ํ•˜์‹ค ๋•Œ ์ฃผ์„์„ ํ•ด์ œํ•ด์ฃผ์„ธ์š”.
87
+
88
+ response = openai.ChatCompletion.create(
89
+ model="gpt-3.5-turbo-16k",
90
+ prompt=f"Rewrite the text: {user_text}",
91
+ temperature=0.1,
92
+ max_tokens=200
93
+ )
94
+ rewritten_text = response['choices'][0]['text']
95
+
96
+ rewritten_text = "์—ฌ๊ธฐ์— ๋‹ค์‹œ ์“ด ํ…์ŠคํŠธ๊ฐ€ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค." # ์˜ˆ์‹œ
97
+ st.write(f"๋‹ค์‹œ ์“ฐ๊ธฐ: {rewritten_text}")
98
 
 
 
 
 
 
99
  if __name__ == "__main__":
100
+ main()