Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -160,20 +160,26 @@ def handle_image_message(event):
|
|
160 |
|
161 |
# === 以下是處理解釋圖片部分 === #
|
162 |
|
163 |
-
response = client.
|
164 |
-
model="gpt-4o
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
175 |
)
|
176 |
-
|
|
|
177 |
with ApiClient(configuration) as api_client:
|
178 |
line_bot_api = MessagingApi(api_client)
|
179 |
line_bot_api.reply_message(
|
|
|
160 |
|
161 |
# === 以下是處理解釋圖片部分 === #
|
162 |
|
163 |
+
response = client.chat.completions.create(
|
164 |
+
model="gpt-4o",
|
165 |
+
messages=[
|
166 |
+
{
|
167 |
+
"role": "user",
|
168 |
+
"content": [
|
169 |
+
{"type": "text", "text": "請描述這張圖片"},
|
170 |
+
{
|
171 |
+
"type": "image_url",
|
172 |
+
"image_url": {
|
173 |
+
"url": image_url,
|
174 |
+
}
|
175 |
+
}
|
176 |
+
]
|
177 |
+
}
|
178 |
+
],
|
179 |
+
max_tokens=800
|
180 |
)
|
181 |
+
|
182 |
+
app.logger.info(response.choices[0].message.content)
|
183 |
with ApiClient(configuration) as api_client:
|
184 |
line_bot_api = MessagingApi(api_client)
|
185 |
line_bot_api.reply_message(
|