Update app.py
Browse files
app.py
CHANGED
|
@@ -115,6 +115,7 @@ def sse_chat():
|
|
| 115 |
chat_history = [{'role': 'system', 'content': ' '}, *chat_history]
|
| 116 |
|
| 117 |
chat_template = TrainerTools().tokenizer.apply_chat_template(chat_history, tokenizer=False)
|
|
|
|
| 118 |
chat_template = f'{chat_template}<assistant>'
|
| 119 |
|
| 120 |
if search_api:
|
|
@@ -124,7 +125,7 @@ def sse_chat():
|
|
| 124 |
search_msg = f'根据用户的问题,我搜索到了如下内容:\n{search_result}'
|
| 125 |
yield fmt_msg('thinking_chunk', search_msg)
|
| 126 |
chat_template = f'{chat_template}<think>{search_msg}</think>'
|
| 127 |
-
|
| 128 |
prompt_token = TrainerTools().tokenizer.encode(chat_template, unsqueeze=True)
|
| 129 |
output_token_count = max(2048 - prompt_token.shape[-1], 0)
|
| 130 |
|
|
|
|
| 115 |
chat_history = [{'role': 'system', 'content': ' '}, *chat_history]
|
| 116 |
|
| 117 |
chat_template = TrainerTools().tokenizer.apply_chat_template(chat_history, tokenizer=False)
|
| 118 |
+
print(f"gen for {chat_history}")
|
| 119 |
chat_template = f'{chat_template}<assistant>'
|
| 120 |
|
| 121 |
if search_api:
|
|
|
|
| 125 |
search_msg = f'根据用户的问题,我搜索到了如下内容:\n{search_result}'
|
| 126 |
yield fmt_msg('thinking_chunk', search_msg)
|
| 127 |
chat_template = f'{chat_template}<think>{search_msg}</think>'
|
| 128 |
+
|
| 129 |
prompt_token = TrainerTools().tokenizer.encode(chat_template, unsqueeze=True)
|
| 130 |
output_token_count = max(2048 - prompt_token.shape[-1], 0)
|
| 131 |
|