File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
engines/python/setup/djl_python Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -335,8 +335,8 @@ def _json_chat_output_formatter(request_output: TextGenerationOutput):
335335 "message" : {
336336 "role" : "assistant" ,
337337 "content" : "" ,
338+ "tool_calls" : tool_calls ,
338339 },
339- "tool_calls" : tool_calls ,
340340 "logprobs" : None ,
341341 "finish_reason" : best_sequence .finish_reason ,
342342 }
@@ -353,8 +353,8 @@ def _json_chat_output_formatter(request_output: TextGenerationOutput):
353353 "message" : {
354354 "role" : "assistant" ,
355355 "content" : tool_call_info .content ,
356+ "tool_calls" : tool_calls ,
356357 },
357- "tool_calls" : tool_calls ,
358358 "logprobs" : None ,
359359 "finish_reason" : "tool_calls" ,
360360 }
@@ -484,11 +484,18 @@ def _jsonlines_chat_output_formatter(request_output: TextGenerationOutput):
484484 }]
485485 }]
486486 },
487+ auto_tools_called = False
488+ if last_token and tool_parser :
489+ auto_tools_called = len (tool_parser .prev_tool_call_arr ) > 0
487490 choice = {
488- "index" : 0 ,
489- "delta" : delta ,
490- "logprobs" : logprobs ,
491- "finish_reason" : best_sequence .finish_reason
491+ "index" :
492+ 0 ,
493+ "delta" :
494+ delta ,
495+ "logprobs" :
496+ logprobs ,
497+ "finish_reason" :
498+ "tool_calls" if auto_tools_called else best_sequence .finish_reason
492499 }
493500 response = {
494501 "id" : f"chatcmpl-{ id (request_output )} " ,
You can’t perform that action at this time.
0 commit comments