Evaaaaa06 commited on
Commit
2dcd5ab
Β·
verified Β·
1 Parent(s): 03af1ab

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -4
main.py CHANGED
@@ -74,9 +74,7 @@ def upload_image_to_imgur_with_token(image_path, access_token):
74
  with open(image_path, "rb") as img_file:
75
  image_binary = img_file.read()
76
 
77
- headers = {
78
- "Authorization": f"Bearer {access_token}"
79
- }
80
 
81
  data = {
82
  "image": base64.b64encode(image_binary).decode("utf-8"),
@@ -103,6 +101,7 @@ def generate_image_with_gemini(prompt):
103
  tmp_file.write(image_data)
104
  return tmp_file.name
105
  return None
 
106
  #==========================
107
  # δ½Ώη”¨θ€…δΈŠε‚³εœ–η‰‡
108
  #==========================
@@ -170,7 +169,7 @@ def handle_image_message(event):
170
  chat = model.start_chat(history=[])
171
  chat_sessions[user_id] = chat
172
 
173
- user_text = event.message.text if event.message.type == "text"
174
  if user_text and user_text.startswith("θ«‹εΉ«ζˆ‘η”Ÿζˆεœ–η‰‡"):
175
  prompt = user_text.replace("θ«‹εΉ«ζˆ‘η”Ÿζˆεœ–η‰‡", "").strip()
176
 
 
74
  with open(image_path, "rb") as img_file:
75
  image_binary = img_file.read()
76
 
77
+ headers = {"Authorization": f"Bearer {access_token}"}
 
 
78
 
79
  data = {
80
  "image": base64.b64encode(image_binary).decode("utf-8"),
 
101
  tmp_file.write(image_data)
102
  return tmp_file.name
103
  return None
104
+
105
  #==========================
106
  # δ½Ώη”¨θ€…δΈŠε‚³εœ–η‰‡
107
  #==========================
 
169
  chat = model.start_chat(history=[])
170
  chat_sessions[user_id] = chat
171
 
172
+ user_text = event.message.text if event.message.type == "text" else None
173
  if user_text and user_text.startswith("θ«‹εΉ«ζˆ‘η”Ÿζˆεœ–η‰‡"):
174
  prompt = user_text.replace("θ«‹εΉ«ζˆ‘η”Ÿζˆεœ–η‰‡", "").strip()
175