File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
packages/ollama-utils/src Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,23 @@ const CUSTOM_TEMPLATE_MAPPING: ((ggufTmpl: string) => OllamaCustomMappedTemplate
9191 stop : "[INST]" ,
9292 }
9393 : undefined ,
94+ ( ggufTmpl : string ) =>
95+ ggufTmpl . match ( / r w k v - w o r l d / )
96+ ? {
97+ // ref: https://huggingface.co/BlinkDL/rwkv-5-world
98+ ollamaTmpl : "{{ .System }}\nUser: {{ .Prompt }}\n\nAssistant:" ,
99+ stop : "### Instruction:" ,
100+ }
101+ : undefined ,
102+ ( ggufTmpl : string ) =>
103+ ( ggufTmpl . match ( / \[ g M A S K \] < s o p > / ) && ggufTmpl . match ( / < \| u s e r \| > / ) ) || ggufTmpl . match ( / c h a t g l m 4 / )
104+ ? {
105+ // ref: https://huggingface.co/THUDM/GLM-4-9B-0414
106+ ollamaTmpl :
107+ "[gMASK]<sop>{{ if .System }}<|system|>\n{{ .System }}{{ end }}{{ if .Prompt }}<|user|>\n{{ .Prompt }}{{ end }}<|assistant|>\n{{ .Response }}" ,
108+ stop : "<|user|>" ,
109+ }
110+ : undefined ,
94111] ;
95112
96113export function convertGGUFTemplateToOllama (
@@ -104,6 +121,9 @@ export function convertGGUFTemplateToOllama(
104121 if ( ! gguf . chat_template ) {
105122 return undefined ;
106123 }
124+ if ( gguf . chat_template . match ( / o u t e t t s - \d / ) ) {
125+ throw new Error ( "OuteTTS is not a text model" ) ;
126+ }
107127 // try matching by first 128 characters (allowing a bit of flexibility)
108128 const truncatedGGUFTmpl = gguf . chat_template . substring ( 0 , 128 ) ;
109129 for ( const tmpl of OLLAMA_CHAT_TEMPLATE_MAPPING ) {
You can’t perform that action at this time.
0 commit comments