Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ system_prompt = f"<|im_start|>{system_role}\n{system_prompt}<|im_end|>"
|
|
| 42 |
@spaces.GPU()
|
| 43 |
def predict(message, history):
|
| 44 |
# history = []
|
| 45 |
-
history_transformer_format = history + [[message, ""]]
|
| 46 |
stop = StopOnTokens()
|
| 47 |
|
| 48 |
# Formatting the input for the model.
|
|
@@ -50,9 +50,11 @@ def predict(message, history):
|
|
| 50 |
# for item in history_transformer_format])
|
| 51 |
|
| 52 |
model_messages = []
|
| 53 |
-
|
|
|
|
| 54 |
model_messages.append({"role": user_role, "content": item[0]})
|
| 55 |
-
|
|
|
|
| 56 |
|
| 57 |
print(f'model_messages: {model_messages}')
|
| 58 |
|
|
|
|
| 42 |
@spaces.GPU()
|
| 43 |
def predict(message, history):
|
| 44 |
# history = []
|
| 45 |
+
# history_transformer_format = history + [[message, ""]]
|
| 46 |
stop = StopOnTokens()
|
| 47 |
|
| 48 |
# Formatting the input for the model.
|
|
|
|
| 50 |
# for item in history_transformer_format])
|
| 51 |
|
| 52 |
model_messages = []
|
| 53 |
+
print(f'history: {history}')
|
| 54 |
+
for i, item in enumerate(history):
|
| 55 |
model_messages.append({"role": user_role, "content": item[0]})
|
| 56 |
+
if i < len(history) - 1:
|
| 57 |
+
model_messages.append({"role": assistant_role, "content": item[1]})
|
| 58 |
|
| 59 |
print(f'model_messages: {model_messages}')
|
| 60 |
|