haepada commited on
Commit
2277770
·
verified ·
1 Parent(s): 6000375

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -202,6 +202,25 @@ def handle_image_timeout(result_image, delay=IMAGE_DISPLAY_TIME):
202
  time.sleep(delay)
203
  return gr.update(value=None)
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  # Part 3/3 - Interface and Main
206
  def create_interface():
207
  # DB 초기화
 
202
  time.sleep(delay)
203
  return gr.update(value=None)
204
 
205
+ def save_reflection(text, state):
206
+ """감상 저장"""
207
+ if not text.strip():
208
+ return state, state["reflections"]
209
+
210
+ try:
211
+ current_time = datetime.now().strftime("%H:%M:%S")
212
+ sentiment = text_analyzer(text)[0]
213
+ new_reflection = [current_time, text, f"{sentiment['label']} ({sentiment['score']:.2f})"]
214
+
215
+ if "reflections" not in state:
216
+ state["reflections"] = []
217
+
218
+ state["reflections"].append(new_reflection)
219
+ return state, state["reflections"]
220
+ except Exception as e:
221
+ print(f"Error in save_reflection: {str(e)}")
222
+ return state, []
223
+
224
  # Part 3/3 - Interface and Main
225
  def create_interface():
226
  # DB 초기화