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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -10,7 +10,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด
10
  def main():
11
  st.title("Keyword Highlighter")
12
 
13
- user_text = st.text_area("Please enter your text here:", "")
14
  user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
15
  ์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜์ž์œ  ํˆฌํ‘œ์ œโ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜์˜๋ฌด ํˆฌํ‘œ์ œโ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(OECD) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.
16
  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ์ •๋‹น์„ฑ์„ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.
@@ -18,12 +18,12 @@ def main():
18
  """
19
 
20
  # ํ…์ŠคํŠธ ์ž…๋ ฅ ๋ฐ•์Šค ์ถ”๊ฐ€
21
- user_input = st.text_input("Enter a keyword or phrase you want to know more about:", "")
22
 
23
  st.text("์ง€๋ฌธ:")
24
  st.write(user_text)
25
 
26
- if st.button("Find Keywords"):
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,7 +61,8 @@ 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."
 
65
 
66
  messages = [
67
  {"role": "system", "content": explanation_task},
 
10
  def main():
11
  st.title("Keyword Highlighter")
12
 
13
+ # user_text = st.text_area("Please enter your text here:", "")
14
  user_text = """๋ฏผ์ฃผ์ฃผ์˜ ์‚ฌํšŒ๋Š” ๊ตญ๋ฏผ์ด ์ •์น˜์— ์ฐธ์—ฌํ•  ๊ถŒ๋ฆฌ๋ฅผ ๋ณด์žฅํ•œ๋‹ค. ๊ทธ๋Ÿฌํ•œ ๊ถŒ๋ฆฌ๋ฅผ ์ฐธ์ •๊ถŒ์ด๋ผ ํ•˜๋Š”๋ฐ, ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜์„ ๊ฑฐโ€™๋กœ ์‹คํ˜„๋œ๋‹ค. ์„ ๊ฑฐ๋Š” ์‚ฌํšŒ ์ง‘๋‹จ์˜ ๋Œ€ํ‘œ์ž๋‚˜ ๊ณต์ง์ž๋ฅผ ์„ ์ถœํ•˜์—ฌ ๊ทธ๋“ค์—๊ฒŒ ๋Œ€ํ‘œ์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ํ–‰์œ„์ด๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๋†’์€ ํˆฌํ‘œ์œจ์€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์ •๋‹น์„ฑ ํ™•๋ณด์™€ ๊นŠ์€ ๊ด€๋ จ์ด ์žˆ๋‹ค.
15
  ์„ ๊ฑฐ ํˆฌํ‘œ ์ œ๋„์—๋Š” ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ํˆฌํ‘œ์ž์˜ ์ž์œ ์˜์‚ฌ์— ๋งก๊ธฐ๋Š” โ€˜์ž์œ  ํˆฌํ‘œ์ œโ€™์™€ ํˆฌํ‘œ๊ถŒ ํ–‰์‚ฌ๋ฅผ ๊ตญ๋ฏผ์˜ ์˜๋ฌด๋กœ ๊ฐ„์ฃผํ•˜๊ณ  ์ •๋‹นํ•œ ์‚ฌ์œ  ์—†์ด ๊ธฐ๊ถŒํ•˜๋ฉด ๋ฒ•์  ์ œ์žฌ๋ฅผ ๊ฐ€ํ•˜๋Š” โ€˜์˜๋ฌด ํˆฌํ‘œ์ œโ€™๊ฐ€ ์žˆ๋‹ค. ์šฐ๋ฆฌ๋‚˜๋ผ๋Š” ์ž์œ  ํˆฌํ‘œ์ œ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ตœ๊ทผ ์น˜๋ฅธ ์„ ๊ฑฐ์˜ ํ‰๊ท  ํˆฌํ‘œ์œจ์ด 50ํผ์„ผํŠธ๋Œ€๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค. ๊ฒฝ์ œ ๊ฐœ๋ฐœ ํ˜‘๋ ฅ ๊ธฐ๊ตฌ(OECD) ํšŒ์›๊ตญ ํ‰๊ท ์ด 70ํผ์„ผํŠธ๋Œ€์ธ ๊ฒƒ์„ ์ƒ๊ฐํ•˜๋ฉด ๋งค์šฐ ๋‚ฎ์€ ์ˆ˜์น˜๋ผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์ด ์ง€์†๋˜์ž ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ์ด ์ œ์‹œ๋˜์—ˆ๊ณ , ์ž์œ  ํˆฌํ‘œ์ œ๊ฐ€ ๋ฏผ์ฃผ์ฃผ์˜์˜ ์›์น™์— ๋งž์œผ๋ฏ€๋กœ ์ด๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์˜๊ฒฌ๊ณผ ๋Œ€๋ฆฝํ•˜๊ณ  ์žˆ๋‹ค.
16
  ์˜๋ฌด ํˆฌํ‘œ์ œ๋ฅผ ๋„์ž…ํ•˜์ž๋Š” ์ธก์€ ๋‚ฎ์€ ํˆฌํ‘œ์œจ๋กœ ํˆฌํ‘œ ๊ฒฐ๊ณผ์˜ ์ •๋‹น์„ฑ์„ ํ™•๋ณดํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋งค์šฐ ์‹ฌ๊ฐํ•˜๋‹ค๊ณ  ์ฃผ์žฅํ•œ๋‹ค. ๋˜ ์˜๋ฌด ํˆฌํ‘œ์ œ์˜ ๊ฐ•์ œ์„ฑ๊ณผ ๋ฒ•์  ์ œ์žฌ๊ฐ€ ํˆฌํ‘œ์œจ์„ ๋†’์ด๋ฏ€๋กœ ํˆฌํ‘œ์œจ์ด ๋‚ฎ์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ณธ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ตญ๋ฏผ ๋Œ€๋ถ€๋ถ„์ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ•˜๊ฒŒ ๋˜๋ฉด ์ •์น˜์ธ๋“ค์ด ๋ชจ๋“  ๊ณ„์ธต์˜ ์ง€์ง€๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ •์ฑ… ๊ฒฝ์Ÿ๋ ฅ์„ ๋†’์ด๋ ค ํ•  ๊ฒƒ์ด๋ฏ€๋กœ ์ •์น˜ ์†Œ์™ธ ๊ณ„์ธต์— ๋”์šฑ ๊ด€์‹ฌ์„ ์Ÿ๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๋ผ๊ณ  ์ด์•ผ๊ธฐํ•œ๋‹ค.
 
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 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},