Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,9 +52,7 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
|
|
| 52 |
print(f'message is - {message}')
|
| 53 |
print(f'history is - {history}')
|
| 54 |
conversation = []
|
| 55 |
-
|
| 56 |
-
conversation.extend([{"role": "user", "content": prompt}, {"role": "assistant", "content": answer}])
|
| 57 |
-
|
| 58 |
if message["files"]:
|
| 59 |
image = Image.open(message["files"][-1])
|
| 60 |
else:
|
|
@@ -63,7 +61,10 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
|
|
| 63 |
image = None
|
| 64 |
elif len(history):
|
| 65 |
image = Image.open(history[0][0][0])
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
conversation.append({"role": "user", "content": f"<|image_1|>\n{message['text']}"})
|
| 68 |
print(f"Conversation is -\n{conversation}")
|
| 69 |
inputs = processor.tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
|
|
|
|
| 52 |
print(f'message is - {message}')
|
| 53 |
print(f'history is - {history}')
|
| 54 |
conversation = []
|
| 55 |
+
|
|
|
|
|
|
|
| 56 |
if message["files"]:
|
| 57 |
image = Image.open(message["files"][-1])
|
| 58 |
else:
|
|
|
|
| 61 |
image = None
|
| 62 |
elif len(history):
|
| 63 |
image = Image.open(history[0][0][0])
|
| 64 |
+
for prompt, answer in history:
|
| 65 |
+
conversation[0]['content'] = f"<|image_1|>\n{prompt}"
|
| 66 |
+
conversation.extend([{"role": "assistant", "content": answer}])
|
| 67 |
+
|
| 68 |
conversation.append({"role": "user", "content": f"<|image_1|>\n{message['text']}"})
|
| 69 |
print(f"Conversation is -\n{conversation}")
|
| 70 |
inputs = processor.tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
|