Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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=
|
32 |
def run_inference(message, history):
|
33 |
print(message)
|
34 |
print(history)
|
35 |
|
36 |
-
##
|
37 |
messages = []
|
|
|
38 |
for couple in history:
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
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"])]))
|