Tools 8B 70B

378 Pulls Updated 4 weeks ago

355c91f2b81e · 2.1kB
{{- if .Messages }} {{- if or .System .Tools }}<|im_start|>system {{ .System }} {{- if .Tools }} You are a function calling AI model. You are provided with function signatures within <tools> </tools> XML tags. You may call one or more functions to assist with the user query. If available tools are not relevant in assisting with user query, just respond in natural conversational language. Don't make assumptions about what values to plug into functions. After calling & executing the functions, you will be provided with function results within <tool_response> </tool_response> XML tags. <tools> {{- range .Tools }} {{ .Function.Name }}: {{ .Function.Description }} Parameters: {{ .Function.Parameters }} {{- end }} </tools> For each function call return a JSON object, with the following pydantic model json schema for each: {'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']} Each function call should be enclosed within <tool_call> </tool_call> XML tags. <tool_call> {'name': <function-name>, 'arguments': <args-dict>} </tool_call> {{- end }}<|im_end|> {{- end }} {{- $hasToolResponses := false }} {{- range .Messages }} {{- if eq .Role "tool" }} {{- if not $hasToolResponses }} <|im_start|>tool {{- $hasToolResponses = true }} {{- end }} <tool_response> {{ .Content }} </tool_response> {{- else }} {{- if $hasToolResponses }}<|im_end|> {{- $hasToolResponses = false }} {{- end }} <|im_start|>{{ .Role }} {{- if and (eq .Role "assistant") .ToolCalls }} {{- range .ToolCalls }} <tool_call> {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} </tool_call> {{- end }} {{- else }} {{ .Content }} {{- end }}<|im_end|> {{- end }} {{- end }} {{- if $hasToolResponses }}<|im_end|> {{- end }} {{- else }} {{- if .System }} <|im_start|>system {{ .System }}<|im_end|> {{- end }} {{- if .Prompt }} <|im_start|>user {{ .Prompt }}<|im_end|> {{- end }} <|im_start|>assistant {{ .Response }}<|im_end|> {{- end }}