@@ -2890,6 +2890,31 @@ def mixtral_function_calling(
2890
2890
]:
2891
2891
end_token = "</s>"
2892
2892
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]"
2893
2918
"{% for message in messages %}\n "
2894
2919
"{% if message.role == 'user' %}\n "
2895
2920
"<s>[INST] \n "
@@ -2921,31 +2946,7 @@ def mixtral_function_calling(
2921
2946
"The current temperature in {{ message.location }} is {{ message.content }} degrees Celsius.</s>\n "
2922
2947
"{% endif %}\n "
2923
2948
"{% 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
+
2949
2950
)
2950
2951
template_renderer = jinja2 .Environment (
2951
2952
loader = jinja2 .BaseLoader (),
0 commit comments