Skip to content

Commit 6330c70

Browse files
authored
fix qwen2-audio (#2157)
1 parent 91e9751 commit 6330c70

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

swift/llm/utils/template.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ def add_default_tags(self, example: Dict[str, Any]) -> None:
434434
num_new_tags = num_media - num_media_tags
435435
assert num_new_tags >= 0, f'Number of media: {num_media}, number of media_tags: {num_media_tags}'
436436
history[0][0] = media_tag * num_new_tags + history[0][0]
437-
438-
example['query'], example['response'] = history[-1]
437+
example['query'] = history[-1][0]
438+
if example.get('response') is not None:
439+
example['response'] = history[-1][1]
439440
example['history'] = history[:-1]
440441

441442
def replace_media_tags(self, example) -> None:
@@ -2106,10 +2107,10 @@ class Internlm2Template(ChatmlTemplate):
21062107

21072108

21082109
def replace_img_tag(query: str,
2109-
response: str,
2110+
response: Optional[str],
21102111
history: History,
21112112
replace_token: str,
2112-
pattern=r'<img>(.+?)</img>') -> Tuple[str, History, List[str]]:
2113+
pattern=r'<img>(.+?)</img>') -> Tuple[str, Optional[str], History, List[str]]:
21132114
images_path = []
21142115
new_history = []
21152116
history.append([query, response])

0 commit comments

Comments
 (0)