pandora-s commited on
Commit
41c5f67
·
verified ·
1 Parent(s): 971f149

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -28,16 +28,21 @@ def image_to_base64(image_path):
28
  encoded_string = base64.b64encode(img.read()).decode('utf-8')
29
  return f"data:image/jpeg;base64,{encoded_string}"
30
 
31
- @spaces.GPU(duration=30)
32
  def run_inference(message, history):
33
  print(message)
34
  print(history)
35
 
36
- ## to be fixed
37
  messages = []
 
38
  for couple in history:
39
- messages.append(UserMessage(content = [ImageURLChunk(image_url=image_to_base64(file["path"])) for file in couple[0][0]]+[TextChunk(text=couple[0][1])]))
40
- messages.append(AssistantMessage(content = couple[1]))
 
 
 
 
41
  ##
42
 
43
  messages.append(UserMessage(content = [ImageURLChunk(image_url=image_to_base64(file["path"])) for file in message["files"]]+[TextChunk(text=message["text"])]))
 
28
  encoded_string = base64.b64encode(img.read()).decode('utf-8')
29
  return f"data:image/jpeg;base64,{encoded_string}"
30
 
31
+ @spaces.GPU(duration=60)
32
  def run_inference(message, history):
33
  print(message)
34
  print(history)
35
 
36
+ ## may work
37
  messages = []
38
+ images = []
39
  for couple in history:
40
+ if type(couple[0]) is tuple:
41
+ images += couple[0]
42
+ elif couple[0][1]:
43
+ messages.append(UserMessage(content = [ImageURLChunk(image_url=image_to_base64(path)) for path in images]+[TextChunk(text=couple[0][1])]))
44
+ messages.append(AssistantMessage(content = couple[1]))
45
+ images = []
46
  ##
47
 
48
  messages.append(UserMessage(content = [ImageURLChunk(image_url=image_to_base64(file["path"])) for file in message["files"]]+[TextChunk(text=message["text"])]))