Tools 8B

Updated 4 weeks ago

98ea10a007fa · 1.7kB
{{- if .Messages }} {{- if or .System .Tools }}<|start_header_id|>system<|end_header_id|> {{ .System }} {{- if .Tools }} You are a function calling AI model. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into function. The user may use the terms function calling or tool use interchangeably. Here are the available functions: <tools>{{ json .Tools }}</tools> For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags in the format: <tool_call>{"tool_name": <function-name>, "tool_arguments": <args-dict>}</tool_call> {{- end }}<|eot_id|> {{- end }} {{- $hasToolResponses := false }} {{- range .Messages }} {{- if eq .Role "tool" }} {{- if not $hasToolResponses }} <|start_header_id|>tool<|end_header_id|> {{- $hasToolResponses = true }} {{- end }} <tool_response> {{ .Content }} </tool_response> {{- else }} {{- if $hasToolResponses }}<|eot_id|> {{- $hasToolResponses = false }} {{- end }} <|start_header_id|>{{ .Role }}<|end_header_id|> {{- if and (eq .Role "assistant") .ToolCalls }} <tool_call> {{- range .ToolCalls }} {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} {{- end }} </tool_call> {{- else }} {{ .Content }} {{- end }}<|eot_id|> {{- end }} {{- end }} {{- if $hasToolResponses }}<|eot_id|> {{- end }} <|start_header_id|>assistant<|end_header_id|> {{ else }} {{- if .System }} <|start_header_id|>system<|end_header_id|> {{ .System }}<|eot_id|> {{- end }} {{- if .Prompt }} <|start_header_id|>user<|end_header_id|> {{ .Prompt }}<|eot_id|> {{- end }} <|start_header_id|>assistant<|end_header_id|> {{ .Response }}<|eot_id|> {{- end }}