Evaaaaa06 commited on
Commit
5e2e6eb
·
verified ·
1 Parent(s): 8cc2c87

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -6
main.py CHANGED
@@ -65,9 +65,9 @@ async def webhook(
65
 
66
  #設定open AI API 金鑰
67
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
 
68
  # 使用字典模擬用戶訊息歷史存儲
69
  user_message_history = defaultdict(list)
70
-
71
  def store_user_message(user_id, message_type, message_content):
72
  """
73
  儲存用戶的訊息
@@ -122,18 +122,15 @@ def analyze_with_openai(image_path, user_text):
122
  return "發生未知錯誤,請稍後再試!"
123
 
124
 
125
-
126
-
127
  def get_previous_message(user_id):
128
  """
129
  獲取用戶的上一則訊息
130
  """
131
- if user_id in user_message_history and len(user_message_history[user_id]) > 0:
132
  # 返回最後一則訊息
133
  return user_message_history[user_id][-1]
134
  return None
135
-
136
-
137
  @line_handler.add(MessageEvent, message=(ImageMessage,TextMessage))
138
  def handle_image_message(event):
139
  global working_status
 
65
 
66
  #設定open AI API 金鑰
67
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
68
+
69
  # 使用字典模擬用戶訊息歷史存儲
70
  user_message_history = defaultdict(list)
 
71
  def store_user_message(user_id, message_type, message_content):
72
  """
73
  儲存用戶的訊息
 
122
  return "發生未知錯誤,請稍後再試!"
123
 
124
 
 
 
125
  def get_previous_message(user_id):
126
  """
127
  獲取用戶的上一則訊息
128
  """
129
+ if user_id in user_message_history and len(user_message_history[user_id]) > 0:
130
  # 返回最後一則訊息
131
  return user_message_history[user_id][-1]
132
  return None
133
+
 
134
  @line_handler.add(MessageEvent, message=(ImageMessage,TextMessage))
135
  def handle_image_message(event):
136
  global working_status