Update app.py
Browse files
app.py
CHANGED
@@ -72,7 +72,7 @@ def generate_response(user_message, max_tokens, temperature, top_p, history_stat
|
|
72 |
{"role": "user", "content": user_message},
|
73 |
{"role": "assistant", "content": ""}
|
74 |
]
|
75 |
-
|
76 |
try:
|
77 |
for new_token in streamer:
|
78 |
if "<|end" in new_token:
|
@@ -84,24 +84,8 @@ def generate_response(user_message, max_tokens, temperature, top_p, history_stat
|
|
84 |
except Exception:
|
85 |
pass
|
86 |
|
87 |
-
yield new_history, new_history'''
|
88 |
-
|
89 |
-
try:
|
90 |
-
for new_token in streamer:
|
91 |
-
if "<|end" in new_token:
|
92 |
-
continue
|
93 |
-
cleaned_token = new_token.replace("<|im_start|>", "").replace("<|im_sep|>", "").replace("<|im_end|>", "")
|
94 |
-
assistant_response += cleaned_token
|
95 |
-
new_history[-1]["content"] = assistant_response.strip()
|
96 |
-
yield new_history, new_history
|
97 |
-
except Exception:
|
98 |
-
new_history[-1]["content"] += "\n⚠️ Incomplete response due to generation limit or stream error."
|
99 |
yield new_history, new_history
|
100 |
-
return
|
101 |
|
102 |
-
# Final yield to clean up in case of clean stop
|
103 |
-
new_history[-1]["content"] = assistant_response.strip()
|
104 |
-
yield new_history, new_history
|
105 |
|
106 |
example_messages = {
|
107 |
"JEE Main 2025 Combinatorics": "From all the English alphabets, five letters are chosen and are arranged in alphabetical order. The total number of ways, in which the middle letter is 'M', is?",
|
|
|
72 |
{"role": "user", "content": user_message},
|
73 |
{"role": "assistant", "content": ""}
|
74 |
]
|
75 |
+
|
76 |
try:
|
77 |
for new_token in streamer:
|
78 |
if "<|end" in new_token:
|
|
|
84 |
except Exception:
|
85 |
pass
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
yield new_history, new_history
|
|
|
88 |
|
|
|
|
|
|
|
89 |
|
90 |
example_messages = {
|
91 |
"JEE Main 2025 Combinatorics": "From all the English alphabets, five letters are chosen and are arranged in alphabetical order. The total number of ways, in which the middle letter is 'M', is?",
|