File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1058,6 +1058,7 @@ def _swift_prepare_inputs(self, inputs):
1058
1058
i += 1
1059
1059
pre_message ['content' ], tool_content = self .agent_template ._format_tool_responses (
1060
1060
pre_content , messages [i_start :i + 1 ])
1061
+ # where tool_content is a List.
1061
1062
messages [i_start :i + 1 ] = [{'role' : 'tool' , 'content' : tool_content }]
1062
1063
i = i_start + 1
1063
1064
elif pre_role == 'assistant' and role == 'assistant' or pre_role == 'user' and role == 'user' :
Original file line number Diff line number Diff line change @@ -45,8 +45,10 @@ def _swift_prepare_inputs(self, inputs):
45
45
# Delete the content before '</think>' in all assistant turns except the last round.
46
46
if message ['role' ] == 'assistant' and isinstance (message ['content' ], str ) and i != len (messages ) - 1 :
47
47
if self .with_answer :
48
- message ['content' ] = message ['content' ].split ('<answer>' )[- 1 ].rstrip ().rstrip (
49
- '</answer>' ).strip ()
48
+ message ['content' ] = message ['content' ].split ('<answer>' )[- 1 ].rstrip ()
49
+ if message ['content' ].endswith ('</answer>' ):
50
+ message ['content' ] = message ['content' ][:- len ('</answer>' )]
51
+ message ['content' ] = message ['content' ].strip ()
50
52
else :
51
53
message ['content' ] = message ['content' ].split ('</think>' )[- 1 ].strip ()
52
54
You can’t perform that action at this time.
0 commit comments