Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,16 +29,17 @@ def generate(message, history, model, system_prompt,
|
|
| 29 |
# history
|
| 30 |
history_openai_format = [{"role": "system", "content": system_prompt}]
|
| 31 |
for user, assistant in history:
|
| 32 |
-
if isinstance(user, tuple): # there were
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
history_openai_format.append(
|
| 44 |
{"role": "user", "content": content})
|
|
|
|
| 29 |
# history
|
| 30 |
history_openai_format = [{"role": "system", "content": system_prompt}]
|
| 31 |
for user, assistant in history:
|
| 32 |
+
if isinstance(user, tuple): # there were
|
| 33 |
+
content = []
|
| 34 |
+
for filepath in user:
|
| 35 |
+
mime_type = get_mimetype(filepath)
|
| 36 |
+
if not mime_type.contains('image'):
|
| 37 |
+
raise gr.Error("Momenteel zijn alleen afbeeldingen ondersteund als bijlagen 💥!", duration=5)
|
| 38 |
+
content.append(
|
| 39 |
+
{"type": "image_url",
|
| 40 |
+
# for some reason you don't get the same image format in history as in message
|
| 41 |
+
"image_url": {"url": process_image({'path': filepath,
|
| 42 |
+
'mime_type': mime_type})}})
|
| 43 |
|
| 44 |
history_openai_format.append(
|
| 45 |
{"role": "user", "content": content})
|