8000 up · themrzmaster/llama-cpp-python@4a896a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a896a1

Browse files
committed
up
1 parent 724faf7 commit 4a896a1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,21 +2910,25 @@ def llama3_function_calling(
29102910
"\nfunctions.{{ tool.function.name }}:\n"
29112911
"{{ tool.function.parameters | tojson }}"
29122912
"\n{% endfor %}"
2913-
"\nYou can respond to users messages with either a single message or one or more function calls. Never both. Prioritize function calls over messages."
2914-
"\nTo respond with a message begin the message with 'message:'"
2915-
'\n Example sending message: message: "Hello, how can I help you?"'
2916-
"\nTo respond with one or more function calls begin the message with 'functions.<function_name>:', use the following format:"
2913+
"\nYou can respond to user messages either by sending a single message or by making one or more function calls. You should never do both. Always prioritize function calls over messages."
2914+
"\nTo send a response message, start your message with 'message:'"
2915+
'\nExample of sending a message: message: "Hello, how can I help you?"'
2916+
"\nTo use one or more function calls, start your response with 'functions.<function_name>:', follow this format:"
29172917
"\nfunctions.<function_name>:"
29182918
'\n{ "arg1": "value1", "arg2": "value2" }'
29192919
"\nfunctions.<function_name>:"
29202920
'\n{ "arg1": "value1", "arg2": "value2" }'
2921-
"\nWhen you are done with the function calls, end the message with </done>."
2922-
'\nStart your output with either message: or functions. <|eot_id|>\n'
2921+
"\nWhen you have completed entering function calls, end your output with '</done>'."
2922+
'\nStart your output with either "message:" or "functions.". Do not mix the two.'
2923+
'\n In any hypothesis you should output: message: function_name: arguments never do that'
2924+
"\nWhen you encounter a <tool_output> tag from a user message, it indicates the output from a previously executed function."
2925+
"Please present this output in an easy-to-understand format, as the user has not seen it directly.\n"
2926+
"Example: <tool_output> item: Cheeseburguer, price: 12 </tool_output> You should output: I found a Cheeseburguer that costs 12 dollars."
29232927
"{% endif %}"
29242928
"{% for message in messages %}"
29252929
"{% if message.role == 'tool' %}"
29262930
"<|start_header_id|>user<|end_header_id|>\n\n"
2927-
"here is the Function response, bring it to me in a nice way: {{ message.content | default('No response available') }}"
2931+
"<tool_output> {{ message.content | default('No response available') }} </tool_output>"
29282932
"<|eot_id|>\n"
29292933
"{% elif message.role == 'assistant' and message.function_call is defined%}"
29302934
"<|start_header_id|>{{ message.role }}<|end_header_id|>\n\n"

0 commit comments

Comments
 (0)
0