available in [F16, q8_0, q6_K, q4_K_S]
tools
15 Pulls Updated 6 weeks ago
706baf9c33ed · 3.2kB
{{- .BosToken }}
{{/* Variable Initialization */}}
{{- $tools := or .CustomTools .Tools }}
{{- $toolsInUserMessage := or .ToolsInUserMessage true }}
{{- $dateString := or .DateString "26 Jul 2024" }}
{{/* Define variables at root scope */}}
{{- $systemMessage := "" }}
{{- $messages := .Messages }}
{{/* System Message Extraction */}}
{{- if eq (index .Messages 0).Role "system" }}
{{- $systemMessage = (index .Messages 0).Content }}
{{- $messages = slice .Messages 1 }}
{{- end }}
{{/* System Message + Built-in Tools */}}
<|start_header_id|>system<|end_header_id>
{{- if or .BuiltinTools $tools }}
Environment: ipython
{{- end }}
{{- if .BuiltinTools }}
Tools: {{ range $index, $tool := .BuiltinTools }}{{ if ne $tool "code_interpreter" }}{{ if $index }}, {{ end }}{{ $tool }}{{ end }}{{ end }}
{{- end }}
Cutting Knowledge Date: December 2023
Today Date: {{ $dateString }}
{{- if and $tools (not $toolsInUserMessage) }}
You have access to the following functions. To call a function, please respond with JSON for a function call.Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.Do not use variables.
{{ range $tools }}
{{ json . 4 }}
{{ end }}
{{- end }}
{{ $systemMessage }}<|eot_id>
{{/* Custom Tools in User Message */}}
{{- if and $toolsInUserMessage $tools }}
{{- if gt (len $messages) 0 }}
{{- $firstUserMessage := (index $messages 0).Content }}
{{- $messages = slice $messages 1 }}
<|start_header_id|>user<|end_header_id>
Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.Do not use variables.
{{ range $tools }}
{{ json . 4 }}
{{ end }}
{{ $firstUserMessage }}<|eot_id>
{{- else }}
<!-- Error: Cannot put tools in the first user message when there's no first user message! -->
{{- end }}
{{- end }}
{{/* Messages Loop */}}
{{- range $messages }}
{{- if not (or (eq .Role "ipython") (eq .Role "tool") .ToolCalls) }}
<|start_header_id|>{{ .Role }}<|end_header_id>
{{ .Content }}<|eot_id>
{{- else if .ToolCalls }}
{{- if gt (len .ToolCalls) 1 }}
<!-- Error: This model only supports single tool-calls at once! -->
{{- else }}
{{- $toolCall := (index .ToolCalls 0).Function }}
<|start_header_id|>assistant<|end_header_id>
{{- if .BuiltinTools }}
<|python_tag>{{ $toolCall.Name }}.call({{ range $index, $arg := $toolCall.Arguments }}{{ if $index }}, {{ end }}{{ $index }}="{{ $arg }}"{{ end }})
<|eom_id>
{{- else }}
{"name": "{{ $toolCall.Name }}", "parameters": {{ json $toolCall.Arguments }}}
<|eot_id>
{{- end }}
{{- end }}
{{- else if or (eq .Role "tool") (eq .Role "ipython") }}
<|start_header_id|>ipython<|end_header_id>
{{ .Content }}<|eot_id>
{{- end }}
{{- end }}
{{/* Generation Prompt */}}
{{- if .AddGenerationPrompt }}
<|start_header_id|>assistant<|end_header_id>
{{- end }}