Spaces:
Runtime error
Runtime error
Update main.py
Browse files
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 |
|