File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -2500,8 +2500,7 @@ def base_function_calling(
2500
2500
text = completion ["choices" ][0 ]["text" ]
2501
2501
print (text )
2502
2502
if "message" in text :
2503
- return _convert_completion_to_chat (
2504
- llama .create_completion (
2503
+ message_output = llama .create_completion (
2505
2504
prompt = prompt + "message:\n " ,
2506
2505
temperature = temperature ,
2507
2506
top_p = top_p ,
@@ -2524,8 +2523,11 @@ def base_function_calling(
2524
2523
# grammar=llama_grammar.LlamaGrammar.from_string(
2525
2524
# follow_up_gbnf_tool_grammar, verbose=llama.verbose
2526
2525
# ),
2527
- ),stream = stream
2528
- )
2526
+ )
2527
+ text : llama_types .CreateCompletionResponse = message_output # type: ignore
2528
+ # fallback
2529
+ if not text ["choices" ][0 ]["text" ].startswith ("functions." ):
2530
+ return _convert_completion_to_chat (message_output ,stream = stream )
2529
2531
2530
2532
# One or more function calls
2531
2533
tool_name = text [len ("functions." ) :].replace (":" , "" )
You can’t perform that action at this time.
0 commit comments