Rijgersberg commited on
Commit
e139577
·
verified ·
1 Parent(s): c44304d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
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 files
33
- mime_type = get_mimetype(filepath)
34
- if not mime_type.contains('image'):
35
- raise gr.Error("Momenteel zijn alleen afbeeldingen ondersteund als bijlagen 💥!", duration=5)
36
- content = [
37
- {"type": "image_url",
38
- # for some reason you don't get the same image format in history as in message
39
- "image_url": {"url": process_image({'path': filepath,
40
- 'mime_type': mime_type})}}
41
- for filepath in user]
 
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})