JUNGU commited on
Commit
76efd51
β€’
1 Parent(s): ea65f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -98,11 +98,31 @@ def main():
98
  presence_penalty=0
99
  )
100
 
 
 
 
 
101
  highlighted_text = response['choices'][0]['message']['content']
102
 
103
- # μ—¬κΈ°μ„œλŠ” κ°„λ‹¨ν•˜κ²Œ exec ν•¨μˆ˜λ₯Ό μ΄μš©ν•΄ GPT-3.5-turboκ°€ μƒμ„±ν•œ μ½”λ“œλ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.
104
- # μ‹€μ œ ν”„λ‘œλ•μ…˜ ν™˜κ²½μ—μ„œλŠ” λ³΄μ•ˆ 이슈λ₯Ό κ³ λ €ν•΄μ•Ό ν•©λ‹ˆλ‹€.
105
- exec(highlighted_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  if __name__ == "__main__":
108
  main()
 
98
  presence_penalty=0
99
  )
100
 
101
+ # highlighted_text = response['choices'][0]['message']['content']
102
+
103
+ #gpt닡변이 였λ₯˜κ°€ λ‚˜λŠ” κ²½μš°κ°€ μžˆμ–΄μ„œ 였λ₯˜ 체크λ₯Ό μœ„ν•œ λΆ€λΆ„ μΆ”κ°€
104
+ # GPT-3λ‘œλΆ€ν„° λ°˜ν™˜λ°›μ€ 응닡
105
  highlighted_text = response['choices'][0]['message']['content']
106
 
107
+ # 1. λ°˜ν™˜λœ ν…μŠ€νŠΈκ°€ `annotated_text(`둜 μ‹œμž‘ν•˜κ³  `)`둜 λλ‚˜λŠ”μ§€ 확인
108
+ if not highlighted_text.startswith("annotated_text(") or not highlighted_text.endswith(")"):
109
+ st.error("Invalid response format from GPT-3.")
110
+
111
+ # 2. κ΄„ν˜Έμ˜ κ°œμˆ˜κ°€ μ˜¬λ°”λ₯Έμ§€ 확인
112
+ elif highlighted_text.count("(") != highlighted_text.count(")"):
113
+ st.error("Mismatched parentheses in the response.")
114
+
115
+ # 3. λ¬Έμžμ—΄ λ‚΄μ˜ μŒλ”°μ˜΄ν‘œλ‚˜ μ‹±κΈ€ λ”°μ˜΄ν‘œμ— λ¬Έμ œκ°€ μ—†λŠ”μ§€ 확인
116
+ elif highlighted_text.count('"') % 2 != 0:
117
+ st.error("Mismatched quotes in the response.")
118
+
119
+ else:
120
+ # λ°˜ν™˜λœ ν…μŠ€νŠΈλ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€. (이 뢀뢄은 λ³΄μ•ˆμƒ μœ„ν—˜ν•  수 μžˆμœΌλ―€λ‘œ μ‹ μ€‘ν•˜κ²Œ μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.)
121
+ exec(highlighted_text)
122
+
123
+ # # μ—¬κΈ°μ„œλŠ” κ°„λ‹¨ν•˜κ²Œ exec ν•¨μˆ˜λ₯Ό μ΄μš©ν•΄ GPT-3.5-turboκ°€ μƒμ„±ν•œ μ½”λ“œλ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.
124
+ # # μ‹€μ œ ν”„λ‘œλ•μ…˜ ν™˜κ²½μ—μ„œλŠ” λ³΄μ•ˆ 이슈λ₯Ό κ³ λ €ν•΄μ•Ό ν•©λ‹ˆλ‹€.
125
+ # exec(highlighted_text)
126
 
127
  if __name__ == "__main__":
128
  main()