JUNGU commited on
Commit
62c0e70
โ€ข
1 Parent(s): b810ad1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -8,7 +8,7 @@ import os
8
  openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด์ œ
9
 
10
  def main():
11
- st.title("Keyword Highlighter")
12
 
13
  # user_text = st.text_area("Please enter your text here:", "")
14
  user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
@@ -18,12 +18,12 @@ def main():
18
  """
19
 
20
  # ํ…์ŠคํŠธ ์ž…๋ ฅ ๋ฐ•์Šค ์ถ”๊ฐ€
21
- user_input = st.text_input("์ž์„ธํžˆ ์•Œ๊ณ  ์‹ถ์€ ํ‚ค์›Œ๋“œ ๋˜๋Š” ๋ฌธ๊ตฌ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.:", "")
22
-
23
  st.text("์ง€๋ฌธ:")
24
  st.write(user_text)
25
 
26
- if st.button("ํ•ต์‹ฌ์–ด ์ฐพ๊ธฐ"):
27
 
28
  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:
29
  annotated_text(
@@ -61,12 +61,11 @@ def main():
61
 
62
  if user_input:
63
  # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ ์„ค๋ช…
64
- # explanation_task = f"Explain the term '{user_input}' in a simple manner based on the passage provided. use only korean."
65
  explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
66
 
67
  messages = [
68
- {"role": "system", "content": explanation_task},
69
- {"role": "user", "content": user_input}
70
  ]
71
 
72
  response = openai.ChatCompletion.create(
@@ -79,7 +78,7 @@ def main():
79
  explanation = response['choices'][0]['message']['content']
80
 
81
  # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
82
- st.text("Explanation:")
83
  st.write(explanation)
84
 
85
 
 
8
  openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด์ œ
9
 
10
  def main():
11
+ st.title("GPT-3๋ฅผ ํ™œ์šฉํ•œ ๊ตญ์–ด ๋ฌธ์ œ ์ƒ์„ฑ๊ธฐ")
12
 
13
  # user_text = st.text_area("Please enter your text here:", "")
14
  user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
 
18
  """
19
 
20
  # ํ…์ŠคํŠธ ์ž…๋ ฅ ๋ฐ•์Šค ์ถ”๊ฐ€
21
+ user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
22
+
23
  st.text("์ง€๋ฌธ:")
24
  st.write(user_text)
25
 
26
+ if st.button("ํ‚ค์›Œ๋“œ ์ฐพ๊ธฐ"):
27
 
28
  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:
29
  annotated_text(
 
61
 
62
  if user_input:
63
  # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ ์„ค๋ช…
 
64
  explanation_task = f"Explain the term '{user_input}' in a simple manner, based on the context of the following passage: {user_text}"
65
 
66
  messages = [
67
+ {"role": "system", "content": "You are a helpful assistant that explains complex topics in a way that an elementary school student can understand."},
68
+ {"role": "user", "content": explanation_task}
69
  ]
70
 
71
  response = openai.ChatCompletion.create(
 
78
  explanation = response['choices'][0]['message']['content']
79
 
80
  # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
81
+ st.text("์„ค๋ช…:")
82
  st.write(explanation)
83
 
84