LLM for Unity
v2.3.0
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 > messages, 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 |
Reimplemented in LLMUnity.GemmaTemplate, and LLMUnity.Phi3Template.
Definition at line 172 of file LLMChatTemplates.cs.
|
inlinestatic |
Definition at line 120 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 115 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 80 of file LLMChatTemplates.cs.
|
inlinestatic |
Determines the chat template name from a Jinja template.
template | Jinja template |
Definition at line 96 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.VicunaTemplate, LLMUnity.Phi3Template, LLMUnity.Phi3_5Template, and LLMUnity.ZephyrTemplate.
Definition at line 153 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, and LLMUnity.ZephyrTemplate.
Definition at line 149 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, and LLMUnity.ZephyrTemplate.
Definition at line 147 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, and LLMUnity.ZephyrTemplate.
Definition at line 151 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, and LLMUnity.ZephyrTemplate.
Definition at line 155 of file LLMChatTemplates.cs.
|
inlinestatic |
Creates the chat template based on the provided chat template name.
template | chat template name |
Definition at line 141 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.