Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,15 +114,31 @@ async def chat(request: ChatRequest):
|
|
| 114 |
"Provide concise answers to the exact question asked and nothing more.\n"
|
| 115 |
)
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
| 118 |
for msg in history:
|
| 119 |
-
if msg.role == "user"
|
| 120 |
cleaned_user_text = clean_input_text(msg.text.strip())
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
elif msg.role == "model":
|
| 124 |
cleaned_model_text = clean_input_text(msg.text.strip())
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
|
| 128 |
#conversation += f"<|user|>\n{user_message.strip()}\n<|assistant|>"
|
|
|
|
| 114 |
"Provide concise answers to the exact question asked and nothing more.\n"
|
| 115 |
)
|
| 116 |
|
| 117 |
+
|
| 118 |
+
seen_user_messages = set()
|
| 119 |
+
seen_model_messages = set()
|
| 120 |
+
|
| 121 |
for msg in history:
|
| 122 |
+
if msg.role == "user":
|
| 123 |
cleaned_user_text = clean_input_text(msg.text.strip())
|
| 124 |
+
if cleaned_user_text and cleaned_user_text not in seen_user_messages:
|
| 125 |
+
conversation += f"<|user|>\n{cleaned_user_text}\n"
|
| 126 |
+
seen_user_messages.add(cleaned_user_text)
|
| 127 |
+
|
| 128 |
elif msg.role == "model":
|
| 129 |
cleaned_model_text = clean_input_text(msg.text.strip())
|
| 130 |
+
if cleaned_model_text and cleaned_model_text not in seen_model_messages:
|
| 131 |
+
conversation += f"<|assistant|>\n{cleaned_model_text}\n"
|
| 132 |
+
seen_model_messages.add(cleaned_model_text)
|
| 133 |
+
# seen_messages = set()
|
| 134 |
+
# for msg in history:
|
| 135 |
+
# if msg.role == "user" and msg.text.strip() not in seen_messages:
|
| 136 |
+
# cleaned_user_text = clean_input_text(msg.text.strip())
|
| 137 |
+
# conversation += f"<|user|>\n{cleaned_user_text}\n"
|
| 138 |
+
# seen_messages.add(cleaned_user_text)
|
| 139 |
+
# elif msg.role == "model":
|
| 140 |
+
# cleaned_model_text = clean_input_text(msg.text.strip())
|
| 141 |
+
# conversation += f"<|assistant|>\n{cleaned_model_text}\n"
|
| 142 |
|
| 143 |
|
| 144 |
#conversation += f"<|user|>\n{user_message.strip()}\n<|assistant|>"
|