LLM for Unity  v2.2.5
Create characters in Unity with LLMs!
Loading...
Searching...
No Matches
LLMChatTemplates.cs
Go to the documentation of this file.
1
3using System;
4using System.Collections.Generic;
5using System.IO;
6using UnityEngine;
7
8namespace LLMUnity
9{
14 public abstract class ChatTemplate
15 {
17 public static string DefaultTemplate;
24 public static Dictionary<string, ChatTemplate> templates;
26 public static ChatTemplate[] templateClasses;
27 public static Dictionary<string, string> templatesDescription;
28 public static Dictionary<string, string> modelTemplates;
29 public static Dictionary<string, string> chatTemplates;
31
32 static ChatTemplate()
33 {
34 DefaultTemplate = "chatml";
35
36 templateClasses = new ChatTemplate[]
37 {
38 new ChatMLTemplate(),
39 new AlpacaTemplate(),
40 new GemmaTemplate(),
45 new LLama2Template(),
46 new Phi3_5Template(),
47 new Phi3Template(),
48 new Phi2Template(),
49 new VicunaTemplate(),
50 new ZephyrTemplate(),
51 };
52
53 templates = new Dictionary<string, ChatTemplate>();
54 templatesDescription = new Dictionary<string, string>();
55 modelTemplates = new Dictionary<string, string>();
56 chatTemplates = new Dictionary<string, string>();
57 foreach (ChatTemplate template in templateClasses)
58 {
59 if (templates.ContainsKey(template.GetName())) LLMUnitySetup.LogError($"{template.GetName()} already in templates");
60 templates[template.GetName()] = template;
61 if (templatesDescription.ContainsKey(template.GetDescription())) LLMUnitySetup.LogError($"{template.GetDescription()} already in templatesDescription");
62 templatesDescription[template.GetDescription()] = template.GetName();
63 foreach (string match in template.GetNameMatches())
64 {
65 if (modelTemplates.ContainsKey(match)) LLMUnitySetup.LogError($"{match} already in modelTemplates");
66 modelTemplates[match] = template.GetName();
67 }
68 foreach (string match in template.GetChatTemplateMatches())
69 {
70 if (chatTemplates.ContainsKey(match)) LLMUnitySetup.LogError($"{match} already in chatTemplates");
71 chatTemplates[match] = template.GetName();
72 }
73 }
74 }
75
82 public static string FromName(string name)
83 {
84 if (name == null) return null;
85 string nameLower = name.ToLower();
86 foreach (var pair in modelTemplates)
87 {
88 if (nameLower.Contains(pair.Key)) return pair.Value;
89 }
90 return null;
91 }
92
98 public static string FromTemplate(string template)
99 {
100 if (template == null) return null;
101 string templateTrim = template.Trim();
102 if (chatTemplates.TryGetValue(templateTrim, out string value))
103 return value;
104 return null;
105 }
106
117 public static string FromGGUF(string path)
118 {
119 return FromGGUF(new GGUFReader(path), path);
120 }
121
122 public static string FromGGUF(GGUFReader reader, string path)
123 {
124 string name;
125 name = FromTemplate(reader.GetStringField("tokenizer.chat_template"));
126 if (name != null) return name;
127
128 name = FromName(reader.GetStringField("general.name"));
129 if (name != null) return name;
130
131 name = FromName(Path.GetFileNameWithoutExtension(path));
132 if (name != null) return name;
133
134 LLMUnitySetup.Log("No chat template could be matched, fallback to ChatML");
135 return DefaultTemplate;
136 }
137
143 public static ChatTemplate GetTemplate(string template)
144 {
145 return templates[template];
146 }
147
149 public virtual string GetName() { return ""; }
151 public virtual string GetDescription() { return ""; }
153 public virtual string[] GetNameMatches() { return new string[] {}; }
155 public virtual string[] GetChatTemplateMatches() { return new string[] {}; }
157 public virtual string[] GetStop(string playerName, string AIName) { return new string[] {}; }
158
159 protected virtual string PromptPrefix() { return ""; }
160 protected virtual string SystemPrefix() { return ""; }
161 protected virtual string SystemSuffix() { return ""; }
162 protected virtual string PlayerPrefix(string playerName) { return ""; }
163 protected virtual string AIPrefix(string AIName) { return ""; }
164 protected virtual string PrefixMessageSeparator() { return ""; }
165 protected virtual string RequestPrefix() { return ""; }
166 protected virtual string RequestSuffix() { return ""; }
167 protected virtual string PairSuffix() { return ""; }
168
174 public virtual string ComputePrompt(List<ChatMessage> messages, string playerName, string AIName, bool endWithPrefix = true)
175 {
176 string chatPrompt = PromptPrefix();
177 int start = 0;
178 if (messages[0].role == "system")
179 {
180 chatPrompt += RequestPrefix() + SystemPrefix() + messages[0].content + SystemSuffix();
181 start = 1;
182 }
183 for (int i = start; i < messages.Count; i += 2)
184 {
185 if (i > start || start == 0) chatPrompt += RequestPrefix();
186 chatPrompt += PlayerPrefix(messages[i].role) + PrefixMessageSeparator() + messages[i].content + RequestSuffix();
187 if (i < messages.Count - 1)
188 {
189 chatPrompt += AIPrefix(messages[i + 1].role) + PrefixMessageSeparator() + messages[i + 1].content + PairSuffix();
190 }
191 }
192 if (endWithPrefix) chatPrompt += AIPrefix(AIName);
193 return chatPrompt;
194 }
195
196 protected string[] AddStopNewlines(string[] stop)
197 {
198 List<string> stopWithNewLines = new List<string>();
199 foreach (string stopword in stop)
200 {
201 stopWithNewLines.Add(stopword);
202 stopWithNewLines.Add("\n" + stopword);
203 }
204 return stopWithNewLines.ToArray();
205 }
206 }
207
213 {
214 public override string GetName() { return "chatml"; }
215 public override string GetDescription() { return "chatml (most widely used)"; }
216 public override string[] GetNameMatches() { return new string[] {"chatml", "hermes", "qwen"}; }
217 public override string[] GetChatTemplateMatches() { return new string[] {"{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"}; }
218
219 protected override string SystemPrefix() { return "<|im_start|>system\n"; }
220 protected override string SystemSuffix() { return "<|im_end|>\n"; }
221 protected override string PlayerPrefix(string playerName) { return $"<|im_start|>{playerName}\n"; }
222 protected override string AIPrefix(string AIName) { return $"<|im_start|>{AIName}\n"; }
223 protected override string RequestSuffix() { return "<|im_end|>\n"; }
224 protected override string PairSuffix() { return "<|im_end|>\n"; }
225
226 public override string[] GetStop(string playerName, string AIName)
227 {
228 return AddStopNewlines(new string[] { "<|im_start|>", "<|im_end|>" });
229 }
230 }
231
237 {
238 public override string GetName() { return "llama"; }
239 public override string GetDescription() { return "llama 2"; }
240
241 protected override string SystemPrefix() { return "<<SYS>>\n"; }
242 protected override string SystemSuffix() { return "\n<</SYS>> "; }
243 protected override string RequestPrefix() { return "<s>[INST] "; }
244 protected override string RequestSuffix() { return " [/INST]"; }
245 protected override string PairSuffix() { return " </s>"; }
246
247 public override string[] GetStop(string playerName, string AIName)
248 {
249 return AddStopNewlines(new string[] { "[INST]", "[/INST]" });
250 }
251 }
252
258 {
259 public override string GetName() { return "llama chat"; }
260 public override string GetDescription() { return "llama 2 (chat)"; }
261 public override string[] GetNameMatches() { return new string[] {"llama-2", "llama v2"}; }
262
263 protected override string PlayerPrefix(string playerName) { return "### " + playerName + ":"; }
264 protected override string AIPrefix(string AIName) { return "### " + AIName + ":"; }
265 protected override string PrefixMessageSeparator() { return " "; }
266
267 public override string[] GetStop(string playerName, string AIName)
268 {
269 return AddStopNewlines(new string[] { "[INST]", "[/INST]", "###" });
270 }
271 }
272
278 {
279 public override string GetName() { return "llama3 chat"; }
280 public override string GetDescription() { return "llama 3 (chat)"; }
281 public override string[] GetNameMatches() { return new string[] {"llama-3", "llama v3"}; }
282 public override string[] GetChatTemplateMatches() { return new string[] {"{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}"};}
283
284 protected override string SystemPrefix() { return "<|start_header_id|>system<|end_header_id|>\n\n"; }
285 protected override string SystemSuffix() { return "<|eot_id|>"; }
286
287 protected override string RequestSuffix() { return "<|eot_id|>"; }
288 protected override string PairSuffix() { return "<|eot_id|>"; }
289
290 protected override string PlayerPrefix(string playerName) { return $"<|start_header_id|>{playerName}<|end_header_id|>\n\n"; }
291 protected override string AIPrefix(string AIName) { return $"<|start_header_id|>{AIName}<|end_header_id|>\n\n"; }
292
293 public override string[] GetStop(string playerName, string AIName)
294 {
295 return AddStopNewlines(new string[] { "<|eot_id|>" });
296 }
297 }
298
304 {
305 public override string GetName() { return "mistral instruct"; }
306 public override string GetDescription() { return "mistral instruct"; }
307
308 protected override string SystemPrefix() { return ""; }
309 protected override string SystemSuffix() { return "\n\n"; }
310 protected override string RequestPrefix() { return "[INST] "; }
311 protected override string RequestSuffix() { return " [/INST]"; }
312 protected override string PairSuffix() { return "</s>"; }
313
314 public override string[] GetStop(string playerName, string AIName)
315 {
316 return AddStopNewlines(new string[] { "</s>", "[INST]", "[/INST]" });
317 }
318 }
319
325 {
326 public override string GetName() { return "mistral chat"; }
327 public override string GetDescription() { return "mistral (chat)"; }
328 public override string[] GetNameMatches() { return new string[] {"mistral"}; }
329 public override string[] GetChatTemplateMatches() { return new string[] {"{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}"}; }
330
331 protected override string PlayerPrefix(string playerName) { return "### " + playerName + ":"; }
332 protected override string AIPrefix(string AIName) { return "### " + AIName + ":"; }
333 protected override string PrefixMessageSeparator() { return " "; }
334
335 public override string[] GetStop(string playerName, string AIName)
336 {
337 return AddStopNewlines(new string[] { "</s>", "[INST]", "[/INST]", "###" });
338 }
339 }
340
346 {
347 public override string GetName() { return "gemma"; }
348 public override string GetDescription() { return "gemma"; }
349 public override string[] GetNameMatches() { return new string[] {"gemma"}; }
350
351 protected override string RequestSuffix() { return "<end_of_turn>\n"; }
352 protected override string PairSuffix() { return "<end_of_turn>\n"; }
353
354 protected override string PlayerPrefix(string playerName) { return "<start_of_turn>" + playerName + "\n"; }
355 protected override string AIPrefix(string AIName) { return "<start_of_turn>" + AIName + "\n"; }
356
357 public override string ComputePrompt(List<ChatMessage> messages, string playerName, string AIName, bool endWithPrefix = true)
358 {
359 List<ChatMessage> messagesSystemPrompt = messages;
360 if (messages[0].role == "system")
361 {
362 string firstUserMessage = messages[0].content;
363 int start = 1;
364 if (messages.Count > 1)
365 {
366 if (firstUserMessage != "") firstUserMessage += "\n\n";
367 firstUserMessage += messages[1].content;
368 start = 2;
369 }
370 messagesSystemPrompt = new List<ChatMessage>(){new ChatMessage { role = playerName, content = firstUserMessage }};
371 messagesSystemPrompt.AddRange(messages.GetRange(start, messages.Count - start));
372 }
373 return base.ComputePrompt(messagesSystemPrompt, playerName, AIName, endWithPrefix);
374 }
375
376 public override string[] GetStop(string playerName, string AIName)
377 {
378 return AddStopNewlines(new string[] { "<start_of_turn>", "<end_of_turn>" });
379 }
380 }
381
387 {
388 public override string GetName() { return "alpaca"; }
389 public override string GetDescription() { return "alpaca (best alternative)"; }
390 public override string[] GetNameMatches() { return new string[] {"alpaca"}; }
391
392 protected override string SystemSuffix() { return "\n\n"; }
393 protected override string RequestSuffix() { return "\n"; }
394 protected override string PlayerPrefix(string playerName) { return "### " + playerName + ":"; }
395 protected override string AIPrefix(string AIName) { return "### " + AIName + ":"; }
396 protected override string PrefixMessageSeparator() { return " "; }
397 protected override string PairSuffix() { return "\n"; }
398
399 public override string[] GetStop(string playerName, string AIName)
400 {
401 return AddStopNewlines(new string[] { "###" });
402 }
403 }
404
410 {
411 public override string GetName() { return "vicuna"; }
412 public override string GetDescription() { return "vicuna"; }
413 public override string[] GetNameMatches() { return new string[] {"vicuna"}; }
414 public override string[] GetChatTemplateMatches() { return new string[] {"{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{% if message['role'] == 'system' %}{{message['content'] + ' '}}{% elif message['role'] == 'user' %}{{ 'USER: ' + message['content'] + ' '}}{% elif message['role'] == 'assistant' %}{{ 'ASSISTANT: ' + message['content'] + ' '}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'ASSISTANT: '}}{% endif %}"}; }
415
416 protected override string SystemSuffix() { return "\n"; }
417 protected override string PlayerPrefix(string playerName) { return "\n" + playerName + ":"; }
418 protected override string AIPrefix(string AIName) { return "\n" + AIName + ":"; }
419 protected override string PrefixMessageSeparator() { return " "; }
420
421 public override string[] GetStop(string playerName, string AIName)
422 {
423 return AddStopNewlines(new string[] { playerName + ":", AIName + ":" });
424 }
425 }
426
432 {
433 public override string GetName() { return "phi"; }
434 public override string GetDescription() { return "phi-2"; }
435 public override string[] GetNameMatches() { return new string[] {"phi-2"}; }
436
437 protected override string SystemSuffix() { return "\n\n"; }
438 protected override string RequestSuffix() { return "\n"; }
439 protected override string PlayerPrefix(string playerName) { return playerName + ":"; }
440 protected override string AIPrefix(string AIName) { return AIName + ":"; }
441 protected override string PrefixMessageSeparator() { return " "; }
442 protected override string PairSuffix() { return "\n"; }
443
444 public override string[] GetStop(string playerName, string AIName)
445 {
446 return AddStopNewlines(new string[] { playerName + ":", AIName + ":" });
447 }
448 }
449
455 {
456 public override string GetName() { return "phi-3"; }
457 public override string GetDescription() { return "phi-3"; }
458 public override string[] GetNameMatches() { return new string[] {"phi-3"}; }
459 public override string[] GetChatTemplateMatches() { return new string[] {"{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|user|>' + '\n' + message['content'] + '<|end|>' + '\n' + '<|assistant|>' + '\n'}}{% elif (message['role'] == 'assistant') %}{{message['content'] + '<|end|>' + '\n'}}{% endif %}{% endfor %}"}; }
460
461 protected override string PlayerPrefix(string playerName) { return $"<|user|>\n"; }
462 protected override string AIPrefix(string AIName) { return $"<|assistant|>\n"; }
463 protected override string RequestSuffix() { return "<|end|>\n"; }
464 protected override string PairSuffix() { return "<|end|>\n"; }
465
466
467 public override string ComputePrompt(List<ChatMessage> messages, string playerName, string AIName, bool endWithPrefix = true)
468 {
469 List<ChatMessage> messagesSystemPrompt = messages;
470 if (messages[0].role == "system")
471 {
472 string firstUserMessage = messages[0].content;
473 int start = 1;
474 if (messages.Count > 1)
475 {
476 if (firstUserMessage != "") firstUserMessage += "\n\n";
477 firstUserMessage += messages[1].content;
478 start = 2;
479 }
480 messagesSystemPrompt = new List<ChatMessage>(){new ChatMessage { role = "user", content = firstUserMessage }};
481 messagesSystemPrompt.AddRange(messages.GetRange(start, messages.Count - start));
482 }
483 return base.ComputePrompt(messagesSystemPrompt, playerName, AIName, endWithPrefix);
484 }
485
486 public override string[] GetStop(string playerName, string AIName)
487 {
488 return AddStopNewlines(new string[] { "<|end|>", "<|user|>", "<|assistant|>" });
489 }
490 }
491
497 {
498 public override string GetName() { return "phi-3.5"; }
499 public override string GetDescription() { return "phi-3.5"; }
500 public override string[] GetNameMatches() { return new string[] {"phi-3.5"}; }
501 public override string[] GetChatTemplateMatches() { return new string[] {"{% for message in messages %}{% if message['role'] == 'system' and message['content'] %}{{'<|system|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'user' %}{{'<|user|>\n' + message['content'] + '<|end|>\n'}}{% elif message['role'] == 'assistant' %}{{'<|assistant|>\n' + message['content'] + '<|end|>\n'}}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% else %}{{ eos_token }}{% endif %}"};}
502
503 protected override string PlayerPrefix(string playerName) { return $"<|user|>\n"; }
504 protected override string AIPrefix(string AIName) { return $"<|assistant|>\n"; }
505 protected override string RequestSuffix() { return "<|end|>\n"; }
506 protected override string PairSuffix() { return "<|end|>\n"; }
507 protected override string SystemPrefix() { return "<|system|>\n"; }
508 protected override string SystemSuffix() { return "<|end|>\n"; }
509
510 public override string[] GetStop(string playerName, string AIName)
511 {
512 return AddStopNewlines(new string[] { "<|end|>", "<|user|>", "<|assistant|>" });
513 }
514 }
515
521 {
522 public override string GetName() { return "zephyr"; }
523 public override string GetDescription() { return "zephyr"; }
524 public override string[] GetNameMatches() { return new string[] {"zephyr"}; }
525 public override string[] GetChatTemplateMatches() { return new string[] {"{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '<|user|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'system' %}\n{{ '<|system|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'assistant' %}\n{{ '<|assistant|>\n' + message['content'] + eos_token }}\n{% endif %}\n{% if loop.last and add_generation_prompt %}\n{{ '<|assistant|>' }}\n{% endif %}\n{% endfor %}"}; }
526
527 protected override string SystemPrefix() { return "<|system|>\n"; }
528 protected override string SystemSuffix() { return "</s>\n"; }
529 protected override string PlayerPrefix(string playerName) { return $"<|user|>\n"; }
530 protected override string AIPrefix(string AIName) { return $"<|assistant|>\n"; }
531 protected override string RequestSuffix() { return "</s>\n"; }
532 protected override string PairSuffix() { return "</s>\n"; }
533
534 public override string[] GetStop(string playerName, string AIName)
535 {
536 return AddStopNewlines(new string[] { $"<|user|>", $"<|assistant|>" });
537 }
538 }
539}
Class implementing the Alpaca template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetDescription()
Returns the chat template description.
override string GetName()
Returns the chat template name.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
Class implementing the ChatML template.
override string GetName()
Returns the chat template name.
override string GetDescription()
Returns the chat template description.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
Class implementing the skeleton of a chat template.
static string FromGGUF(string path)
Determines the chat template name from a GGUF file. It reads the GGUF file and then determines the ch...
virtual string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
static Dictionary< string, ChatTemplate > templates
a dictionary from chat template name to chat template type. It can be used to get the chat template n...
virtual string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
static string FromName(string name)
Determines the chat template name from a search name. It searches if any of the chat template names i...
virtual string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
static ChatTemplate GetTemplate(string template)
Creates the chat template based on the provided chat template name.
virtual string ComputePrompt(List< ChatMessage > messages, string playerName, string AIName, bool endWithPrefix=true)
Constructs the prompt using the template based on a list of ChatMessages.
virtual string GetName()
Returns the chat template name.
virtual string GetDescription()
Returns the chat template description.
static string FromTemplate(string template)
Determines the chat template name from a Jinja template.
static string DefaultTemplate
the default template used when it can't be determined ("chatml")
Class implementing the GGUF reader.
Definition LLMGGUF.cs:55
string GetStringField(string key)
Allows to retrieve a string GGUF field.
Definition LLMGGUF.cs:140
Class implementing the Gemma template.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetDescription()
Returns the chat template description.
override string ComputePrompt(List< ChatMessage > messages, string playerName, string AIName, bool endWithPrefix=true)
Constructs the prompt using the template based on a list of ChatMessages.
override string GetName()
Returns the chat template name.
Class implementing helper functions for setup and process management.
Class implementing a modified version of the LLama2 template for chat.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetDescription()
Returns the chat template description.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string GetName()
Returns the chat template name.
Class implementing the LLama2 template.
override string GetName()
Returns the chat template name.
override string GetDescription()
Returns the chat template description.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
Class implementing the LLama3 template for chat.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string GetName()
Returns the chat template name.
override string GetDescription()
Returns the chat template description.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
Class implementing a modified version of the Mistral Instruct template for chat.
override string GetDescription()
Returns the chat template description.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string GetName()
Returns the chat template name.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
Class implementing the Mistral Instruct template.
override string GetDescription()
Returns the chat template description.
override string GetName()
Returns the chat template name.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
Class implementing the Phi-2 template.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string GetName()
Returns the chat template name.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetDescription()
Returns the chat template description.
Class implementing the Phi-3 template.
override string GetDescription()
Returns the chat template description.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetName()
Returns the chat template name.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string ComputePrompt(List< ChatMessage > messages, string playerName, string AIName, bool endWithPrefix=true)
Constructs the prompt using the template based on a list of ChatMessages.
Class implementing the Phi-3.5 template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string GetName()
Returns the chat template name.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string GetDescription()
Returns the chat template description.
Class implementing the Vicuna template.
override string GetDescription()
Returns the chat template description.
override string GetName()
Returns the chat template name.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
Class implementing the Zephyr template.
override string[] GetChatTemplateMatches()
Returns an array of jinja templates that can be used to match the chat template.
override string GetDescription()
Returns the chat template description.
override string GetName()
Returns the chat template name.
override string[] GetStop(string playerName, string AIName)
Returns an array of the stopwords used by the template.
override string[] GetNameMatches()
Returns an array of names that can be used to match the chat template.