FrankC0st1e
commited on
Commit
•
43b498b
1
Parent(s):
a4f2dcb
fix: empty system prompt
Browse files- tokenization_minicpm.py +3 -2
tokenization_minicpm.py
CHANGED
@@ -4,6 +4,7 @@ import keyword
|
|
4 |
import traceback
|
5 |
import uuid
|
6 |
from collections import deque
|
|
|
7 |
from logging import getLogger
|
8 |
from typing import Any, Dict, List, Optional, Union
|
9 |
|
@@ -324,6 +325,8 @@ def input_format(messages: List[Dict], tools: List[Dict], add_to_system=True):
|
|
324 |
the tools list you can use
|
325 |
For example:
|
326 |
"""
|
|
|
|
|
327 |
if tools is not None and len(tools) > 0:
|
328 |
header = (
|
329 |
"from enum import Enum\nfrom typing import List, Dict, Optional\nfrom pydantic import BaseModel, Field\n\n"
|
@@ -363,8 +366,6 @@ func2(params)
|
|
363 |
tools_string = ""
|
364 |
|
365 |
if add_to_system:
|
366 |
-
if len(messages) > 0 and messages[0]["role"] != "system":
|
367 |
-
messages.insert(0, {"role": "system", "content": ""})
|
368 |
return [message_format(msg, system_suffix=tools_string, user_prefix="") for msg in messages]
|
369 |
else:
|
370 |
return [message_format(msg, system_suffix="", user_prefix=tools_string) for msg in messages]
|
|
|
4 |
import traceback
|
5 |
import uuid
|
6 |
from collections import deque
|
7 |
+
from copy import deepcopy
|
8 |
from logging import getLogger
|
9 |
from typing import Any, Dict, List, Optional, Union
|
10 |
|
|
|
325 |
the tools list you can use
|
326 |
For example:
|
327 |
"""
|
328 |
+
messages = deepcopy(messages)
|
329 |
+
tools = deepcopy(tools)
|
330 |
if tools is not None and len(tools) > 0:
|
331 |
header = (
|
332 |
"from enum import Enum\nfrom typing import List, Dict, Optional\nfrom pydantic import BaseModel, Field\n\n"
|
|
|
366 |
tools_string = ""
|
367 |
|
368 |
if add_to_system:
|
|
|
|
|
369 |
return [message_format(msg, system_suffix=tools_string, user_prefix="") for msg in messages]
|
370 |
else:
|
371 |
return [message_format(msg, system_suffix="", user_prefix=tools_string) for msg in messages]
|