JUNGU commited on
Commit
022cf58
โ€ข
1 Parent(s): f404a7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -2
app.py CHANGED
@@ -15,7 +15,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY") # ์‹ค์ œ ์ฝ”๋“œ์—์„œ ์ฃผ์„ ํ•ด
15
  def main():
16
  st.title("ํ•œ๊ตญ์–ด ํ•™์Šต์ž๋ฅผ ์œ„ํ•œ HCI tools")
17
 
18
- col1, col2 = st.columns([7, 3])
19
 
20
  with col1:
21
  st.header("์ง€๋ฌธ")
@@ -30,7 +30,7 @@ def main():
30
  with col2:
31
  user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
32
 
33
- cols = st.columns(2)
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:
@@ -92,5 +92,31 @@ def main():
92
  st.write(explanation)
93
  pass
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  if __name__ == "__main__":
96
  main()
 
15
  def main():
16
  st.title("ํ•œ๊ตญ์–ด ํ•™์Šต์ž๋ฅผ ์œ„ํ•œ HCI tools")
17
 
18
+ col1, col2 = st.columns([70, 30],width="auto")
19
 
20
  with col1:
21
  st.header("์ง€๋ฌธ")
 
30
  with col2:
31
  user_input = st.text_input("๋ชจ๋ฅด๋Š” ๋ฌธ์žฅ์ด๋‚˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", "")
32
 
33
+ cols = st.columns(3)
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:
 
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=150
112
+ )
113
+
114
+ explanation = response['choices'][0]['message']['content']
115
+
116
+ # ์‰ฌ์šด ํ‘œํ˜„์œผ๋กœ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
117
+ st.text("์„ค๋ช…:")
118
+ st.write(explanation)
119
+ pass
120
+
121
  if __name__ == "__main__":
122
  main()