LLM for Unity  v2.3.0
Create characters in Unity with LLMs!
Loading...
Searching...
No Matches
LLMUnity.LLMManager Class Reference

Class implementing the LLM model manager. More...

Static Public Member Functions

static void SetDownloadProgress (float progress)
 Sets the model download progress in all registered callbacks.
 
static Task< bool > Setup ()
 Setup of the models.
 
static async Task< bool > SetupOnce ()
 Task performing the setup of the models.
 
static void SetTemplate (string filename, string chatTemplate)
 Sets the chat template for a model and distributes it to all LLMs using it.
 
static void SetTemplate (ModelEntry entry, string chatTemplate)
 Sets the chat template for a model and distributes it to all LLMs using it.
 
static ModelEntry Get (string path)
 Gets the model entry for a model path.
 
static string GetAssetPath (string filename)
 Gets the asset path based on whether the application runs locally in the editor or in a build.
 
static int Num (bool lora)
 Returns the number of LLM/LORA models.
 
static int NumModels ()
 Returns the number of LLM models.
 
static int NumLoras ()
 Returns the number of LORA models.
 
static void Register (LLM llm)
 Registers a LLM to the model manager.
 
static void Unregister (LLM llm)
 Removes a LLM from the model manager.
 
static void LoadFromDisk ()
 Loads the model manager from a file.
 
static string AddEntry (ModelEntry entry)
 Adds a model entry to the model manager.
 
static string AddEntry (string path, bool lora=false, string label=null, string url=null)
 Creates and adds a model entry to the model manager.
 
static async Task< string > Download (string url, bool lora=false, bool log=false, string label=null)
 Downloads a model and adds a model entry to the model manager.
 
static string Load (string path, bool lora=false, bool log=false, string label=null)
 Loads a model from disk and adds a model entry to the model manager.
 
static async Task< string > DownloadModel (string url, bool log=false, string label=null)
 Downloads a LLM model from disk and adds a model entry to the model manager.
 
static async Task< string > DownloadLora (string url, bool log=false, string label=null)
 Downloads a Lora model from disk and adds a model entry to the model manager.
 
static string LoadModel (string path, bool log=false, string label=null)
 Loads a LLM model from disk and adds a model entry to the model manager.
 
static string LoadLora (string path, bool log=false, string label=null)
 Loads a LORA model from disk and adds a model entry to the model manager.
 
static void SetURL (string filename, string url)
 Sets the URL for a model.
 
static void SetURL (ModelEntry entry, string url)
 Sets the URL for a model.
 
static void SetIncludeInBuild (string filename, bool includeInBuild)
 Sets whether to include a model to the build.
 
static void SetIncludeInBuild (ModelEntry entry, bool includeInBuild)
 Sets whether to include a model to the build.
 
static void SetDownloadOnStart (bool value)
 Sets whether to download files on start.
 
static void Remove (string filename)
 Removes a model from the model manager.
 
static void Remove (ModelEntry entry)
 Removes a model from the model manager.
 
static void SetModelProgress (float progress)
 Sets the LLM download progress.
 
static void SetLoraProgress (float progress)
 Sets the LORA download progress.
 
static void Save ()
 Serialises and saves the model manager.
 
static void Load ()
 Deserialises and loads the model manager.
 
static void SaveToDisk ()
 Saves the model manager to disk for the build.
 
