Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions swift/llm/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ def _swift_prepare_inputs(self, inputs: StdTemplateInputs):
i += 1
pre_message['content'], tool_content = self.agent_template._format_tool_responses(
pre_content, messages[i_start:i + 1])
# where tool_content is a List.
messages[i_start:i + 1] = [{'role': 'tool', 'content': tool_content}]
i = i_start + 1
elif pre_role == 'assistant' and role == 'assistant' or pre_role == 'user' and role == 'user':
Expand Down
6 changes: 4 additions & 2 deletions swift/llm/template/template/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def _swift_prepare_inputs(self, inputs):
# Delete the content before '</think>' in all assistant turns except the last round.
if message['role'] == 'assistant' and isinstance(message['content'], str) and i != len(messages) - 1:
if self.with_answer:
message['content'] = message['content'].split('<answer>')[-1].rstrip().rstrip(
'</answer>').strip()
message['content'] = message['content'].split('<answer>')[-1].rstrip()
if message['content'].endswith('</answer>'):
message['content'] = message['content'][:-len('</answer>')]
message['content'] = message['content'].strip()
else:
message['content'] = self.history_think_prefix + message['content'].split(
'</think>')[-1].strip()
Expand Down
Loading