@@ -3453,7 +3453,7 @@ def _stream_tool_calls(
34533453 completions : List [llama_types .CreateCompletionResponse ] = []
34543454 completions_tool_name : List [str ] = []
34553455 finish_reason_chat_chunk = None
3456- while tool is not None :
3456+ while tool is not None and len ( completions ) <= 16 :
34573457 # Generate the parameter values for the selected tool
34583458 prompt += f"functions.{ tool_name } :\n "
34593459 try :
@@ -3726,9 +3726,12 @@ def chatml_function_calling(
37263726
37273727 # Case 2 step 2A: Respond with a message
37283728 if tool_name is None :
3729+ prompt = template_renderer .render (
3730+ messages = messages , tools = [], tool_calls = None , add_generation_prompt = True
3731+ )
37293732 return _convert_completion_to_chat (
37303733 llama .create_completion (
3731- prompt = prompt + "message: \n " ,
3734+ prompt = prompt ,
37323735 ** completion_kwargs , # type: ignore[arg-type]
37333736 logprobs = top_logprobs if logprobs else None ,
37343737 ),
@@ -3748,7 +3751,7 @@ def chatml_function_calling(
37483751 tool = next ((tool for tool in tools if tool ["function" ]["name" ] == tool_name ), None )
37493752 completions : List [llama_types .CreateCompletionResponse ] = []
37503753 completions_tool_name : List [str ] = []
3751- while tool is not None :
3754+ while tool is not None and len ( completions ) <= 16 :
37523755 # Generate the parameter values for the selected tool
37533756 prompt += f"functions.{ tool_name } :\n "
37543757 try :
0 commit comments