static void Build (ActionCallback copyCallback)
 Saves the model manager to disk along with models that are not (or can't) be downloaded for the build.
 

Static Public Attributes

static bool downloadOnStart = false
 
static List< ModelEntrymodelEntries = new List<ModelEntry>()
 
static float downloadProgress = 1
 
static List< Callback< float > > downloadProgressCallbacks = new List<Callback<float>>()
 
static float modelProgress = 1
 
static float loraProgress = 1
 

Detailed Description

Class implementing the LLM model manager.

Definition at line 108 of file LLMManager.cs.

Member Function Documentation

◆ AddEntry() [1/2]

static string LLMUnity.LLMManager.AddEntry ( ModelEntry entry)
inlinestatic

Adds a model entry to the model manager.

Parameters
entrymodel entry
Returns
model filename

Definition at line 345 of file LLMManager.cs.

◆ AddEntry() [2/2]

static string LLMUnity.LLMManager.AddEntry ( string path,
bool lora = false,
string label = null,
string url = null )
inlinestatic

Creates and adds a model entry to the model manager.

Parameters
pathmodel path
loraif it is a LORA or LLM
labellabel to show in the model manager in the Editor
urlmodel url
Returns
model filename

Definition at line 376 of file LLMManager.cs.

◆ Build()

static void LLMUnity.LLMManager.Build ( ActionCallback copyCallback)
inlinestatic

Saves the model manager to disk along with models that are not (or can't) be downloaded for the build.

Parameters
copyCallbackcopy function

Definition at line 648 of file LLMManager.cs.

◆ Download()

static async Task< string > LLMUnity.LLMManager.Download ( string url,
bool lora = false,
bool log = false,
string label = null )
inlinestatic

Downloads a model and adds a model entry to the model manager.

Parameters
urlmodel url
loraif it is a LORA or LLM
logwhether to log
labelmodel label
Returns
model filename

Definition at line 389 of file LLMManager.cs.

◆ DownloadLora()

static async Task< string > LLMUnity.LLMManager.DownloadLora ( string url,
bool log = false,
string label = null )
inlinestatic

Downloads a Lora model from disk and adds a model entry to the model manager.

Parameters
urlmodel url
logwhether to log
labelmodel label
Returns
model filename

Definition at line 472 of file LLMManager.cs.

◆ DownloadModel()

static async Task< string > LLMUnity.LLMManager.DownloadModel ( string url,
bool log = false,
string label = null )
inlinestatic

Downloads a LLM model from disk and adds a model entry to the model manager.

Parameters
urlmodel url
logwhether to log
labelmodel label
Returns
model filename

Definition at line 460 of file LLMManager.cs.

◆ Get()

static ModelEntry LLMUnity.LLMManager.Get ( string path)
inlinestatic

Gets the model entry for a model path.

Parameters
pathmodel path
Returns
model entry

Definition at line 239 of file LLMManager.cs.

◆ GetAssetPath()

static string LLMUnity.LLMManager.GetAssetPath ( string filename)
inlinestatic

Gets the asset path based on whether the application runs locally in the editor or in a build.

Parameters
filenamemodel filename or relative path
Returns
asset path

Definition at line 255 of file LLMManager.cs.

◆ Load() [1/2]

static void LLMUnity.LLMManager.Load ( )
inlinestatic

Deserialises and loads the model manager.

Definition at line 620 of file LLMManager.cs.

◆ Load() [2/2]

static string LLMUnity.LLMManager.Load ( string path,
bool lora = false,
bool log = false,
string label = null )
inlinestatic

Loads a model from disk and adds a model entry to the model manager.

Parameters
pathmodel path
loraif it is a LORA or LLM
logwhether to log
labelmodel label
Returns
model filename

Definition at line 442 of file LLMManager.cs.

◆ LoadFromDisk()

static void LLMUnity.LLMManager.LoadFromDisk ( )
inlinestatic

Loads the model manager from a file.

Definition at line 320 of file LLMManager.cs.

◆ LoadLora()

static string LLMUnity.LLMManager.LoadLora ( string path,
bool log = false,
string label = null )
inlinestatic

Loads a LORA model from disk and adds a model entry to the model manager.

Parameters
pathmodel path
logwhether to log
labelmodel label
Returns
model filename

Definition at line 496 of file LLMManager.cs.

◆ LoadModel()

static string LLMUnity.LLMManager.LoadModel ( string path,
bool log = false,
string label = null )
inlinestatic

Loads a LLM model from disk and adds a model entry to the model manager.

Parameters
pathmodel path
logwhether to log
labelmodel label
Returns
model filename

Definition at line 484 of file LLMManager.cs.

◆ Num()

static int LLMUnity.LLMManager.Num ( bool lora)
inlinestatic

Returns the number of LLM/LORA models.

Parameters
lorawhether to return number of LORA or LLM models
Returns
number of LLM/LORA models

Definition at line 271 of file LLMManager.cs.

◆ NumLoras()

static int LLMUnity.LLMManager.NumLoras ( )
inlinestatic

Returns the number of LORA models.

Returns
number of LORA models

Definition at line 294 of file LLMManager.cs.

◆ NumModels()

static int LLMUnity.LLMManager.NumModels ( )
inlinestatic

Returns the number of LLM models.

Returns
number of LLM models

Definition at line 285 of file LLMManager.cs.

◆ Register()

static void LLMUnity.LLMManager.Register ( LLM llm)
inlinestatic

Registers a LLM to the model manager.

Parameters
llmLLM

Definition at line 303 of file LLMManager.cs.

◆ Remove() [1/2]

static void LLMUnity.LLMManager.Remove ( ModelEntry entry)
inlinestatic

Removes a model from the model manager.

Parameters
filenamemodel entry

Definition at line 577 of file LLMManager.cs.

◆ Remove() [2/2]

static void LLMUnity.LLMManager.Remove ( string filename)
inlinestatic

Removes a model from the model manager.

Parameters
filenamemodel filename

Definition at line 568 of file LLMManager.cs.

◆ Save()

static void LLMUnity.LLMManager.Save ( )
inlinestatic

Serialises and saves the model manager.

Definition at line 610 of file LLMManager.cs.

◆ SaveToDisk()

static void LLMUnity.LLMManager.SaveToDisk ( )
inlinestatic

Saves the model manager to disk for the build.

Definition at line 632 of file LLMManager.cs.

◆ SetDownloadOnStart()

static void LLMUnity.LLMManager.SetDownloadOnStart ( bool value)
inlinestatic

Sets whether to download files on start.

Parameters
valuewhether to download files

Definition at line 549 of file LLMManager.cs.

◆ SetDownloadProgress()

static void LLMUnity.LLMManager.SetDownloadProgress ( float progress)
inlinestatic

Sets the model download progress in all registered callbacks.

Parameters
progressmodel download progress

Definition at line 126 of file LLMManager.cs.

◆ SetIncludeInBuild() [1/2]

static void LLMUnity.LLMManager.SetIncludeInBuild ( ModelEntry entry,
bool includeInBuild )
inlinestatic

Sets whether to include a model to the build.

Parameters
entrymodel entry
includeInBuildwhether to include it

Definition at line 538 of file LLMManager.cs.

◆ SetIncludeInBuild() [2/2]

static void LLMUnity.LLMManager.SetIncludeInBuild ( string filename,
bool includeInBuild )
inlinestatic

Sets whether to include a model to the build.

Parameters
filenamemodel filename
includeInBuildwhether to include it

Definition at line 528 of file LLMManager.cs.

◆ SetLoraProgress()

static void LLMUnity.LLMManager.SetLoraProgress ( float progress)
inlinestatic

Sets the LORA download progress.

Parameters
progressdownload progress

Definition at line 602 of file LLMManager.cs.

◆ SetModelProgress()

static void LLMUnity.LLMManager.SetModelProgress ( float progress)
inlinestatic

Sets the LLM download progress.

Parameters
progressdownload progress

Definition at line 593 of file LLMManager.cs.

◆ SetTemplate() [1/2]

static void LLMUnity.LLMManager.SetTemplate ( ModelEntry entry,
string chatTemplate )
inlinestatic

Sets the chat template for a model and distributes it to all LLMs using it.

Parameters
entrymodel entry
chatTemplatechat template

Definition at line 221 of file LLMManager.cs.

◆ SetTemplate() [2/2]

static void LLMUnity.LLMManager.SetTemplate ( string filename,
string chatTemplate )
inlinestatic

Sets the chat template for a model and distributes it to all LLMs using it.

Parameters
filenamemodel path
chatTemplatechat template

Definition at line 211 of file LLMManager.cs.

◆ Setup()

static Task< bool > LLMUnity.LLMManager.Setup ( )
inlinestatic

Setup of the models.

Returns
bool specifying if the setup was successful

Definition at line 136 of file LLMManager.cs.

◆ SetupOnce()

static async Task< bool > LLMUnity.LLMManager.SetupOnce ( )
inlinestatic

Task performing the setup of the models.

Returns
bool specifying if the setup was successful

Definition at line 149 of file LLMManager.cs.

◆ SetURL() [1/2]

static void LLMUnity.LLMManager.SetURL ( ModelEntry entry,
string url )
inlinestatic

Sets the URL for a model.

Parameters
entrymodel entry
urlmodel URL

Definition at line 516 of file LLMManager.cs.

◆ SetURL() [2/2]

static void LLMUnity.LLMManager.SetURL ( string filename,
string url )
inlinestatic

Sets the URL for a model.

Parameters
filenamemodel filename
urlmodel URL

Definition at line 506 of file LLMManager.cs.

◆ Unregister()

static void LLMUnity.LLMManager.Unregister ( LLM llm)
inlinestatic

Removes a LLM from the model manager.

Parameters
llmLLM

Definition at line 312 of file LLMManager.cs.

Member Data Documentation

◆ downloadOnStart

bool LLMUnity.LLMManager.downloadOnStart = false
static

Definition at line 110 of file LLMManager.cs.

◆ downloadProgress

float LLMUnity.LLMManager.downloadProgress = 1
static

Definition at line 114 of file LLMManager.cs.

◆ downloadProgressCallbacks

List<Callback<float> > LLMUnity.LLMManager.downloadProgressCallbacks = new List<Callback<float>>()
static

Definition at line 115 of file LLMManager.cs.

◆ loraProgress

float LLMUnity.LLMManager.loraProgress = 1
static

Definition at line 332 of file LLMManager.cs.

◆ modelEntries

List<ModelEntry> LLMUnity.LLMManager.modelEntries = new List<ModelEntry>()
static

Definition at line 111 of file LLMManager.cs.

◆ modelProgress

float LLMUnity.LLMManager.modelProgress = 1
static

Definition at line 331 of file LLMManager.cs.


The documentation for this class was generated from the following file: