Skip to content

Commit 9a44b43

Browse files
committed
improve gguf-function-calling parser
1 parent caec4ef commit 9a44b43

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,17 +4295,12 @@ def gguf_function_calling(
42954295
)
42964296
initial_gbnf_tool_grammar = (
42974297
(
4298-
'root ::= message_only | message_with_functions | functions_only\n'
4299-
'message_only ::= "message:" ws text\n'
4300-
'message_with_functions ::= "message:" ws text ws "<function_calls>" nl functions\n'
4301-
'functions_only ::= "<function_calls>" nl functions\n'
4298+
'root ::= "<function_calls>" "\\n" functions | "message:" text | "message:" text "<function_calls>" "\\n" functions\n'
43024299
'text ::= [^<]+\n'
4303-
'ws ::= [ \t\n]*\n'
4304-
'nl ::= "\\n"\n'
43054300
f"functions ::= {function_names}\n"
43064301
)
43074302
if tool_choice == "auto"
4308-
else f'root ::= "<function_calls>" nl functions\nfunctions ::= {function_names}\n'
4303+
else f'root ::= "<function_calls>" "\\n" functions\nfunctions ::= {function_names}\n'
43094304
)
43104305
completion = cast(
43114306
llama_types.CreateCompletionResponse,

0 commit comments

Comments
 (0)