Skip to content

Commit d1e3d34

Browse files
committed
wait on download, server ready
1 parent 44ba7f2 commit d1e3d34

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

Samples~/AndroidDemo/AndroidDemo.cs

+13-21
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,29 @@ public class AndroidDemo : MonoBehaviour
2020
public Text progressText;
2121
int cores;
2222

23-
void Awake()
24-
{
25-
ChatPanel.SetActive(false);
26-
DownloadPanel.SetActive(false);
27-
}
28-
29-
void Start()
23+
async void Start()
3024
{
3125
playerText.onSubmit.AddListener(onInputFieldSubmit);
3226
playerText.interactable = false;
33-
StartCoroutine(Loading());
27+
await ShowDownloadScreen();
28+
await WarmUp();
3429
}
3530

36-
IEnumerator<string> Loading()
31+
async Task ShowDownloadScreen()
3732
{
33+
ChatPanel.SetActive(false);
3834
DownloadPanel.SetActive(true);
39-
AIText.text = "Downloading model...";
40-
Task downloadTask = llm.DownloadModel(
41-
"https://huggingface.co/afrideva/smol_llama-220M-openhermes-GGUF/resolve/main/smol_llama-220m-openhermes.q4_k_m.gguf?download=true",
42-
SetProgress
43-
);
44-
while (!downloadTask.IsCompleted) yield return null;
45-
llm.SetTemplate("alpaca");
35+
// await llm.WaitUntilModelDownloaded(SetProgress);
4636
DownloadPanel.SetActive(false);
47-
4837
ChatPanel.SetActive(true);
49-
cores = LLMUnitySetup.AndroidGetNumBigCores();
50-
AIText.text += $"\nWarming up the model...\nWill use {cores} cores";
51-
Task warmup = llmCharacter.Warmup();
52-
while (!warmup.IsCompleted) yield return null;
38+
}
5339

40+
async Task WarmUp()
41+
{
42+
llm.SetTemplate("alpaca");
43+
cores = LLMUnitySetup.AndroidGetNumBigCores();
44+
AIText.text += $"Warming up the model...\nWill use {cores} cores";
45+
await llmCharacter.Warmup();
5446
AIText.text = $"Ready when you are ({cores} cores)!";
5547
AIReplyComplete();
5648
}

Samples~/AndroidDemo/Scene.unity

+7-5
Original file line numberDiff line numberDiff line change
@@ -1323,22 +1323,24 @@ MonoBehaviour:
13231323
advancedOptions: 0
13241324
remote: 0
13251325
port: 13333
1326-
numThreads: -1
1326+
numThreads: 2
13271327
numGPULayers: 0
1328-
debug: 1
1328+
debug: 0
13291329
parallelPrompts: -1
13301330
asynchronousStartup: 1
13311331
dontDestroyOnLoad: 1
1332-
model: smol_llama-220m-openhermes.q4_k_m.gguf
1332+
model: Phi-3-mini-4k-instruct-q4.gguf
1333+
downloadOnBuild: 0
1334+
modelURL: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf?download=true
13331335
lora:
13341336
contextSize: 0
13351337
batchSize: 512
13361338
basePrompt:
1337-
SelectedModel: 0
1339+
SelectedModel: 3
13381340
modelProgress: 1
13391341
modelCopyProgress: 1
13401342
modelHide: 1
1341-
chatTemplate: chatml
1343+
chatTemplate: phi-3
13421344
--- !u!4 &1047848255
13431345
Transform:
13441346
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)