10000 up · themrzmaster/llama-cpp-python@08cf4f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 08cf4f7

Browse files
committed
up
1 parent 454b5e3 commit 08cf4f7

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,31 @@ def mixtral_function_calling(
28902890
]:
28912891
end_token = "</s>"
28922892
function_calling_template = (
2893+
"<s>[AVAILABLE_TOOLS]"
2894+
"["
2895+
" {% for tool in tools %}"
2896+
" {"
2897+
" \"type\": \"function\","
2898+
" \"function\": {"
2899+
" \"name\": \"{{ tool.function.name }}\","
2900+
" \"description\": \"{{ tool.function.description }}\","
2901+
" \"parameters\": {"
2902+
" \"type\": \"object\","
2903+
" \"properties\": {"
2904+
" {% for param_key, param_spec in tool.function.parameters.properties.items() %}"
2905+
" \"{{ param_key }}\": {"
2906+
" \"type\": \"{{ param_spec.type }}\","
2907+
" \"description\": \"{{ param_spec.description }}\""
2908+
" }{% if not loop.last %},{% endif %}"
2909+
" {% endfor %}"
2910+
" },"
2911+
" \"required\": [{{ tool.function.parameters.required | join(', ') }}]"
2912+
" }"
2913+
" }"
2914+
" }{% if not loop.last %},{% endif %}"
2915+
" {% endfor %}"
2916+
"]"
2917+
"[/AVAILABLE_TOOLS]"
28932918
"{% for message in messages %}\n"
28942919
"{% if message.role == 'user' %}\n"
28952920
"<s>[INST] \n"
@@ -2921,31 +2946,7 @@ def mixtral_function_calling(
29212946
"The current temperature in {{ message.location }} is {{ message.content }} degrees Celsius.</s>\n"
29222947
"{% endif %}\n"
29232948
"{% endfor %}\n"
2924-
"[AVAILABLE_TOOLS]"
2925-
"["
2926-
" {% for tool in tools %}"
2927-
" {"
2928-
" \"type\": \"function\","
2929-
" \"function\": {"
2930-
" \"name\": \"{{ tool.function.name }}\","
2931-
" \"description\": \"{{ tool.function.description }}\","
2932-
" \"parameters\": {"
2933-
" \"type\": \"object\","
2934-
" \"properties\": {"
2935-
" {% for param_key, param_spec in tool.function.parameters.properties.items() %}"
2936-
" \"{{ param_key }}\": {"
2937-
" \"type\": \"{{ param_spec.type }}\","
2938-
" \"description\": \"{{ param_spec.description }}\""
2939-
" }{% if not loop.last %},{% endif %}"
2940-
" {% endfor %}"
2941-
" },"
2942-
" \"required\": [{{ tool.function.parameters.required | join(', ') }}]"
2943-
" }"
2944-
" }"
2945-
" }{% if not loop.last %},{% endif %}"
2946-
" {% endfor %}"
2947-
"]"
2948-
"[/AVAILABLE_TOOLS]"
2949+
29492950
)
29502951
template_renderer = jinja2.Environment(
29512952
loader=jinja2.BaseLoader(),

0 commit comments

Comments
 (0)
0