Skip to content

Commit 27fe809

Browse files
committed
do not change template when downloading models at start
1 parent f4c3a7f commit 27fe809

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Runtime/LLM.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ public async Task DownloadDefaultModel(int optionIndex)
163163
await DownloadModel(modelUrl, modelName);
164164
}
165165

166-
public async Task DownloadModel(string modelUrl, string modelName, bool overwrite = false)
166+
public async Task DownloadModel(string modelUrl, string modelName, bool overwrite = false, bool setTemplate = true)
167167
{
168168
modelProgress = 0;
169169
string modelPath = LLMUnitySetup.GetAssetPath(modelName);
170-
await LLMUnitySetup.DownloadFile(modelUrl, modelPath, overwrite, SetModel, SetModelProgress);
170+
await LLMUnitySetup.DownloadFile(modelUrl, modelPath, overwrite, (string path) => SetModel(path, setTemplate), SetModelProgress);
171171
}
172172

173173
public async Task DownloadLora(string loraUrl, string loraName, bool overwrite = false)
@@ -177,10 +177,10 @@ public async Task DownloadLora(string loraUrl, string loraName, bool overwrite =
177177
await LLMUnitySetup.DownloadFile(loraUrl, loraPath, overwrite, SetLora, SetLoraProgress);
178178
}
179179

180-
public async Task DownloadModels()
180+
public async Task DownloadModels(bool overwrite = false)
181181
{
182-
if (modelURL != "") await DownloadModel(modelURL, model);
183-
if (loraURL != "") await DownloadLora(loraURL, lora);
182+
if (modelURL != "") await DownloadModel(modelURL, model, overwrite, false);
183+
if (loraURL != "") await DownloadLora(loraURL, lora, overwrite);
184184
}
185185

186186
public async Task AndroidExtractModels()
@@ -209,11 +209,11 @@ public async Task WaitUntilReady()
209209
/// Models supported are in .gguf format.
210210
/// </summary>
211211
/// <param name="path">path to model to use (.gguf format)</param>
212-
public void SetModel(string path)
212+
public void SetModel(string path, bool setTemplate = true)
213213
{
214214
// set the model and enable the model editor properties
215215
model = CopyAsset(path);
216-
SetTemplate(ChatTemplate.FromGGUF(LLMUnitySetup.GetAssetPath(model)));
216+
if (setTemplate) SetTemplate(ChatTemplate.FromGGUF(LLMUnitySetup.GetAssetPath(model)));
217217
#if UNITY_EDITOR
218218
if (!EditorApplication.isPlaying) EditorUtility.SetDirty(this);
219219
#endif

0 commit comments

Comments
 (0)