![]() |
LLM for Unity
v2.5.1
Create characters in Unity with LLMs!
|
Class implementing the skeleton of a chat template. More...
Public Member Functions | |
virtual string | GetName () |
Returns the chat template name. | |
virtual string | GetDescription () |
Returns the chat template description. | |
virtual string[] | GetNameMatches () |
Returns an array of names that can be used to match the chat template. | |
virtual string[] | GetChatTemplateMatches () |
Returns an array of jinja templates that can be used to match the chat template. | |
virtual string[] | GetStop (string playerName, string AIName) |
Returns an array of the stopwords used by the template. | |
virtual string | ComputePrompt (List< ChatMessage > chatMessages, string playerName, string AIName, bool endWithPrefix=true) |
Constructs the prompt using the template based on a list of ChatMessages. | |
Static Public Member Functions | |
static string | FromName (string name) |
Determines the chat template name from a search name. It searches if any of the chat template names is a substring of the provided name. | |
static string | FromTemplate (string template) |
Determines the chat template name from a Jinja template. | |
static string | FromGGUF (string path) |
Determines the chat template name from a GGUF file. It reads the GGUF file and then determines the chat template name based on: | |
static string | FromGGUF (GGUFReader reader, string path) |
static ChatTemplate | GetTemplate (string template) |
Creates the chat template based on the provided chat template name. | |
Static Public Attributes | |
static string | DefaultTemplate |
the default template used when it can't be determined ("chatml") | |
static Dictionary< string, ChatTemplate > | templates |
a dictionary from chat template name to chat template type. It can be used to get the chat template names supported with: | |
Class implementing the skeleton of a chat template.
Definition at line 12 of file LLMChatTemplates.cs.
|
inlinevirtual |
Constructs the prompt using the template based on a list of ChatMessages.
messages | list of ChatMessages e.g. the LLMCharacter chat |
AIName | the AI name |
endWithPrefix | whether to end the prompt with the AI prefix |
Definition at line 188 of file LLMChatTemplates.cs.
|
inlinestatic |
Definition at line 133 of file LLMChatTemplates.cs.
|
inlinestatic |
Determines the chat template name from a GGUF file. It reads the GGUF file and then determines the chat template name based on:
path | GGUF file path |
Definition at line 128 of file LLMChatTemplates.cs.
|
inlinestatic |
Determines the chat template name from a search name. It searches if any of the chat template names is a substring of the provided name.
name | search name |
Definition at line 87 of file LLMChatTemplates.cs.
|
inlinestatic |
Determines the chat template name from a Jinja template.
template | Jinja template |
Definition at line 109 of file LLMChatTemplates.cs.
|
inlinevirtual |
Returns an array of jinja templates that can be used to match the chat template.
Reimplemented in LLMUnity.ChatMLTemplate, LLMUnity.LLama3ChatTemplate, LLMUnity.MistralChatTemplate, LLMUnity.GemmaTemplate, LLMUnity.VicunaTemplate, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, LLMUnity.Phi4MiniTemplate, LLMUnity.Phi4Template, LLMUnity.ZephyrTemplate, LLMUnity.DeepSeekV2Template, LLMUnity.DeepSeekV3Template, LLMUnity.DeepSeekR1Template, LLMUnity.Qwen3Template, and LLMUnity.BitNetTemplate.
Definition at line 166 of file LLMChatTemplates.cs.
|
inlinevirtual |
Returns the chat template description.
Reimplemented in LLMUnity.ChatMLTemplate, LLMUnity.LLama2Template, LLMUnity.LLama2ChatTemplate, LLMUnity.LLama3ChatTemplate, LLMUnity.MistralInstructTemplate, LLMUnity.MistralChatTemplate, LLMUnity.GemmaTemplate, LLMUnity.AlpacaTemplate, LLMUnity.VicunaTemplate, LLMUnity.Phi2Template, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, LLMUnity.Phi4MiniTemplate, LLMUnity.Phi4Template, LLMUnity.ZephyrTemplate, LLMUnity.DeepSeekV2Template, LLMUnity.DeepSeekV3Template, LLMUnity.DeepSeekR1Template, LLMUnity.Qwen3Template, and LLMUnity.BitNetTemplate.
Definition at line 162 of file LLMChatTemplates.cs.
|
inlinevirtual |
Returns the chat template name.
Reimplemented in LLMUnity.ChatMLTemplate, LLMUnity.LLama2Template, LLMUnity.LLama2ChatTemplate, LLMUnity.LLama3ChatTemplate, LLMUnity.MistralInstructTemplate, LLMUnity.MistralChatTemplate, LLMUnity.GemmaTemplate, LLMUnity.AlpacaTemplate, LLMUnity.VicunaTemplate, LLMUnity.Phi2Template, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, LLMUnity.Phi4MiniTemplate, LLMUnity.Phi4Template, LLMUnity.ZephyrTemplate, LLMUnity.DeepSeekV2Template, LLMUnity.DeepSeekV3Template, LLMUnity.DeepSeekR1Template, LLMUnity.Qwen3Template, and LLMUnity.BitNetTemplate.
Definition at line 160 of file LLMChatTemplates.cs.
|
inlinevirtual |
Returns an array of names that can be used to match the chat template.
Reimplemented in LLMUnity.ChatMLTemplate, LLMUnity.LLama2ChatTemplate, LLMUnity.LLama3ChatTemplate, LLMUnity.MistralChatTemplate, LLMUnity.GemmaTemplate, LLMUnity.AlpacaTemplate, LLMUnity.VicunaTemplate, LLMUnity.Phi2Template, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, LLMUnity.Phi4MiniTemplate, LLMUnity.Phi4Template, LLMUnity.ZephyrTemplate, LLMUnity.DeepSeekV2Template, LLMUnity.DeepSeekV3Template, LLMUnity.DeepSeekR1Template, LLMUnity.Qwen3Template, and LLMUnity.BitNetTemplate.
Definition at line 164 of file LLMChatTemplates.cs.
|
inlinevirtual |
Returns an array of the stopwords used by the template.
Reimplemented in LLMUnity.ChatMLTemplate, LLMUnity.LLama2Template, LLMUnity.LLama2ChatTemplate, LLMUnity.LLama3ChatTemplate, LLMUnity.MistralInstructTemplate, LLMUnity.MistralChatTemplate, LLMUnity.GemmaTemplate, LLMUnity.AlpacaTemplate, LLMUnity.VicunaTemplate, LLMUnity.Phi2Template, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, LLMUnity.Phi4MiniTemplate, LLMUnity.Phi4Template, LLMUnity.ZephyrTemplate, LLMUnity.DeepSeekV2Template, LLMUnity.DeepSeekV3Template, LLMUnity.DeepSeekR1Template, and LLMUnity.BitNetTemplate.
Definition at line 168 of file LLMChatTemplates.cs.
|
inlinestatic |
Creates the chat template based on the provided chat template name.
template | chat template name |
Definition at line 154 of file LLMChatTemplates.cs.
|
static |
the default template used when it can't be determined ("chatml")
Definition at line 15 of file LLMChatTemplates.cs.
|
static |
a dictionary from chat template name to chat template type. It can be used to get the chat template names supported with:
Definition at line 22 of file LLMChatTemplates.cs.