tttoaster commited on
Commit
4086dbb
1 Parent(s): 06429f7

Update conversation.py

Browse files
Files changed (1) hide show
  1. conversation.py +10 -7
conversation.py CHANGED
@@ -109,14 +109,17 @@ class Conversation:
109
  assert len(text_list) == len(single_turn['images']) + 1, print(text_list, len(single_turn['images']))
110
  message = ''
111
  for image_idx in range(len(single_turn['images'])):
112
- # image = single_turn['images'][image_idx]
113
- # image_base64 = encode_image(image)
114
- # image_str = f'<img src="data:image/png;base64,{image_base64}" alt="user upload image" />'
115
  image_path = single_turn['images'][image_idx]
116
- if image_path == '':
117
- message += text_list[image_idx] + '<corrupt_image>'
118
- else:
119
- message += text_list[image_idx] + f'![](file={image_path})'
 
 
 
 
 
 
120
  message += text_list[-1]
121
 
122
  if i % 2 == 0:
 
109
  assert len(text_list) == len(single_turn['images']) + 1, print(text_list, len(single_turn['images']))
110
  message = ''
111
  for image_idx in range(len(single_turn['images'])):
 
 
 
112
  image_path = single_turn['images'][image_idx]
113
+ image = Image.open(image_path)
114
+ image_base64 = encode_image(image)
115
+ image_str = f'<img src="data:image/png;base64,{image_base64}" alt="user upload image" />'
116
+ message += text_list[image_idx] + image_str
117
+
118
+ # image_path = single_turn['images'][image_idx]
119
+ # if image_path == '':
120
+ # message += text_list[image_idx] + '<corrupt_image>'
121
+ # else:
122
+ # message += text_list[image_idx] + f'![](file={image_path})'
123
  message += text_list[-1]
124
 
125
  if i % 2 == 0: