Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,14 +53,21 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
|
|
| 53 |
print(f'history is - {history}')
|
| 54 |
conversation = []
|
| 55 |
if message["files"]:
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
conversation.append({"role": "user", "content": f"<|image_1|>\n{message['text']}"})
|
| 58 |
else:
|
| 59 |
if len(history) == 0:
|
| 60 |
raise gr.Error("Please upload an image first.")
|
| 61 |
image = None
|
| 62 |
else:
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
for prompt, answer in history:
|
| 65 |
if answer is None:
|
| 66 |
conversation.extend([{"role": "user", "content":""}])
|
|
|
|
| 53 |
print(f'history is - {history}')
|
| 54 |
conversation = []
|
| 55 |
if message["files"]:
|
| 56 |
+
image_path = message["files"][-1]
|
| 57 |
+
if isinstance(image_path, dict):
|
| 58 |
+
mage_path = image_path["path"]
|
| 59 |
+
image = Image.open(image_path)
|
| 60 |
conversation.append({"role": "user", "content": f"<|image_1|>\n{message['text']}"})
|
| 61 |
else:
|
| 62 |
if len(history) == 0:
|
| 63 |
raise gr.Error("Please upload an image first.")
|
| 64 |
image = None
|
| 65 |
else:
|
| 66 |
+
if isinstance(history[0][0], tuple):
|
| 67 |
+
image_path = history[0][0][0]
|
| 68 |
+
else:
|
| 69 |
+
image_path = history[0][0]
|
| 70 |
+
image = Image.open(image_path)
|
| 71 |
for prompt, answer in history:
|
| 72 |
if answer is None:
|
| 73 |
conversation.extend([{"role": "user", "content":""}])
|