Skip to content

Commit df3e228

Browse files
fix template example copy (#1003)
1 parent a3cdd99 commit df3e228

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

swift/llm/utils/template.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) Alibaba, Inc. and its affiliates.
22
import re
3-
from copy import deepcopy
3+
from copy import copy, deepcopy
44
from io import BytesIO
55
from typing import Any, Dict, List, Literal, Optional, Tuple, Union
66

@@ -222,6 +222,7 @@ def encode(self, example: Dict[str, Any]) -> Tuple[Dict[str, Any], Dict[str, Any
222222
if not self._is_init:
223223
raise ValueError(
224224
'Template is not initialized, please use the `get_template` function to obtain the template.')
225+
example = copy(example)
225226
query: Optional[str] = example.pop('query', None)
226227
response: Optional[str] = example.pop('response', None)
227228
history: Optional[History] = example.pop('history', None)

0 commit comments

Comments
 (0)